Skip to content

Commit e7de603

Browse files
committed
[X86] combineCMov - pull out repeated getValueType calls. NFC.
1 parent b80965e commit e7de603

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48464,7 +48464,7 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4846448464
TargetLowering::DAGCombinerInfo &DCI,
4846548465
const X86Subtarget &Subtarget) {
4846648466
SDLoc DL(N);
48467-
48467+
EVT VT = N->getValueType(0);
4846848468
SDValue FalseOp = N->getOperand(0);
4846948469
SDValue TrueOp = N->getOperand(1);
4847048470
X86::CondCode CC = (X86::CondCode)N->getConstantOperandVal(2);
@@ -48483,7 +48483,7 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4848348483
!Subtarget.canUseCMOV() || hasFPCMov(CC)) {
4848448484
SDValue Ops[] = {FalseOp, TrueOp, DAG.getTargetConstant(CC, DL, MVT::i8),
4848548485
Flags};
48486-
return DAG.getNode(X86ISD::CMOV, DL, N->getValueType(0), Ops);
48486+
return DAG.getNode(X86ISD::CMOV, DL, VT, Ops);
4848748487
}
4848848488
}
4848948489

@@ -48530,9 +48530,9 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4853048530

4853148531
// Optimize cases that will turn into an LEA instruction. This requires
4853248532
// an i32 or i64 and an efficient multiplier (1, 2, 3, 4, 5, 8, 9).
48533-
if (N->getValueType(0) == MVT::i32 || N->getValueType(0) == MVT::i64) {
48533+
if (VT == MVT::i32 || VT == MVT::i64) {
4853448534
APInt Diff = TrueC->getAPIntValue() - FalseC->getAPIntValue();
48535-
assert(Diff.getBitWidth() == N->getValueType(0).getSizeInBits() &&
48535+
assert(Diff.getBitWidth() == VT.getSizeInBits() &&
4853648536
"Implicit constant truncation");
4853748537

4853848538
bool isFastMultiplier = false;
@@ -48600,11 +48600,10 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4860048600
std::swap(TrueOp, FalseOp);
4860148601
}
4860248602

48603-
if (CC == X86::COND_E &&
48604-
CmpAgainst == dyn_cast<ConstantSDNode>(TrueOp)) {
48603+
if (CC == X86::COND_E && CmpAgainst == dyn_cast<ConstantSDNode>(TrueOp)) {
4860548604
SDValue Ops[] = {FalseOp, Cond.getOperand(0),
4860648605
DAG.getTargetConstant(CC, DL, MVT::i8), Cond};
48607-
return DAG.getNode(X86ISD::CMOV, DL, N->getValueType(0), Ops);
48606+
return DAG.getNode(X86ISD::CMOV, DL, VT, Ops);
4860848607
}
4860948608
}
4861048609
}
@@ -48624,14 +48623,13 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4862448623
auto *Sub1C = dyn_cast<ConstantSDNode>(Cond.getOperand(1));
4862548624
if (Cond0 == TrueOp && Sub1C && Sub1C->getZExtValue() == 2) {
4862648625
EVT CondVT = Cond->getValueType(0);
48627-
EVT OuterVT = N->getValueType(0);
4862848626
// Subtract 1 and generate a carry.
4862948627
SDValue NewSub =
4863048628
DAG.getNode(X86ISD::SUB, DL, Cond->getVTList(), Cond.getOperand(0),
4863148629
DAG.getConstant(1, DL, CondVT));
4863248630
SDValue EFLAGS(NewSub.getNode(), 1);
48633-
return DAG.getNode(X86ISD::ADC, DL, DAG.getVTList(OuterVT, MVT::i32),
48634-
TrueOp, DAG.getConstant(0, DL, OuterVT), EFLAGS);
48631+
return DAG.getNode(X86ISD::ADC, DL, DAG.getVTList(VT, MVT::i32), TrueOp,
48632+
DAG.getConstant(0, DL, VT), EFLAGS);
4863548633
}
4863648634
}
4863748635

@@ -48665,10 +48663,10 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4866548663

4866648664
SDValue LOps[] = {FalseOp, TrueOp,
4866748665
DAG.getTargetConstant(CC0, DL, MVT::i8), Flags};
48668-
SDValue LCMOV = DAG.getNode(X86ISD::CMOV, DL, N->getValueType(0), LOps);
48666+
SDValue LCMOV = DAG.getNode(X86ISD::CMOV, DL, VT, LOps);
4866948667
SDValue Ops[] = {LCMOV, TrueOp, DAG.getTargetConstant(CC1, DL, MVT::i8),
4867048668
Flags};
48671-
SDValue CMOV = DAG.getNode(X86ISD::CMOV, DL, N->getValueType(0), Ops);
48669+
SDValue CMOV = DAG.getNode(X86ISD::CMOV, DL, VT, Ops);
4867248670
return CMOV;
4867348671
}
4867448672
}
@@ -48696,7 +48694,6 @@ static SDValue combineCMov(SDNode *N, SelectionDAG &DAG,
4869648694
(Add.getOperand(0).getOpcode() == ISD::CTTZ_ZERO_UNDEF ||
4869748695
Add.getOperand(0).getOpcode() == ISD::CTTZ) &&
4869848696
Add.getOperand(0).getOperand(0) == Cond.getOperand(0)) {
48699-
EVT VT = N->getValueType(0);
4870048697
// This should constant fold.
4870148698
SDValue Diff = DAG.getNode(ISD::SUB, DL, VT, Const, Add.getOperand(1));
4870248699
SDValue CMov =

0 commit comments

Comments
 (0)