summaryrefslogtreecommitdiff
path: root/lib/Target/SystemZ/SystemZElimCompare.cpp
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>2014-03-06 11:00:15 +0000
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>2014-03-06 11:00:15 +0000
commitb653ed85457de149bb42c22a8098e6b2f2685dd4 (patch)
tree208144e92af1f27346a85e623bba88c4e9ae45d7 /lib/Target/SystemZ/SystemZElimCompare.cpp
parent9a1cd05a3d7456f9cdd9f5f30f037fbeb3c0fb20 (diff)
downloadllvm-b653ed85457de149bb42c22a8098e6b2f2685dd4.tar.gz
llvm-b653ed85457de149bb42c22a8098e6b2f2685dd4.tar.bz2
llvm-b653ed85457de149bb42c22a8098e6b2f2685dd4.tar.xz
[SystemZ] Use "for (auto" a bit
Just the simple cases for now. There were a few knock-on changes of MachineBasicBlock *s to MachineBasicBlock &s. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SystemZ/SystemZElimCompare.cpp')
-rw-r--r--lib/Target/SystemZ/SystemZElimCompare.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/Target/SystemZ/SystemZElimCompare.cpp b/lib/Target/SystemZ/SystemZElimCompare.cpp
index b161c0af84..6cee9c24a0 100644
--- a/lib/Target/SystemZ/SystemZElimCompare.cpp
+++ b/lib/Target/SystemZ/SystemZElimCompare.cpp
@@ -70,7 +70,7 @@ public:
return "SystemZ Comparison Elimination";
}
- bool processBlock(MachineBasicBlock *MBB);
+ bool processBlock(MachineBasicBlock &MBB);
bool runOnMachineFunction(MachineFunction &F);
private:
@@ -97,9 +97,8 @@ FunctionPass *llvm::createSystemZElimComparePass(SystemZTargetMachine &TM) {
}
// Return true if CC is live out of MBB.
-static bool isCCLiveOut(MachineBasicBlock *MBB) {
- for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
- SE = MBB->succ_end(); SI != SE; ++SI)
+static bool isCCLiveOut(MachineBasicBlock &MBB) {
+ for (auto SI = MBB.succ_begin(), SE = MBB.succ_end(); SI != SE; ++SI)
if ((*SI)->isLiveIn(SystemZ::CC))
return true;
return false;
@@ -328,8 +327,8 @@ optimizeCompareZero(MachineInstr *Compare,
// Search back for CC results that are based on the first operand.
unsigned SrcReg = Compare->getOperand(0).getReg();
unsigned SrcSubReg = Compare->getOperand(0).getSubReg();
- MachineBasicBlock *MBB = Compare->getParent();
- MachineBasicBlock::iterator MBBI = Compare, MBBE = MBB->begin();
+ MachineBasicBlock &MBB = *Compare->getParent();
+ MachineBasicBlock::iterator MBBI = Compare, MBBE = MBB.begin();
Reference CCRefs;
Reference SrcRefs;
while (MBBI != MBBE) {
@@ -424,7 +423,7 @@ fuseCompareAndBranch(MachineInstr *Compare,
// Process all comparison instructions in MBB. Return true if something
// changed.
-bool SystemZElimCompare::processBlock(MachineBasicBlock *MBB) {
+bool SystemZElimCompare::processBlock(MachineBasicBlock &MBB) {
bool Changed = false;
// Walk backwards through the block looking for comparisons, recording
@@ -432,8 +431,8 @@ bool SystemZElimCompare::processBlock(MachineBasicBlock *MBB) {
// instructions before it.
bool CompleteCCUsers = !isCCLiveOut(MBB);
SmallVector<MachineInstr *, 4> CCUsers;
- MachineBasicBlock::iterator MBBI = MBB->end();
- while (MBBI != MBB->begin()) {
+ MachineBasicBlock::iterator MBBI = MBB.end();
+ while (MBBI != MBB.begin()) {
MachineInstr *MI = --MBBI;
if (CompleteCCUsers &&
MI->isCompare() &&
@@ -463,9 +462,8 @@ bool SystemZElimCompare::runOnMachineFunction(MachineFunction &F) {
TRI = &TII->getRegisterInfo();
bool Changed = false;
- for (MachineFunction::iterator MFI = F.begin(), MFE = F.end();
- MFI != MFE; ++MFI)
- Changed |= processBlock(MFI);
+ for (auto &MBB : F)
+ Changed |= processBlock(MBB);
return Changed;
}