[PredicateInfo] Add a method to interpret predicate as cmp constraint
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Jul 2020 20:52:50 +0000 (22:52 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 19 Jul 2020 13:34:32 +0000 (15:34 +0200)
commitc6e13667e787b3a72b794422ab506d5403ddcd21
tree5e12e98505eee3cfea9ac42a3231448bb7082d96
parentfb5577d4f883ba21a6fe048ffd59ca3659cdb491
[PredicateInfo] Add a method to interpret predicate as cmp constraint

Both users of predicteinfo (NewGVN and SCCP) are interested in
getting a cmp constraint on the predicated value. They currently
implement separate logic for this. This patch adds a common method
for this in PredicateBase.

This enables a missing bit of PredicateInfo handling in SCCP: Now
the predicate on the condition itself is also used. For switches
it means we know that the switched-on value is the same as the case
value. For assumes/branches we know that the condition is true or
false.

Differential Revision: https://reviews.llvm.org/D83640
llvm/include/llvm/Transforms/Utils/PredicateInfo.h
llvm/lib/Transforms/Scalar/NewGVN.cpp
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/lib/Transforms/Utils/PredicateInfo.cpp
llvm/test/Transforms/SCCP/predicateinfo-cond.ll