[PATCH] D41576: [SCEV] Be careful with nuw/nsw in InsertBinop

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 26 13:23:25 PST 2017


sanjoy requested changes to this revision.
sanjoy added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:198
       if (IP->getOpcode() == (unsigned)Opcode && IP->getOperand(0) == LHS &&
-          IP->getOperand(1) == RHS)
+          IP->getOperand(1) == RHS && !hasNoWrap(&*IP))
         return &*IP;
----------------
Good catch!

I think you also need to check for `I` having the `exact` bit set since it looks like `InsertBinop` is used for shifts and divisions as well.

Finally, please also add a TODO that we can be more aggressive here by piping in the flags for the SCEV expression whose expansion we want to insert (nsw/nuw/exact).


https://reviews.llvm.org/D41576





More information about the llvm-commits mailing list