[llvm] r298680 - [InstCombine] Use range-based for loop. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 19:58:02 PDT 2017


Author: ctopper
Date: Thu Mar 23 21:58:02 2017
New Revision: 298680

URL: http://llvm.org/viewvc/llvm-project?rev=298680&view=rev
Log:
[InstCombine] Use range-based for loop. NFC

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=298680&r1=298679&r2=298680&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Thu Mar 23 21:58:02 2017
@@ -3019,12 +3019,11 @@ static bool AddReachableCodeToWorklist(B
         }
 
       // 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<ConstantVector>(i) && !isa<ConstantExpr>(i))
+      for (Use &U : Inst->operands()) {
+        if (!isa<ConstantVector>(U) && !isa<ConstantExpr>(U))
           continue;
 
-        auto *C = cast<Constant>(i);
+        auto *C = cast<Constant>(U);
         Constant *&FoldRes = FoldedConstants[C];
         if (!FoldRes)
           FoldRes = ConstantFoldConstant(C, DL, TLI);
@@ -3035,7 +3034,7 @@ static bool AddReachableCodeToWorklist(B
           DEBUG(dbgs() << "IC: ConstFold operand of: " << *Inst
                        << "\n    Old = " << *C
                        << "\n    New = " << *FoldRes << '\n');
-          *i = FoldRes;
+          U = FoldRes;
           MadeIRChange = true;
         }
       }




More information about the llvm-commits mailing list