[llvm] r278009 - [LVI] NFC. On the fast dest path use inverse predicate instead of inverse range result

Artur Pilipenko via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 07:33:12 PDT 2016


Author: apilipenko
Date: Mon Aug  8 09:33:11 2016
New Revision: 278009

URL: http://llvm.org/viewvc/llvm-project?rev=278009&view=rev
Log:
[LVI] NFC. On the fast dest path use inverse predicate instead of inverse range result

Gathering constantins from a condition on the false path ask makeAllowedICmpRegion about inverse predicate instead of inversing the resulting range.

This change was separated from the review "[LVI] Make LVI smarter about comparisons with non-constants" (https://reviews.llvm.org/D23205#inline-198361)

Modified:
    llvm/trunk/lib/Analysis/LazyValueInfo.cpp

Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=278009&r1=278008&r2=278009&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Mon Aug  8 09:33:11 2016
@@ -1208,15 +1208,16 @@ bool getValueFromCondition(Value *Val, V
     if (CI && (LHS == Val || Offset)) {
       // Calculate the range of values that are allowed by the comparison
       ConstantRange CmpRange(CI->getValue());
+
+      // If we're interested in the false dest, invert the condition
+      CmpInst::Predicate Pred =
+          isTrueDest ? Predicate : CmpInst::getInversePredicate(Predicate);
       ConstantRange TrueValues =
-          ConstantRange::makeAllowedICmpRegion(Predicate, CmpRange);
+          ConstantRange::makeAllowedICmpRegion(Pred, CmpRange);
 
       if (Offset) // Apply the offset from above.
         TrueValues = TrueValues.subtract(Offset->getValue());
 
-      // If we're interested in the false dest, invert the condition.
-      if (!isTrueDest) TrueValues = TrueValues.inverse();
-
       Result = LVILatticeVal::getRange(std::move(TrueValues));
       return true;
     }




More information about the llvm-commits mailing list