[PATCH] D36873: [IRCE] Fix buggy behavior in Clamp

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 06:25:44 PDT 2017


mkazantsev added inline comments.


================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:1088
   auto Clamp = [this, Smallest, Greatest, IsSignedPredicate](const SCEV *S) {
-    return IsSignedPredicate
+    bool MaybeNegativeValues = IsSignedPredicate || !SE.isKnownNonNegative(S);
+    return MaybeNegativeValues
----------------
anna wrote:
> I think there is just one missed case of checking `isKnownNonNegative` right? 
> 
> Just looked through IRCE code and we correctly check it for choosing the right predicate: `ULT` or `SLT`. 
Yes, for other values we know that they are non-negative because they are start and final values of the IV which is checked by unsigned condition. For `S`, we didn't check it.


https://reviews.llvm.org/D36873





More information about the llvm-commits mailing list