diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-10-20 07:07:24 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-10-20 07:07:24 +0000 |
commit | b83eb6447ba155342598f0fabe1f08f5baa9164a (patch) | |
tree | a5822f5fdac89033b7b16ba8e5aaf1ae10833b1c /lib/Transforms/Utils/LowerSwitch.cpp | |
parent | 6e7dd9db6bf677c9161a6ecc12f90651cf1231e0 (diff) |
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
Diffstat (limited to 'lib/Transforms/Utils/LowerSwitch.cpp')
-rw-r--r-- | lib/Transforms/Utils/LowerSwitch.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index 12a32f19cb..724499d1ba 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -60,11 +60,12 @@ namespace { 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 @@ BasicBlock* LowerSwitch::switchConvert(CaseItr Begin, CaseItr End, 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, |