diff options
author | Alexander Shaposhnikov <ashaposhnikov@google.com> | 2022-05-20 18:39:21 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <ashaposhnikov@google.com> | 2022-05-20 18:39:58 +0000 |
commit | 9398caf399ae04d3f331c7d766ee9884f794d4f2 (patch) | |
tree | 533833a481bf0f8a1685011f1cdba4bb392504dd /llvm/lib/IR/ConstantRange.cpp | |
parent | 9385a6d6eaa3f4caebdee2eb53b5bf4ca1f1b832 (diff) | |
download | llvm-9398caf399ae04d3f331c7d766ee9884f794d4f2.zip llvm-9398caf399ae04d3f331c7d766ee9884f794d4f2.tar.gz llvm-9398caf399ae04d3f331c7d766ee9884f794d4f2.tar.bz2 |
Recommit "[ConstantRange] Improve the implementation of binaryOr"
This recommits https://reviews.llvm.org/rG6990e7477d24ff585ae86549f5280f0be65422a6
as the problematic test has been updated updated in
https://reviews.llvm.org/rG3bd112c720dc614a59e3f34ebf9b45075037bfa0.
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index c3915ce..be6386c 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -1410,14 +1410,13 @@ ConstantRange ConstantRange::binaryOr(const ConstantRange &Other) const { if (isEmptySet() || Other.isEmptySet()) return getEmpty(); - // Use APInt's implementation of OR for single element ranges. - if (isSingleElement() && Other.isSingleElement()) - return {*getSingleElement() | *Other.getSingleElement()}; - - // TODO: replace this with something less conservative - - APInt umax = APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin()); - return getNonEmpty(std::move(umax), APInt::getZero(getBitWidth())); + ConstantRange KnownBitsRange = + fromKnownBits(toKnownBits() | Other.toKnownBits(), false); + // Upper wrapped range. + ConstantRange UMaxUMinRange = + getNonEmpty(APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin()), + APInt::getZero(getBitWidth())); + return KnownBitsRange.intersectWith(UMaxUMinRange); } ConstantRange ConstantRange::binaryXor(const ConstantRange &Other) const { |