[llvm] [CodeGen] Use range-based for loops (NFC) (PR #97187)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 30 12:32:29 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/97187
>From 409dd5f7b50adabe33d5fafe7698b65c300256af Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 29 Jun 2024 18:56:47 -0700
Subject: [PATCH 1/2] [CodeGen] Use range-based for loops (NFC)
---
llvm/lib/CodeGen/MachineSSAUpdater.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/CodeGen/MachineSSAUpdater.cpp b/llvm/lib/CodeGen/MachineSSAUpdater.cpp
index 5b21c5653b46b..43c4b9c6c557f 100644
--- a/llvm/lib/CodeGen/MachineSSAUpdater.cpp
+++ b/llvm/lib/CodeGen/MachineSSAUpdater.cpp
@@ -89,8 +89,8 @@ Register LookForIdenticalPHI(MachineBasicBlock *BB,
return Register();
AvailableValsTy AVals;
- for (unsigned i = 0, e = PredValues.size(); i != e; ++i)
- AVals[PredValues[i].first] = PredValues[i].second;
+ for (const auto &[SrcBB, SrcReg] : PredValues)
+ AVals[SrcBB] = SrcReg;
while (I != BB->end() && I->isPHI()) {
bool Same = true;
for (unsigned i = 1, e = I->getNumOperands(); i != e; i += 2) {
@@ -196,8 +196,8 @@ Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB,
InsertNewDef(TargetOpcode::PHI, BB, Loc, RegAttrs, MRI, TII);
// Fill in all the predecessors of the PHI.
- for (unsigned i = 0, e = PredValues.size(); i != e; ++i)
- InsertedPHI.addReg(PredValues[i].second).addMBB(PredValues[i].first);
+ for (const auto &[SrcBB, SrcReg]: PredValues)
+ InsertedPHI.addReg(SrcReg).addMBB(SrcBB);
// See if the PHI node can be merged to a single value. This can happen in
// loop cases when we get a PHI of itself and one other value.
>From e71ce29e4f7cf2b08fd033361016b99096a087a5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 30 Jun 2024 12:32:07 -0700
Subject: [PATCH 2/2] Fix formatting.
---
llvm/lib/CodeGen/MachineSSAUpdater.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/MachineSSAUpdater.cpp b/llvm/lib/CodeGen/MachineSSAUpdater.cpp
index 43c4b9c6c557f..f3e5f4c0384e9 100644
--- a/llvm/lib/CodeGen/MachineSSAUpdater.cpp
+++ b/llvm/lib/CodeGen/MachineSSAUpdater.cpp
@@ -196,7 +196,7 @@ Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB,
InsertNewDef(TargetOpcode::PHI, BB, Loc, RegAttrs, MRI, TII);
// Fill in all the predecessors of the PHI.
- for (const auto &[SrcBB, SrcReg]: PredValues)
+ for (const auto &[SrcBB, SrcReg] : PredValues)
InsertedPHI.addReg(SrcReg).addMBB(SrcBB);
// See if the PHI node can be merged to a single value. This can happen in
More information about the llvm-commits
mailing list