[llvm] 1067a13 - [NFC] Use evaluatePredicate in eliminateComparison
    Max Kazantsev via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Mar 18 05:21:44 PDT 2021
    
    
  
Author: Max Kazantsev
Date: 2021-03-18T19:21:29+07:00
New Revision: 1067a13cc11fb7e02b337bc669426bcd5958e86b
URL: https://github.com/llvm/llvm-project/commit/1067a13cc11fb7e02b337bc669426bcd5958e86b
DIFF: https://github.com/llvm/llvm-project/commit/1067a13cc11fb7e02b337bc669426bcd5958e86b.diff
LOG: [NFC] Use evaluatePredicate in eliminateComparison
Just makes code simpler.
Added: 
    
Modified: 
    llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
Removed: 
    
################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 290c04a7ad10..d0c43bb26105 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -263,12 +263,8 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) {
 
   // If the condition is always true or always false, replace it with
   // a constant value.
-  if (SE->isKnownPredicate(Pred, S, X)) {
-    ICmp->replaceAllUsesWith(ConstantInt::getTrue(ICmp->getContext()));
-    DeadInsts.emplace_back(ICmp);
-    LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');
-  } else if (SE->isKnownPredicate(ICmpInst::getInversePredicate(Pred), S, X)) {
-    ICmp->replaceAllUsesWith(ConstantInt::getFalse(ICmp->getContext()));
+  if (auto Ev = SE->evaluatePredicate(Pred, S, X)) {
+    ICmp->replaceAllUsesWith(ConstantInt::getBool(ICmp->getContext(), *Ev));
     DeadInsts.emplace_back(ICmp);
     LLVM_DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');
   } else if (makeIVComparisonInvariant(ICmp, IVOperand)) {
        
    
    
More information about the llvm-commits
mailing list