[LowerSwitch] Use ConstantRange::fromKnownBits(); NFC
Using an unsigned range to stay NFC, but a signed range would really
be more useful here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356831 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index 08db63e..3c973e7 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -436,14 +436,6 @@
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 @@
// 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