[PATCH] [LAA] Try to prove non-wrapping of pointers if SCEV cannot

Sanjoy Das sanjoy at playingwithpointers.com
Mon Jun 15 23:07:16 PDT 2015

Comment at: lib/Analysis/LoopAccessAnalysis.cpp:509
@@ +508,3 @@
+/// i.e. monotonically increasing/decreasing.
+static bool isNoWrapAddRec(Value *Ptr, const SCEVAddRecExpr *AR,
+                           ScalarEvolution *SE, const Loop *L) {
I'm not clear on how LAA uses this property, but I think this function should mention what kind of no-wrap (signed or unsigned) behavior it is trying to prove.  IOW, Ptr is supposed to be  monotonically increasing/decreasing in the signed or unsigned sense?

Comment at: lib/Analysis/LoopAccessAnalysis.cpp:540
@@ +539,3 @@
+  // using a non-wrapping operation.
+  if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(NonConstIndex))
+    if ((OBO->hasNoUnsignedWrap() || OBO->hasNoSignedWrap()) &&
What if `OBO` is `nuw` (and not `nsw`) and `OpAR` is `nsw` (and not `nuw`)?  Or vice-versa?



More information about the llvm-commits mailing list