summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-12-12 15:52:56 +0000
committerSanjay Patel <spatel@rotateright.com>2016-12-12 15:52:56 +0000
commit87e2f677d76e14797dab74378843e3d1377c4ef2 (patch)
tree74523b66ba95129cfc15a426478eda01e437f388 /llvm/lib/Transforms
parentd4ff86b973f1115cfabefbb1bdfb17b3909ba650 (diff)
downloadbcm5719-llvm-87e2f677d76e14797dab74378843e3d1377c4ef2.tar.gz
bcm5719-llvm-87e2f677d76e14797dab74378843e3d1377c4ef2.zip
[InstCombine] clean up range-for-loops in visitSwitchInst(); NFCI
llvm-svn: 289439
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 90eba686966..f96766db6df 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2260,18 +2260,18 @@ Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) {
Value *NewCond = Builder->CreateTrunc(Cond, Ty, "trunc");
SI.setCondition(NewCond);
- for (auto &C : SI.cases())
- static_cast<SwitchInst::CaseIt *>(&C)->setValue(ConstantInt::get(
- SI.getContext(), C.getCaseValue()->getValue().trunc(NewWidth)));
+ for (SwitchInst::CaseIt CaseIter : SI.cases()) {
+ APInt TruncatedCase = CaseIter.getCaseValue()->getValue().trunc(NewWidth);
+ CaseIter.setValue(ConstantInt::get(SI.getContext(), TruncatedCase));
+ }
}
Value *Op0 = nullptr;
ConstantInt *AddRHS = nullptr;
if (match(Cond, m_Add(m_Value(Op0), m_ConstantInt(AddRHS)))) {
// Change 'switch (X+4) case 1:' into 'switch (X) case -3'.
- for (SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e;
- ++i) {
- ConstantInt *CaseVal = i.getCaseValue();
+ for (SwitchInst::CaseIt CaseIter : SI.cases()) {
+ ConstantInt *CaseVal = CaseIter.getCaseValue();
Constant *LHS = CaseVal;
if (TruncCond) {
LHS = LeadingKnownZeros
@@ -2281,7 +2281,7 @@ Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) {
Constant *NewCaseVal = ConstantExpr::getSub(LHS, AddRHS);
assert(isa<ConstantInt>(NewCaseVal) &&
"Result of expression should be constant");
- i.setValue(cast<ConstantInt>(NewCaseVal));
+ CaseIter.setValue(cast<ConstantInt>(NewCaseVal));
}
SI.setCondition(Op0);
if (auto *CondI = dyn_cast<Instruction>(Cond))
OpenPOWER on IntegriCloud