[PATCH] D42953: [SCEV] Make getPostIncExpr guaranteed to return AddRec

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 20:51:43 PST 2018


mkazantsev added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:10224
+  // case we cannot guarantee that the value returned will be an AddRec. So we
+  // make it explicitly. Given that the last op of this is non zero, it will
+  // also be non-zero if we add this and Step one by one operand. This does give
----------------
sanjoy wrote:
> I didn't quite understand what you meant by "last op of this is non zero".
When we create an AddRecurrency, if we found out that the last stey was zero we pop it out. For example, if we add `{1,+,1}` and `{2,+,-1}`, we have `{1+2,+,1-1}` where the last element is zero, so it will be removed. It means that whatever the last operand in `this` is, it is NOT a constant zero (otherwise it would have been removed earlier). The fact that the returned value has the same value as its last element guarantees as that the returned value is an AddRec. 


https://reviews.llvm.org/D42953





More information about the llvm-commits mailing list