[PATCH] D12948: [SCEV] Teach SCEV that A < B => (A+1) < (B+1) on no overflow.

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 19:57:39 PDT 2015


majnemer added inline comments.

================
Comment at: lib/Analysis/ScalarEvolution.cpp:7369-7372
@@ +7368,6 @@
+
+  // If we can prove B + 1 does not signed / unsigned overflow, then we can
+  // prove
+  //
+  //  A < B => (A + 1) < (B + 1)
+  //
----------------
Let's say I have the following:
  A = 0x7FFFFFFF
  B = 0x7FFFBC80

In this case, `B+1` does not signed overflow and  `A` is not less than `B`.

However, this results in the following:
  A+1 = 0x80000000
  B+1 = 0x7FFFBC81

Thus the claim is made false, `A+1` is now less than `B+1`.

However, the claim is valid if we can prove that `B+1` does not signed/unsigned overflow *and* `A+1` will not overflow in kind.

I'm no SCEV expert but it seems to me that the code is doing the right thing, is it only the comment that needs adjustment?


http://reviews.llvm.org/D12948





More information about the llvm-commits mailing list