[llvm] dfa13c0 - [CodeGen] Use a range-based for loop (NFC) (#104408)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 17:58:34 PDT 2024


Author: Kazu Hirata
Date: 2024-08-15T17:58:31-07:00
New Revision: dfa13c010ff10b7bbbbf71c648de1b06ce58e34e

URL: https://github.com/llvm/llvm-project/commit/dfa13c010ff10b7bbbbf71c648de1b06ce58e34e
DIFF: https://github.com/llvm/llvm-project/commit/dfa13c010ff10b7bbbbf71c648de1b06ce58e34e.diff

LOG: [CodeGen] Use a range-based for loop (NFC) (#104408)

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 1fb37fb8406ef4..ec5b7579c66c26 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -7382,12 +7382,9 @@ bool CodeGenPrepare::tryToSinkFreeOperands(Instruction *I) {
     if (IsHugeFunc) {
       // Now we clone an instruction, its operands' defs may sink to this BB
       // now. So we put the operands defs' BBs into FreshBBs to do optimization.
-      for (unsigned I = 0; I < NI->getNumOperands(); ++I) {
-        auto *OpDef = dyn_cast<Instruction>(NI->getOperand(I));
-        if (!OpDef)
-          continue;
-        FreshBBs.insert(OpDef->getParent());
-      }
+      for (Value *Op : NI->operands())
+        if (auto *OpDef = dyn_cast<Instruction>(Op))
+          FreshBBs.insert(OpDef->getParent());
     }
 
     NewInstructions[UI] = NI;


        


More information about the llvm-commits mailing list