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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 11:52:21 PST 2019


lebedev.ri added inline comments.


================
Comment at: llvm/trunk/lib/IR/ConstantRange.cpp:834-856
+    bool Overflow;
+    APInt NewMin = LMin.uadd_ov(RMin, Overflow);
+    if (Overflow)
+      return getEmpty();
+    APInt NewMax = LMax.uadd_sat(RMax);
+    return getNonEmpty(std::move(NewMin), std::move(NewMax) + 1);
+  };
----------------
@nikic @shchenz
So i'm trying to look into `sub` variant, and i'm missing a subtlety here.

In `addWithNoSignedWrap()` why those overflow checks are needed?
All tests pass without them.

In `addWithNoUnsignedWrap()` why is that overflow check needed?
All tests pass without it (with it replaced with `uadd_sat`)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67339





More information about the llvm-commits mailing list