[PATCH] D44515: [IRCE] Change min value safety check

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 20 04:48:55 PDT 2018


mkazantsev added inline comments.


================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:698
+  auto Predicate = Signed ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
+  return SE.isLoopBackedgeGuardedByCond(L, Predicate, BoundSCEV, Limit);
 }
----------------
mkazantsev wrote:
> samparker wrote:
> > mkazantsev wrote:
> > > It is also potentially incorrect. You need to check this condition not on loop backedge but on loop entry. Otherwise it can be in theory wrong on 1st iteration. It is checked with `isLoopEntryGuardedByCond`.
> > I think this is already handled on line 943.
> Likewise, if you rely on something from outside your function then you should add an assert on it. If this function goes to utils and someone reuses it, it can be not obvious for them.
> 
And clearly, I don't see why you should check guard on backedge and not on entry. Any arguments in favour of that?


https://reviews.llvm.org/D44515





More information about the llvm-commits mailing list