Skip to content

Commit cba370b

Browse files
committed
Simplify performNegCSelCombine changes.
Instead of reversing the operands when they are negations of each other, peek through already existing negations. This has the same effect when the operands are negations of each other but should be more generally useful.
1 parent e8efeab commit cba370b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20822,6 +20822,9 @@ static bool isNegatedInteger(SDValue Op) {
2082220822
}
2082320823

2082420824
static SDValue getNegatedInteger(SDValue Op, SelectionDAG &DAG) {
20825+
if (isNegatedInteger(Op))
20826+
return Op.getOperand(1);
20827+
2082520828
SDLoc DL(Op);
2082620829
EVT VT = Op.getValueType();
2082720830
SDValue Zero = DAG.getConstant(0, DL, VT);
@@ -20851,17 +20854,11 @@ static SDValue performNegCSelCombine(SDNode *N, SelectionDAG &DAG) {
2085120854
if (!isNegatedInteger(N0) && !isNegatedInteger(N1))
2085220855
return SDValue();
2085320856

20854-
SDLoc DL(N);
20855-
EVT VT = CSel.getValueType();
20856-
20857-
// If the operands are negations of each other, reverse them.
20858-
if ((isNegatedInteger(N0) && N0.getOperand(1) == N1) ||
20859-
(isNegatedInteger(N1) && N1.getOperand(1) == N0))
20860-
return DAG.getNode(AArch64ISD::CSEL, DL, VT, N1, N0, CSel.getOperand(2),
20861-
CSel.getOperand(3));
20862-
2086320857
SDValue N0N = getNegatedInteger(N0, DAG);
2086420858
SDValue N1N = getNegatedInteger(N1, DAG);
20859+
20860+
SDLoc DL(N);
20861+
EVT VT = CSel.getValueType();
2086520862
return DAG.getNode(AArch64ISD::CSEL, DL, VT, N0N, N1N, CSel.getOperand(2),
2086620863
CSel.getOperand(3));
2086720864
}

0 commit comments

Comments
 (0)