[PATCH] D37209: [LSR] Fix Shadow IV in case of integer overflow

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 09:31:10 PDT 2017


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


================
Comment at: lib/Transforms/Scalar/LoopStrengthReduce.cpp:2034
+    const SCEVAddRecExpr *PS = dyn_cast<SCEVAddRecExpr>(SE.getSCEV(PH));
+    if (!PS || !PS->hasNoSelfWrap()) continue;
+
----------------
I don't think this is the correct check.  Specifically, this check allows overflow as long as we can guarantee that the value never reaches it's starting value.  I think you actually want hasNoUnsignedWrap() && hasNoSignedWrap()

Consider:
unsigned i = 1
do {
  i += INT_MAX; 
  d += i;
} while ( (signed int)i > 0)


================
Comment at: test/Transforms/LoopStrengthReduce/dont_turn_int_overflow_to_fp.ll:10
+
+define i32 @test_01() {
+; CHECK-LABEL:  test_01(
----------------
Can't you greatly reduce this example?

Doesn't a simple sum of squares in the 32 bit domain trigger this?


https://reviews.llvm.org/D37209





More information about the llvm-commits mailing list