Skip to content

Commit f62a76e

Browse files
committed
address review comments
1 parent ef7f8a8 commit f62a76e

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

llvm/lib/Target/X86/X86ConditionalCompares.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ STATISTIC(NumConverted, "Number of ccmp instructions created");
125125
namespace {
126126
class SSACCmpConv {
127127
MachineFunction *MF;
128-
const X86Subtarget *STI;
129128
const TargetInstrInfo *TII;
130129
const TargetRegisterInfo *TRI;
131130
MachineRegisterInfo *MRI;
@@ -181,7 +180,6 @@ class SSACCmpConv {
181180
const MachineBranchProbabilityInfo *MBPI) {
182181
this->MF = &MF;
183182
this->MBPI = MBPI;
184-
STI = &MF.getSubtarget<X86Subtarget>();
185183
TII = MF.getSubtarget().getInstrInfo();
186184
TRI = MF.getSubtarget().getRegisterInfo();
187185
MRI = &MF.getRegInfo();
@@ -200,14 +198,12 @@ class SSACCmpConv {
200198
// Check that all PHIs in Tail are selecting the same value from Head and CmpBB.
201199
// This means that no if-conversion is required when merging CmpBB into Head.
202200
bool SSACCmpConv::trivialTailPHIs() {
203-
for (auto &I : *Tail) {
204-
if (!I.isPHI())
205-
break;
201+
for (auto &I : Tail->phis()) {
206202
unsigned HeadReg = 0, CmpBBReg = 0;
207203
// PHI operands come in (VReg, MBB) pairs.
208-
for (unsigned oi = 1, oe = I.getNumOperands(); oi != oe; oi += 2) {
209-
MachineBasicBlock *MBB = I.getOperand(oi + 1).getMBB();
210-
Register Reg = I.getOperand(oi).getReg();
204+
for (unsigned Idx = 1, End = I.getNumOperands(); Idx != End; Idx += 2) {
205+
MachineBasicBlock *MBB = I.getOperand(Idx + 1).getMBB();
206+
Register Reg = I.getOperand(Idx).getReg();
211207
if (MBB == Head) {
212208
assert((!HeadReg || HeadReg == Reg) && "Inconsistent PHI operands");
213209
HeadReg = Reg;
@@ -226,9 +222,7 @@ bool SSACCmpConv::trivialTailPHIs() {
226222
// Assuming that trivialTailPHIs() is true, update the Tail PHIs by simply
227223
// removing the CmpBB operands. The Head operands will be identical.
228224
void SSACCmpConv::updateTailPHIs() {
229-
for (auto &I : *Tail) {
230-
if (!I.isPHI())
231-
break;
225+
for (auto &I : Tail->phis()) {
232226
// I is a PHI. It can have multiple entries for CmpBB.
233227
for (unsigned Idx = I.getNumOperands(); Idx > 2; Idx -= 2) {
234228
// PHI operands are (Reg, MBB) at (Idx-2, Idx-1).
@@ -285,7 +279,7 @@ MachineInstr *SSACCmpConv::findConvertibleCompare(MachineBasicBlock *MBB) {
285279
case X86::SUB64ri32_ND: {
286280
if (!isDeadDef(I->getOperand(0).getReg()))
287281
return nullptr;
288-
return STI->hasCCMP() ? &*I : nullptr;
282+
return &*I;
289283
}
290284
case X86::CMP8rr:
291285
case X86::CMP16rr:
@@ -303,7 +297,7 @@ MachineInstr *SSACCmpConv::findConvertibleCompare(MachineBasicBlock *MBB) {
303297
case X86::TEST16ri:
304298
case X86::TEST32ri:
305299
case X86::TEST64ri32:
306-
return STI->hasCCMP() ? &*I : nullptr;
300+
return &*I;
307301
default:
308302
break;
309303
}

0 commit comments

Comments
 (0)