Skip to content

Commit 8326fb2

Browse files
committed
[X86] combineOrXorWithSETCC - avoid duplicate SDLoc/operands code. NFC.
Reuse values from the callers directly.
1 parent 8cead83 commit 8326fb2

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51206,10 +51206,10 @@ static SDValue combineAddOrSubToADCOrSBB(SDNode *N, const SDLoc &DL,
5120651206
return SDValue();
5120751207
}
5120851208

51209-
static SDValue combineOrXorWithSETCC(SDNode *N, SDValue N0, SDValue N1,
51209+
static SDValue combineOrXorWithSETCC(unsigned Opc, const SDLoc &DL, EVT VT,
51210+
SDValue N0, SDValue N1,
5121051211
SelectionDAG &DAG) {
51211-
assert((N->getOpcode() == ISD::XOR || N->getOpcode() == ISD::OR) &&
51212-
"Unexpected opcode");
51212+
assert((Opc == ISD::XOR || Opc == ISD::OR) && "Unexpected opcode");
5121351213

5121451214
// Delegate to combineAddOrSubToADCOrSBB if we have:
5121551215
//
@@ -51220,23 +51220,19 @@ static SDValue combineOrXorWithSETCC(SDNode *N, SDValue N0, SDValue N1,
5122051220
if (N0.getOpcode() == ISD::ZERO_EXTEND &&
5122151221
N0.getOperand(0).getOpcode() == X86ISD::SETCC && N0.hasOneUse()) {
5122251222
if (auto *N1C = dyn_cast<ConstantSDNode>(N1)) {
51223-
bool IsSub = N->getOpcode() == ISD::XOR;
51223+
bool IsSub = Opc == ISD::XOR;
5122451224
bool N1COdd = N1C->getZExtValue() & 1;
51225-
if (IsSub ? N1COdd : !N1COdd) {
51226-
SDLoc DL(N);
51227-
EVT VT = N->getValueType(0);
51225+
if (IsSub ? N1COdd : !N1COdd)
5122851226
if (SDValue R = combineAddOrSubToADCOrSBB(IsSub, DL, VT, N1, N0, DAG))
5122951227
return R;
51230-
}
5123151228
}
5123251229
}
5123351230

5123451231
// not(pcmpeq(and(X,CstPow2),0)) -> pcmpeq(and(X,CstPow2),CstPow2)
51235-
if (N->getOpcode() == ISD::XOR && N0.getOpcode() == X86ISD::PCMPEQ &&
51232+
if (Opc == ISD::XOR && N0.getOpcode() == X86ISD::PCMPEQ &&
5123651233
N0.getOperand(0).getOpcode() == ISD::AND &&
5123751234
ISD::isBuildVectorAllZeros(N0.getOperand(1).getNode()) &&
5123851235
ISD::isBuildVectorAllOnes(N1.getNode())) {
51239-
MVT VT = N->getSimpleValueType(0);
5124051236
APInt UndefElts;
5124151237
SmallVector<APInt> EltBits;
5124251238
if (getTargetConstantBitsFromNode(N0.getOperand(0).getOperand(1),
@@ -51247,7 +51243,7 @@ static SDValue combineOrXorWithSETCC(SDNode *N, SDValue N0, SDValue N1,
5124751243
IsPow2OrUndef &= UndefElts[I] || EltBits[I].isPowerOf2();
5124851244

5124951245
if (IsPow2OrUndef)
51250-
return DAG.getNode(X86ISD::PCMPEQ, SDLoc(N), VT, N0.getOperand(0),
51246+
return DAG.getNode(X86ISD::PCMPEQ, DL, VT, N0.getOperand(0),
5125151247
N0.getOperand(0).getOperand(1));
5125251248
}
5125351249
}
@@ -51409,7 +51405,7 @@ static SDValue combineOr(SDNode *N, SelectionDAG &DAG,
5140951405
if (SDValue R = foldMaskedMerge(N, DAG))
5141051406
return R;
5141151407

51412-
if (SDValue R = combineOrXorWithSETCC(N, N0, N1, DAG))
51408+
if (SDValue R = combineOrXorWithSETCC(N->getOpcode(), dl, VT, N0, N1, DAG))
5141351409
return R;
5141451410

5141551411
return SDValue();
@@ -53638,7 +53634,7 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
5363853634
if (SDValue SetCC = foldXor1SetCC(N, DAG))
5363953635
return SetCC;
5364053636

53641-
if (SDValue R = combineOrXorWithSETCC(N, N0, N1, DAG))
53637+
if (SDValue R = combineOrXorWithSETCC(N->getOpcode(), DL, VT, N0, N1, DAG))
5364253638
return R;
5364353639

5364453640
if (SDValue RV = foldXorTruncShiftIntoCmp(N, DAG))

0 commit comments

Comments
 (0)