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

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 23:37:42 PST 2015


sanjoy 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");
+
----------------
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.


http://reviews.llvm.org/D15412





More information about the llvm-commits mailing list