[PATCH] D61934: [SCEV] Add wrap flags while expanding Add

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 2 12:21:53 PDT 2019


jdoerfert added inline comments.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:753
 
+  // Add wrapping flags.
+  if (isa<OverflowingBinaryOperator>(Sum) && !isa<ConstantExpr>(Sum)) {
----------------
Why is this happening only at the end? A SCEVAdd `<nsw>`(a+b+c) should have two `<nsw>` additions, right? Should we have the following code as a helper routine that is called after a new `Sum` was created?

I just realized, maybe my interpretation of SCEVAdd `<nsw>`(a+b+c) is wrong. Does it mean there is no intermediate overflow? In that case, the above might be what we want. If that is not the case, what does it mean?


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:754
+  // Add wrapping flags.
+  if (isa<OverflowingBinaryOperator>(Sum) && !isa<ConstantExpr>(Sum)) {
+    auto *I = cast<Instruction>(Sum);
----------------
This makes implicit assumptions about the hierarchy. Could you (also) check `isa<Instruction>`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61934/new/

https://reviews.llvm.org/D61934





More information about the llvm-commits mailing list