[PATCH] ScalarEvolution incorrectly assumes that the start of certain add recurrences don't overflow
sanjoy at playingwithpointers.com
Fri Feb 6 17:51:48 PST 2015
Comment at: lib/Analysis/ScalarEvolution.cpp:1370
@@ -1369,1 +1369,3 @@
+ // cannot assume the increment of PreStart to not overflow even if PreAR does
+ // not overflow.
> Seems like we could still pick up some trivial cases (loops with only one exit block, only one backedge, etc.). Maybe we could do more with a dominance query?
I think we can prove overflow if the loop has only one exit. Having only one backedge does not give us anything though (the counterexample in this change also has only one backedge).
That said, it is not clear to me how important this optimization is (for instance, removing the optimization does not fail any existing unit tests). I'd like to fix the bug first and check in a correct version of this optimization as a later change. I plan to generalize this part of SCEV to `nuw`s so I'll be touching this area in the future anyway.
More information about the llvm-commits