For PR950:
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31063 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index 12a32f1..724499d 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -60,11 +60,12 @@
struct CaseCmp {
bool operator () (const LowerSwitch::Case& C1,
const LowerSwitch::Case& C2) {
- if (const ConstantUInt* U1 = dyn_cast<const ConstantUInt>(C1.first))
- return U1->getValue() < cast<const ConstantUInt>(C2.first)->getValue();
- const ConstantSInt* S1 = dyn_cast<const ConstantSInt>(C1.first);
- return S1->getValue() < cast<const ConstantSInt>(C2.first)->getValue();
+ const ConstantInt* CI1 = cast<const ConstantInt>(C1.first);
+ const ConstantInt* CI2 = cast<const ConstantInt>(C2.first);
+ if (CI1->getType()->isUnsigned())
+ return CI1->getZExtValue() < CI2->getZExtValue();
+ return CI1->getSExtValue() < CI2->getSExtValue();
}
};
@@ -129,7 +130,7 @@
Case& Pivot = *(Begin + Mid);
DEBUG(std::cerr << "Pivot ==> "
- << (int64_t)cast<ConstantInt>(Pivot.first)->getRawValue()
+ << cast<ConstantInt>(Pivot.first)->getSExtValue()
<< "\n");
BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,