[llvm] e99eb89 - [SimplifyCFG] Use range-based for loops (NFC) (#107180)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 01:29:16 PDT 2024


Author: Kazu Hirata
Date: 2024-09-04T01:29:13-07:00
New Revision: e99eb89d5d97efc709f18f9369f2ec087352baaa

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

LOG: [SimplifyCFG] Use range-based for loops (NFC) (#107180)

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 15de40c7b09962..f9db996cdc3583 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1000,20 +1000,20 @@ bool SimplifyCFGOpt::simplifyEqualityComparisonWithOnlyPredecessor(
   // which value (or set of values) this is.
   ConstantInt *TIV = nullptr;
   BasicBlock *TIBB = TI->getParent();
-  for (unsigned i = 0, e = PredCases.size(); i != e; ++i)
-    if (PredCases[i].Dest == TIBB) {
+  for (const auto &[Value, Dest] : PredCases)
+    if (Dest == TIBB) {
       if (TIV)
         return false; // Cannot handle multiple values coming to this block.
-      TIV = PredCases[i].Value;
+      TIV = Value;
     }
   assert(TIV && "No edge from pred to succ?");
 
   // Okay, we found the one constant that our value can be if we get into TI's
   // BB.  Find out which successor will unconditionally be branched to.
   BasicBlock *TheRealDest = nullptr;
-  for (unsigned i = 0, e = ThisCases.size(); i != e; ++i)
-    if (ThisCases[i].Value == TIV) {
-      TheRealDest = ThisCases[i].Dest;
+  for (const auto &[Value, Dest] : ThisCases)
+    if (Value == TIV) {
+      TheRealDest = Dest;
       break;
     }
 


        


More information about the llvm-commits mailing list