[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
Wed Feb 3 05:18:37 PST 2016

sbaranga added inline comments.

Comment at: lib/Analysis/LoopAccessAnalysis.cpp:812
@@ -811,3 +811,3 @@
         isa<ConstantInt>(OBO->getOperand(1))) {
-      auto *OpScev = SE->getSCEV(OBO->getOperand(0));
I think that's already covered by the current change, because isStridedPtr will add the predicates if needed (and I think this is only called from isStridedPtr).

This should be better because isStridedPtr might return true even if isNoWrapAddRec returns false (for example in the case of unit strided pointers), and we try to only add predicates when needed.

If we ever end up calling isNoWrapAddRec from somewhere else than isStridedPtr, it would be a good idea to allow coercing here as well.

Comment at: lib/Analysis/LoopAccessAnalysis.cpp:913-916
@@ +912,6 @@
+      Stride != 1 && Stride != -1) {
+    if (Assume) {
+      // We can avoid this case by adding a run-time check.
+      DEBUG(dbgs() << "LAA: Non unit strided pointer which is not either "
+                   << "inbouds  or in address space 0 may wrap: " << *Ptr
+                   << " SCEV: " << *PtrScev
Thanks, I intended to add the debug message here as well.

Comment at: test/Analysis/LoopAccessAnalysis/wrapping-pointer-versioning.ll:27-28
@@ +26,4 @@
+; LAA-NEXT: {0,+,2}<%for.body> Added Flags: <nusw>
+; LAA-NEXT: {%a,+,4}<%for.body> Added Flags: <nusw>
+; The expression for %mul_ext as analyzed by SCEV is
Added text with the SCEV expressions for %mul_ext before and after the predicates for all tests.


More information about the llvm-commits mailing list