Skip to content

Commit d1ca593

Browse files
committed
add getCondFromCFCMov
1 parent 3cbc9eb commit d1ca593

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

llvm/lib/Target/X86/X86FlagsCopyLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ bool X86FlagsCopyLoweringPass::runOnMachineFunction(MachineFunction &MF) {
604604
}
605605

606606
// Otherwise we can just rewrite in-place.
607-
if (X86::getCondFromCMov(MI) != X86::COND_INVALID) {
607+
if (X86::getCondFromCMov(MI) != X86::COND_INVALID ||
608+
X86::getCondFromCFCMov(MI) != X86::COND_INVALID) {
608609
rewriteCMov(*TestMBB, TestPos, TestLoc, MI, *FlagUse, CondRegs);
609610
} else if (getCondFromFCMOV(MI.getOpcode()) != X86::COND_INVALID) {
610611
rewriteFCMov(*TestMBB, TestPos, TestLoc, MI, *FlagUse, CondRegs);
@@ -829,7 +830,9 @@ void X86FlagsCopyLoweringPass::rewriteCMov(MachineBasicBlock &TestMBB,
829830
MachineOperand &FlagUse,
830831
CondRegArray &CondRegs) {
831832
// First get the register containing this specific condition.
832-
X86::CondCode Cond = X86::getCondFromCMov(CMovI);
833+
X86::CondCode Cond = X86::getCondFromCMov(CMovI) == X86::COND_INVALID
834+
? X86::getCondFromCFCMov(CMovI)
835+
: X86::getCondFromCMov(CMovI);
833836
unsigned CondReg;
834837
bool Inverted;
835838
std::tie(CondReg, Inverted) =

llvm/lib/Target/X86/X86InstrInfo.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,9 +3148,13 @@ X86::CondCode X86::getCondFromSETCC(const MachineInstr &MI) {
31483148
}
31493149

31503150
X86::CondCode X86::getCondFromCMov(const MachineInstr &MI) {
3151-
return X86::isCMOVCC(MI.getOpcode()) || X86::isCFCMOVCC(MI.getOpcode())
3152-
? X86::getCondFromMI(MI)
3153-
: X86::COND_INVALID;
3151+
return X86::isCMOVCC(MI.getOpcode()) ? X86::getCondFromMI(MI)
3152+
: X86::COND_INVALID;
3153+
}
3154+
3155+
X86::CondCode X86::getCondFromCFCMov(const MachineInstr &MI) {
3156+
return X86::isCFCMOVCC(MI.getOpcode()) ? X86::getCondFromMI(MI)
3157+
: X86::COND_INVALID;
31543158
}
31553159

31563160
/// Return the inverse of the specified condition,

llvm/lib/Target/X86/X86InstrInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ CondCode getCondFromSETCC(const MachineInstr &MI);
6262
// Turn CMOV instruction into condition code.
6363
CondCode getCondFromCMov(const MachineInstr &MI);
6464

65+
// Turn CFCMOV instruction into condition code.
66+
CondCode getCondFromCFCMov(const MachineInstr &MI);
67+
6568
/// GetOppositeBranchCondition - Return the inverse of the specified cond,
6669
/// e.g. turning COND_E to COND_NE.
6770
CondCode GetOppositeBranchCondition(CondCode CC);

0 commit comments

Comments
 (0)