Skip to content

Commit 076a9dc

Browse files
committed
[X86][NFC] Rename hasCMOV() to canUseCMOV(), hasLAHFSAHF() to canUseLAHFSAHF()
To make them less like other feature functions. This is a follow-up patch for D121978.
1 parent 4eb59f0 commit 076a9dc

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

llvm/lib/Target/X86/X86FastISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ bool X86FastISel::X86SelectDivRem(const Instruction *I) {
20362036
/// the select.
20372037
bool X86FastISel::X86FastEmitCMoveSelect(MVT RetVT, const Instruction *I) {
20382038
// Check if the subtarget supports these instructions.
2039-
if (!Subtarget->hasCMOV())
2039+
if (!Subtarget->canUseCMOV())
20402040
return false;
20412041

20422042
// FIXME: Add support for i8.

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5514,7 +5514,7 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
55145514
MVT CmpVT = N0.getSimpleValueType();
55155515

55165516
// Floating point needs special handling if we don't have FCOMI.
5517-
if (Subtarget->hasCMOV())
5517+
if (Subtarget->canUseCMOV())
55185518
break;
55195519

55205520
bool IsSignaling = Node->getOpcode() == X86ISD::STRICT_FCMPS;
@@ -5554,7 +5554,7 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
55545554

55555555
// Move AH into flags.
55565556
// Some 64-bit targets lack SAHF support, but they do support FCOMI.
5557-
assert(Subtarget->hasLAHFSAHF() &&
5557+
assert(Subtarget->canUseLAHFSAHF() &&
55585558
"Target doesn't support SAHF or FCOMI?");
55595559
SDValue AH = CurDAG->getCopyToReg(Chain, dl, X86::AH, Extract, SDValue());
55605560
Chain = AH;

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
200200
}
201201

202202
// Integer absolute.
203-
if (Subtarget.hasCMOV()) {
203+
if (Subtarget.canUseCMOV()) {
204204
setOperationAction(ISD::ABS , MVT::i16 , Custom);
205205
setOperationAction(ISD::ABS , MVT::i32 , Custom);
206206
if (Subtarget.is64Bit())
@@ -23466,7 +23466,7 @@ X86TargetLowering::BuildSDIVPow2(SDNode *N, const APInt &Divisor,
2346623466

2346723467
// Only perform this transform if CMOV is supported otherwise the select
2346823468
// below will become a branch.
23469-
if (!Subtarget.hasCMOV())
23469+
if (!Subtarget.canUseCMOV())
2347023470
return SDValue();
2347123471

2347223472
// fold (sdiv X, pow2)
@@ -24662,7 +24662,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
2466224662
return (Op1.getOpcode() == ISD::CTTZ_ZERO_UNDEF && Op1.hasOneUse() &&
2466324663
Op1.getOperand(0) == CmpOp0 && isAllOnesConstant(Op2));
2466424664
};
24665-
if (Subtarget.hasCMOV() && (VT == MVT::i32 || VT == MVT::i64) &&
24665+
if (Subtarget.canUseCMOV() && (VT == MVT::i32 || VT == MVT::i64) &&
2466624666
((CondCode == X86::COND_NE && MatchFFSMinus1(Op1, Op2)) ||
2466724667
(CondCode == X86::COND_E && MatchFFSMinus1(Op2, Op1)))) {
2466824668
// Keep Cmp.
@@ -24690,7 +24690,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
2469024690
DAG.getTargetConstant(X86::COND_B, DL, MVT::i8),
2469124691
Sub.getValue(1));
2469224692
return DAG.getNode(ISD::OR, DL, VT, SBB, Y);
24693-
} else if (!Subtarget.hasCMOV() && CondCode == X86::COND_E &&
24693+
} else if (!Subtarget.canUseCMOV() && CondCode == X86::COND_E &&
2469424694
Cmp.getOperand(0).getOpcode() == ISD::AND &&
2469524695
isOneConstant(Cmp.getOperand(0).getOperand(1))) {
2469624696
SDValue Src1, Src2;
@@ -24745,7 +24745,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
2474524745
SDValue Cmp = Cond.getOperand(1);
2474624746
bool IllegalFPCMov = false;
2474724747
if (VT.isFloatingPoint() && !VT.isVector() &&
24748-
!isScalarFPTypeInSSEReg(VT) && Subtarget.hasCMOV()) // FPStack?
24748+
!isScalarFPTypeInSSEReg(VT) && Subtarget.canUseCMOV()) // FPStack?
2474924749
IllegalFPCMov = !hasFPCMov(cast<ConstantSDNode>(CC)->getSExtValue());
2475024750

2475124751
if ((isX86LogicalCmp(Cmp) && !IllegalFPCMov) ||
@@ -24826,7 +24826,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
2482624826
// legal, but EmitLoweredSelect() can not deal with these extensions
2482724827
// being inserted between two CMOV's. (in i16 case too TBN)
2482824828
// https://bugs.llvm.org/show_bug.cgi?id=40974
24829-
if ((Op.getValueType() == MVT::i8 && Subtarget.hasCMOV()) ||
24829+
if ((Op.getValueType() == MVT::i8 && Subtarget.canUseCMOV()) ||
2483024830
(Op.getValueType() == MVT::i16 && !X86::mayFoldLoad(Op1, Subtarget) &&
2483124831
!X86::mayFoldLoad(Op2, Subtarget))) {
2483224832
Op1 = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i32, Op1);
@@ -45111,7 +45111,7 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4511145111
if (!(FalseOp.getValueType() == MVT::f80 ||
4511245112
(FalseOp.getValueType() == MVT::f64 && !Subtarget.hasSSE2()) ||
4511345113
(FalseOp.getValueType() == MVT::f32 && !Subtarget.hasSSE1())) ||
45114-
!Subtarget.hasCMOV() || hasFPCMov(CC)) {
45114+
!Subtarget.canUseCMOV() || hasFPCMov(CC)) {
4511545115
SDValue Ops[] = {FalseOp, TrueOp, DAG.getTargetConstant(CC, DL, MVT::i8),
4511645116
Flags};
4511745117
return DAG.getNode(X86ISD::CMOV, DL, N->getValueType(0), Ops);

llvm/lib/Target/X86/X86InstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3463,7 +3463,7 @@ bool X86InstrInfo::canInsertSelect(const MachineBasicBlock &MBB,
34633463
Register FalseReg, int &CondCycles,
34643464
int &TrueCycles, int &FalseCycles) const {
34653465
// Not all subtargets have cmov instructions.
3466-
if (!Subtarget.hasCMOV())
3466+
if (!Subtarget.canUseCMOV())
34673467
return false;
34683468
if (Cond.size() != 1)
34693469
return false;

llvm/lib/Target/X86/X86InstrInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,8 @@ def relocImm : ComplexPattern<iAny, 1, "selectRelocImm",
875875
// X86 Instruction Predicate Definitions.
876876
def TruePredicate : Predicate<"true">;
877877

878-
def HasCMOV : Predicate<"Subtarget->hasCMOV()">;
879-
def NoCMOV : Predicate<"!Subtarget->hasCMOV()">;
878+
def HasCMOV : Predicate<"Subtarget->canUseCMOV()">;
879+
def NoCMOV : Predicate<"!Subtarget->canUseCMOV()">;
880880

881881
def HasMMX : Predicate<"Subtarget->hasMMX()">;
882882
def Has3DNow : Predicate<"Subtarget->hasThreeDNow()">;

llvm/lib/Target/X86/X86Subtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ const RegisterBankInfo *X86Subtarget::getRegBankInfo() const {
359359
}
360360

361361
bool X86Subtarget::enableEarlyIfConversion() const {
362-
return hasCMOV() && X86EarlyIfConv;
362+
return canUseCMOV() && X86EarlyIfConv;
363363
}
364364

365365
void X86Subtarget::getPostRAMutations(

llvm/lib/Target/X86/X86Subtarget.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,10 @@ class X86Subtarget final : public X86GenSubtargetInfo {
640640
return hasCX16() && is64Bit();
641641
}
642642
bool hasNOPL() const { return HasNOPL; }
643+
bool hasCMOV() const { return HasCMOV; }
643644
// SSE codegen depends on cmovs, and all SSE1+ processors support them.
644645
// All 64-bit processors support cmov.
645-
bool hasCMOV() const { return HasCMOV || X86SSELevel >= SSE1 || is64Bit(); }
646+
bool canUseCMOV() const { return hasCMOV() || hasSSE1() || is64Bit(); }
646647
bool hasSSE1() const { return X86SSELevel >= SSE1; }
647648
bool hasSSE2() const { return X86SSELevel >= SSE2; }
648649
bool hasSSE3() const { return X86SSELevel >= SSE3; }
@@ -705,7 +706,8 @@ class X86Subtarget final : public X86GenSubtargetInfo {
705706
return hasSSE1() || (hasPRFCHW() && !hasThreeDNow()) || hasPREFETCHWT1();
706707
}
707708
bool hasRDSEED() const { return HasRDSEED; }
708-
bool hasLAHFSAHF() const { return HasLAHFSAHF64 || !is64Bit(); }
709+
bool hasLAHFSAHF() const { return HasLAHFSAHF64; }
710+
bool canUseLAHFSAHF() const { return hasLAHFSAHF() || !is64Bit(); }
709711
bool hasMWAITX() const { return HasMWAITX; }
710712
bool hasCLZERO() const { return HasCLZERO; }
711713
bool hasCLDEMOTE() const { return HasCLDEMOTE; }

0 commit comments

Comments
 (0)