Skip to content

Commit 39eedfd

Browse files
committed
[DAG] visitADDLikeCommutative - convert (add x, shl(0 - y, n)) fold to SDPatternMatch. NFC.
1 parent 269d0aa commit 39eedfd

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,17 +3053,15 @@ static SDValue foldAddSubMasked1(bool IsAdd, SDValue N0, SDValue N1,
30533053

30543054
/// Helper for doing combines based on N0 and N1 being added to each other.
30553055
SDValue DAGCombiner::visitADDLikeCommutative(SDValue N0, SDValue N1,
3056-
SDNode *LocReference) {
3056+
SDNode *LocReference) {
30573057
EVT VT = N0.getValueType();
30583058
SDLoc DL(LocReference);
30593059

30603060
// fold (add x, shl(0 - y, n)) -> sub(x, shl(y, n))
3061-
if (N1.getOpcode() == ISD::SHL && N1.getOperand(0).getOpcode() == ISD::SUB &&
3062-
isNullOrNullSplat(N1.getOperand(0).getOperand(0)))
3061+
SDValue Y, N;
3062+
if (sd_match(N1, m_Shl(m_Neg(m_Value(Y)), m_Value(N))))
30633063
return DAG.getNode(ISD::SUB, DL, VT, N0,
3064-
DAG.getNode(ISD::SHL, DL, VT,
3065-
N1.getOperand(0).getOperand(1),
3066-
N1.getOperand(1)));
3064+
DAG.getNode(ISD::SHL, DL, VT, Y, N));
30673065

30683066
if (SDValue V = foldAddSubMasked1(true, N0, N1, DAG, DL))
30693067
return V;

0 commit comments

Comments
 (0)