[PATCH] D18867: [IndVarSimplify] Eliminate zext of a signed IV when the IV is known to be non-negative

Li Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 09:31:55 PDT 2016

lihuang added a comment.

I looked at the threads on llvm-dev discussing the no-wrap flag propagation issues. It seems like this has been a problem for a while and there is not a clear agreement on when and how to propagate no-wrap flags from instructions to corresponding SCEVs.

The problem in this case could be easily solved by propagating "nsw" flag of "%add = add nsw i32 %i.0, 2" to it's SCEV. It's not possible to infer the "nsw" flag for this SCEV. As %i.0 has range [0,-2147483648), "%i.0 + 2" could cause signed-overflow.

Sanjoy, I see you are actively contributing to SCEV. Do you know the community's plan on strengthening the no-wrap flag propagation? The tests I added here might not serve as a very good motivation for the effort but I think this will generally benefit SCEV and some optimizations depending on SCEV.



More information about the llvm-commits mailing list