[llvm] IR: introduce ICmpInst::isImpliedByMatchingCmp (PR #122597)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 11 08:31:54 PST 2025
================
@@ -1964,18 +1964,11 @@ NewGVN::ExprResult NewGVN::performSymbolicCmpEvaluation(Instruction *I) const {
if (PBranch->TrueEdge) {
// If we know the previous predicate is true and we are in the true
// edge then we may be implied true or false.
- if (ICmpInst::isImpliedTrueByMatchingCmp(BranchPredicate,
- OurPredicate)) {
- return ExprResult::some(
- createConstantExpression(ConstantInt::getTrue(CI->getType())),
- PI);
- }
-
- if (ICmpInst::isImpliedFalseByMatchingCmp(BranchPredicate,
- OurPredicate)) {
- return ExprResult::some(
- createConstantExpression(ConstantInt::getFalse(CI->getType())),
- PI);
+ if (auto R = ICmpInst::isImpliedByMatchingCmp(BranchPredicate,
+ OurPredicate)) {
+ auto *C = *R ? ConstantInt::getTrue(CI->getType())
+ : ConstantInt::getFalse(CI->getType());
----------------
dtcxzyw wrote:
```suggestion
auto *C = ConstantInt::getBool(CI->getType(), *R);
```
https://github.com/llvm/llvm-project/pull/122597
More information about the llvm-commits
mailing list