[PATCH] D104634: [SCEV] Generalize MatchBinaryAddToConst to support non-add expressions.

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 21 06:02:02 PDT 2021


mkazantsev requested changes to this revision.
mkazantsev added a comment.
This revision now requires changes to proceed.

I think this is wrong.



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:10106
   case ICmpInst::ICMP_SLE:
-    // X s<= (X + C)<nsw> if C >= 0
-    if (MatchBinaryAddToConst(RHS, LHS, C, SCEV::FlagNSW) && C.isNonNegative())
+    // (X + C1)<nsw> s<= (X + C2) if C1 s<= C2.
+    if (MatchBinaryAddToConst(LHS, RHS, C1, C2, SCEV::FlagNSW) && C1.sle(C2))
----------------
Is lack of `nsw` in `(X + C2)` intentional? If yes, the counter-example to this is

```
X = SINT_MIN
C1 = 1
C2 = -1
```
`(X + C1)<nsw> = SINT_MIN + 1 <= (X - 1) = SINT_MAX`, but obviously `C1 > C2`.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104634



More information about the llvm-commits mailing list