[PATCH] D87034: [KnownBits] Implement accurate unsigned and signed max and min
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 11:45:58 PDT 2020
nikic added inline comments.
================
Comment at: llvm/lib/Support/KnownBits.cpp:113
+ LHSgeRHS.setLowBits(BitWidth - LHSgtRHS.countLeadingZeros());
+ if (LHSgeRHS.isAllOnesValue()) {
+ Res.Zero |= LHS.Zero;
----------------
nikic wrote:
> How does this differ from `LHS.getMinValue().uge(RHS.getMaxValue())`?
Generally I think this code should be structured something like this:
```
if (LHS.getMinValue().uge(RHS.getMaxValue()))
return LHS;
if (RHS.getMinValue().uge(LHS.getMaxValue()))
return RHS;
// If the result of the umax is LHS then it must be greater than or equal to
// the minimum possible value of RHS. Likewise for RHS. Any known bits that
// are common to these two values are also known in the result.
KnownBits L = LHS.makeGE(RHS.getMinValue());
KnownBits R = RHS.makeGE(LHS.getMinValue());
return KnownBits(L.Zero & R.Zero, L.One & R.One);
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87034/new/
https://reviews.llvm.org/D87034
More information about the llvm-commits
mailing list