[PATCH] D15412: [SCEV][LAA] Add no overflow SCEV predicates and use use them to improve strided pointer detection

silviu.baranga@arm.com via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 11 06:16:01 PST 2015


sbaranga added inline comments.

================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:2059
@@ +2058,3 @@
+  Value *OfAdd = OFBuilder.CreateExtractValue(Add, 1, "add.overflow");
+  Value *Overflow = OFBuilder.CreateOr(OfMul, OfAdd, "overflow");
+
----------------
sanjoy wrote:
> Actually, now that I think of it, I don't think this scheme will work for `nsw`.  E.g. if `AR` is `i8 {0,+,1}` and `TripCount` is `i8 255` == `i8 -1` then neither `(i8 1) * (i8 255)` == `i8 -1` nor `0 + (-1)` will sign overflow, while the add recurrence clearly does sign overflow.
> 
> I think the most obvious way to check for no `nsw` is to check `sext(Start + TripCount * Step)` == `sext(Start) + zext(TripCount) * sext(Step)`, where you extend to 2 * Bitwidth(Start).  There could also potentially be a more efficient scheme, but I don't have one with me right now.
Thanks for the catch! This is indeed a problem. I'll think about some more alternatives to this.


http://reviews.llvm.org/D15412





More information about the llvm-commits mailing list