summaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCInstrInfo.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2013-05-07 17:49:55 +0000
committerHal Finkel <hfinkel@anl.gov>2013-05-07 17:49:55 +0000
commit8a88cadaedcfa3bb020df1d100d67cecaf638f35 (patch)
treea1c3b07fe23155b152799ce45a4d8943bcc2ffe5 /lib/Target/PowerPC/PPCInstrInfo.cpp
parenteb4d746d7d89116ea1e1deca654cafa261748fcd (diff)
downloadllvm-8a88cadaedcfa3bb020df1d100d67cecaf638f35.tar.gz
llvm-8a88cadaedcfa3bb020df1d100d67cecaf638f35.tar.bz2
llvm-8a88cadaedcfa3bb020df1d100d67cecaf638f35.tar.xz
Cleanup PPCInstrInfo::optimizeCompareInstr
Implement suggestions by Bill Schmidt in post-commit review. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCInstrInfo.cpp')
-rw-r--r--lib/Target/PowerPC/PPCInstrInfo.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/Target/PowerPC/PPCInstrInfo.cpp b/lib/Target/PowerPC/PPCInstrInfo.cpp
index 847bd224b6..e6dac83e84 100644
--- a/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -1153,25 +1153,19 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr,
MachineInstr *UseMI = &*I;
if (UseMI->getOpcode() == PPC::BCC) {
unsigned Pred = UseMI->getOperand(0).getImm();
- if (Pred == PPC::PRED_EQ || Pred == PPC::PRED_NE)
- continue;
-
- return false;
+ if (Pred != PPC::PRED_EQ && Pred != PPC::PRED_NE)
+ return false;
} else if (UseMI->getOpcode() == PPC::ISEL ||
UseMI->getOpcode() == PPC::ISEL8) {
unsigned SubIdx = UseMI->getOperand(3).getSubReg();
- if (SubIdx == PPC::sub_eq)
- continue;
-
- return false;
+ if (SubIdx != PPC::sub_eq)
+ return false;
} else
return false;
}
}
- // Get ready to iterate backward from CmpInstr.
- MachineBasicBlock::iterator I = CmpInstr, E = MI,
- B = CmpInstr->getParent()->begin();
+ MachineBasicBlock::iterator I = CmpInstr;
// Scan forward to find the first use of the compare.
for (MachineBasicBlock::iterator EL = CmpInstr->getParent()->end();
@@ -1188,9 +1182,6 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr,
break;
}
- // Early exit if we're at the beginning of the BB.
- if (I == B) return false;
-
// There are two possible candidates which can be changed to set CR[01].
// One is MI, the other is a SUB instruction.
// For CMPrr(r1,r2), we are looking for SUB(r1,r2) or SUB(r2,r1).
@@ -1210,6 +1201,11 @@ bool PPCInstrInfo::optimizeCompareInstr(MachineInstr *CmpInstr,
// Search for Sub.
const TargetRegisterInfo *TRI = &getRegisterInfo();
--I;
+
+ // Get ready to iterate backward from CmpInstr.
+ MachineBasicBlock::iterator E = MI,
+ B = CmpInstr->getParent()->begin();
+
for (; I != E && !noSub; --I) {
const MachineInstr &Instr = *I;
unsigned IOpC = Instr.getOpcode();