[llvm] r356831 - [LowerSwitch] Use ConstantRange::fromKnownBits(); NFC
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 23 05:48:54 PDT 2019
Author: nikic
Date: Sat Mar 23 05:48:54 2019
New Revision: 356831
URL: http://llvm.org/viewvc/llvm-project?rev=356831&view=rev
Log:
[LowerSwitch] Use ConstantRange::fromKnownBits(); NFC
Using an unsigned range to stay NFC, but a signed range would really
be more useful here.
Modified:
llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp
Modified: llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp?rev=356831&r1=356830&r2=356831&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp Sat Mar 23 05:48:54 2019
@@ -436,14 +436,6 @@ unsigned LowerSwitch::Clusterify(CaseVec
return NumSimpleCases;
}
-static ConstantRange getConstantRangeFromKnownBits(const KnownBits &Known) {
- APInt Lower = Known.One;
- APInt Upper = ~Known.Zero + 1;
- if (Upper == Lower)
- return ConstantRange(Known.getBitWidth(), /*isFullSet=*/true);
- return ConstantRange(Lower, Upper);
-}
-
/// Replace the specified switch instruction with a sequence of chained if-then
/// insts in a balanced binary search.
void LowerSwitch::processSwitchInst(SwitchInst *SI,
@@ -501,7 +493,9 @@ void LowerSwitch::processSwitchInst(Swit
// switch, while LowerSwitch only needs to call LVI once per switch.
const DataLayout &DL = F->getParent()->getDataLayout();
KnownBits Known = computeKnownBits(Val, DL, /*Depth=*/0, AC, SI);
- ConstantRange KnownBitsRange = getConstantRangeFromKnownBits(Known);
+ // TODO Shouldn't this create a signed range?
+ ConstantRange KnownBitsRange =
+ ConstantRange::fromKnownBits(Known, /*ForSigned=*/false);
const ConstantRange LVIRange = LVI->getConstantRange(Val, OrigBlock, SI);
ConstantRange ValRange = KnownBitsRange.intersectWith(LVIRange);
// We delegate removal of unreachable non-default cases to other passes. In
More information about the llvm-commits
mailing list