From 36f2e0eee834fca853e6e0df6b4fa76b06c0f329 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 24 Mar 2017 02:58:02 +0000 Subject: [PATCH] [InstCombine] Use range-based for loop. NFC llvm-svn: 298680 --- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 2241863..9cd22f6 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3019,12 +3019,11 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB, const DataLayout &DL, } // See if we can constant fold its operands. - for (User::op_iterator i = Inst->op_begin(), e = Inst->op_end(); i != e; - ++i) { - if (!isa(i) && !isa(i)) + for (Use &U : Inst->operands()) { + if (!isa(U) && !isa(U)) continue; - auto *C = cast(i); + auto *C = cast(U); Constant *&FoldRes = FoldedConstants[C]; if (!FoldRes) FoldRes = ConstantFoldConstant(C, DL, TLI); @@ -3035,7 +3034,7 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB, const DataLayout &DL, DEBUG(dbgs() << "IC: ConstFold operand of: " << *Inst << "\n Old = " << *C << "\n New = " << *FoldRes << '\n'); - *i = FoldRes; + U = FoldRes; MadeIRChange = true; } } -- 2.7.4