[PATCH] D67339: [ConstantRange] add helper function addWithNoWrap

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 04:03:59 PDT 2019


nikic added inline comments.


================
Comment at: llvm/unittests/IR/ConstantRangeTest.cpp:701
+            RangeAlwaysOverflowLow &= false;
+        }
+      });
----------------
The logic here seems unnecessary complicated to me. Couldn't we do something like this?

```
bool IsOverflow = false;
APInt N = IntFn(IsOverflow, N1, N2);
if (!IsOverflow) {
    if (N.sle(Min))
        Min = N;
    if (N.sge(Max))
        Max = N;
}
```

here, and use just `sadd_ov()` (without `sadd_sat`) in IntFn? The empty set case can be checked as `if (Min.sgt(Max)) EXPECT_TRUE(CR.isEmptySet());` I believe.


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

https://reviews.llvm.org/D67339





More information about the llvm-commits mailing list