aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/Local.cpp4
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp6
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 179f29cdaf..130b876ee9 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -171,8 +171,10 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions) {
SwitchInst::CaseIt FirstCase = SI->case_begin();
ConstantRangesSet CRS = FirstCase.getCaseValueEx();
if (CRS.getNumItems() == 1 && CRS.isSingleNumber(0)) {
+ // FIXME: Currently work with ConstantInt based numbers.
Value *Cond = Builder.CreateICmpEQ(SI->getCondition(),
- CRS.getItem(0).Low, "cond");
+ CRS.getItem(0).Low.toConstantInt(),
+ "cond");
// Insert the new branch.
Builder.CreateCondBr(Cond, FirstCase.getCaseSuccessor(),
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index fa5a9340f4..23620373a0 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -239,7 +239,11 @@ unsigned LowerSwitch::Clusterify(CaseVector& Cases, SwitchInst *SI) {
for (CRSBuilder::RangeIterator i = TheClusterifier.begin(),
e = TheClusterifier.end(); i != e; ++i, ++numCmps) {
CRSBuilder::Cluster &C = *i;
- Cases.push_back(CaseRange(C.first.Low, C.first.High, C.second));
+
+ // FIXME: Currently work with ConstantInt based numbers.
+ // Changing it to APInt based is a pretty heavy for this commit.
+ Cases.push_back(CaseRange(C.first.Low.toConstantInt(),
+ C.first.High.toConstantInt(), C.second));
if (C.first.Low != C.first.High)
// A range counts double, since it requires two compares.
++numCmps;