[PATCH] D19266: [SCEV] Improve the run-time checking of the NoWrap predicate

silviu.baranga@arm.com via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 02:55:36 PDT 2016


sbaranga added inline comments.

================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:2038
@@ +2037,3 @@
+  Value *StepCompare =
+      Builder.CreateICmp(ICmpInst::ICMP_SLT, StepValue, NegStepValue);
+  Value *AbsStep = Builder.CreateSelect(StepCompare, NegStepValue, StepValue);
----------------
sanjoy wrote:
> Why not just check if `Step < 0`?  (Assuming later passes don't optimize this) That way we won't have compute `-Step` if `Step` is positive.
Sure, that makes sense.

================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:2084
@@ +2083,3 @@
+
+  EndCheck = Builder.CreateAnd(
+      EndCheck, Builder.CreateICmp(ICmpInst::ICMP_NE, StepValue, Zero));
----------------
sanjoy wrote:
> Why do you need this extra check?  If `Step` is `0` then won't both the less than and the greater than check return false?
The problem is that we have an edge case where we discard bits by truncating the backedge taken count and the step is 0. In this case we don't have overflow. It would be better to create it only when we need to truncate the backedge taken count and create the and with the 'BackedgeCount < MAX_UINT(Type(Start))' comparison. 



http://reviews.llvm.org/D19266





More information about the llvm-commits mailing list