forked from OSchip/llvm-project
[X86] combineAddOrSubToADCOrSBB - pull out repeated Y.getOperand(1) calls. NFC.
This commit is contained in:
parent
85e9b2687a
commit
34110a7320
|
@ -52315,6 +52315,7 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, SelectionDAG &DAG) {
|
||||||
SDLoc DL(N);
|
SDLoc DL(N);
|
||||||
EVT VT = N->getValueType(0);
|
EVT VT = N->getValueType(0);
|
||||||
X86::CondCode CC = (X86::CondCode)Y.getConstantOperandVal(0);
|
X86::CondCode CC = (X86::CondCode)Y.getConstantOperandVal(0);
|
||||||
|
SDValue EFLAGS = Y.getOperand(1);
|
||||||
|
|
||||||
// If X is -1 or 0, then we have an opportunity to avoid constants required in
|
// If X is -1 or 0, then we have an opportunity to avoid constants required in
|
||||||
// the general case below.
|
// the general case below.
|
||||||
|
@ -52327,12 +52328,11 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, SelectionDAG &DAG) {
|
||||||
// 0 - SETB --> 0 - (CF) --> CF ? -1 : 0 --> SBB %eax, %eax
|
// 0 - SETB --> 0 - (CF) --> CF ? -1 : 0 --> SBB %eax, %eax
|
||||||
return DAG.getNode(X86ISD::SETCC_CARRY, DL, VT,
|
return DAG.getNode(X86ISD::SETCC_CARRY, DL, VT,
|
||||||
DAG.getTargetConstant(X86::COND_B, DL, MVT::i8),
|
DAG.getTargetConstant(X86::COND_B, DL, MVT::i8),
|
||||||
Y.getOperand(1));
|
EFLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!IsSub && CC == X86::COND_BE && ConstantX->isAllOnes()) ||
|
if ((!IsSub && CC == X86::COND_BE && ConstantX->isAllOnes()) ||
|
||||||
(IsSub && CC == X86::COND_A && ConstantX->isZero())) {
|
(IsSub && CC == X86::COND_A && ConstantX->isZero())) {
|
||||||
SDValue EFLAGS = Y->getOperand(1);
|
|
||||||
if (EFLAGS.getOpcode() == X86ISD::SUB && EFLAGS.hasOneUse() &&
|
if (EFLAGS.getOpcode() == X86ISD::SUB && EFLAGS.hasOneUse() &&
|
||||||
EFLAGS.getValueType().isInteger() &&
|
EFLAGS.getValueType().isInteger() &&
|
||||||
!isa<ConstantSDNode>(EFLAGS.getOperand(1))) {
|
!isa<ConstantSDNode>(EFLAGS.getOperand(1))) {
|
||||||
|
@ -52355,11 +52355,10 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, SelectionDAG &DAG) {
|
||||||
// X - SETB Z --> sbb X, 0
|
// X - SETB Z --> sbb X, 0
|
||||||
return DAG.getNode(IsSub ? X86ISD::SBB : X86ISD::ADC, DL,
|
return DAG.getNode(IsSub ? X86ISD::SBB : X86ISD::ADC, DL,
|
||||||
DAG.getVTList(VT, MVT::i32), X,
|
DAG.getVTList(VT, MVT::i32), X,
|
||||||
DAG.getConstant(0, DL, VT), Y.getOperand(1));
|
DAG.getConstant(0, DL, VT), EFLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CC == X86::COND_A) {
|
if (CC == X86::COND_A) {
|
||||||
SDValue EFLAGS = Y.getOperand(1);
|
|
||||||
// Try to convert COND_A into COND_B in an attempt to facilitate
|
// Try to convert COND_A into COND_B in an attempt to facilitate
|
||||||
// materializing "setb reg".
|
// materializing "setb reg".
|
||||||
//
|
//
|
||||||
|
@ -52384,13 +52383,12 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, SelectionDAG &DAG) {
|
||||||
// X - SETAE --> adc X, -1
|
// X - SETAE --> adc X, -1
|
||||||
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL,
|
return DAG.getNode(IsSub ? X86ISD::ADC : X86ISD::SBB, DL,
|
||||||
DAG.getVTList(VT, MVT::i32), X,
|
DAG.getVTList(VT, MVT::i32), X,
|
||||||
DAG.getConstant(-1, DL, VT), Y.getOperand(1));
|
DAG.getConstant(-1, DL, VT), EFLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CC == X86::COND_BE) {
|
if (CC == X86::COND_BE) {
|
||||||
// X + SETBE --> sbb X, -1
|
// X + SETBE --> sbb X, -1
|
||||||
// X - SETBE --> adc X, -1
|
// X - SETBE --> adc X, -1
|
||||||
SDValue EFLAGS = Y.getOperand(1);
|
|
||||||
// Try to convert COND_BE into COND_AE in an attempt to facilitate
|
// Try to convert COND_BE into COND_AE in an attempt to facilitate
|
||||||
// materializing "setae reg".
|
// materializing "setae reg".
|
||||||
//
|
//
|
||||||
|
@ -52413,13 +52411,12 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, SelectionDAG &DAG) {
|
||||||
if (CC != X86::COND_E && CC != X86::COND_NE)
|
if (CC != X86::COND_E && CC != X86::COND_NE)
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
SDValue Cmp = Y.getOperand(1);
|
if (EFLAGS.getOpcode() != X86ISD::CMP || !EFLAGS.hasOneUse() ||
|
||||||
if (Cmp.getOpcode() != X86ISD::CMP || !Cmp.hasOneUse() ||
|
!X86::isZeroNode(EFLAGS.getOperand(1)) ||
|
||||||
!X86::isZeroNode(Cmp.getOperand(1)) ||
|
!EFLAGS.getOperand(0).getValueType().isInteger())
|
||||||
!Cmp.getOperand(0).getValueType().isInteger())
|
|
||||||
return SDValue();
|
return SDValue();
|
||||||
|
|
||||||
SDValue Z = Cmp.getOperand(0);
|
SDValue Z = EFLAGS.getOperand(0);
|
||||||
EVT ZVT = Z.getValueType();
|
EVT ZVT = Z.getValueType();
|
||||||
|
|
||||||
// If X is -1 or 0, then we have an opportunity to avoid constants required in
|
// If X is -1 or 0, then we have an opportunity to avoid constants required in
|
||||||
|
|
Loading…
Reference in New Issue