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

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 26 22:31:12 PDT 2018


mkazantsev accepted this revision.
mkazantsev added a comment.
This revision is now accepted and ready to land.

LGTM



================
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;
----------------
samparker wrote:
> 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.
Ok, it makes sense (yet at the first glance this confused me slightly :) ). We can always legally replace sgt with ugt if we prove non-negativity of both, so I'm fine with that.


https://reviews.llvm.org/D44776





More information about the llvm-commits mailing list