[PATCH] D44776: [IRCE] Enable decreasing loops of variable bounds

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 26 03:37:21 PDT 2018


samparker added inline comments.


================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:716
+  if (Pred != ICmpInst::ICMP_SLT && Pred != ICmpInst::ICMP_SGT &&
+      Pred != ICmpInst::ICMP_ULT && Pred != ICmpInst::ICMP_UGT)
+    return false;
----------------
mkazantsev wrote:
> Just a general observation (this problem seems to exist in old code as well): if the predicate is unsigned, the loop cannot be decreasing. In unsigned, all values are seen as non-negative. So this logic makes no sense. Could you please check that we only come here with signed predicates? If so, please add an assert on that.
But if we know that the limit is a non negative, why couldn't an unsigned comparison be used? test_02 in decrementing-loop.ll does just this. If sub can legally handle unsigned values, I can't see why we wouldn't be able to use unsigned compares in this case.


https://reviews.llvm.org/D44776





More information about the llvm-commits mailing list