Skip to content

Commit d230442

Browse files
[DAG][NFC] Use SDPatternMatch for VScale in some instances
1 parent ad77888 commit d230442

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
@@ -1086,10 +1086,9 @@ bool DAGCombiner::reassociationCanBreakAddressingModePattern(unsigned Opc,
10861086
// (load/store (add/sub (add x, y), vscale))
10871087
// (load/store (add/sub (add x, y), (lsl vscale, C)))
10881088
// (load/store (add/sub (add x, y), (mul vscale, C)))
1089-
if ((N1.getOpcode() == ISD::VSCALE ||
1090-
((N1.getOpcode() == ISD::SHL || N1.getOpcode() == ISD::MUL) &&
1091-
N1.getOperand(0).getOpcode() == ISD::VSCALE &&
1092-
isa<ConstantSDNode>(N1.getOperand(1)))) &&
1089+
if (sd_match(N1, m_AnyOf(m_VScale(m_Value()),
1090+
m_Shl(m_VScale(m_Value()), m_ConstInt()),
1091+
m_Mul(m_VScale(m_Value()), m_ConstInt()))) &&
10931092
N1.getValueType().getFixedSizeInBits() <= 64) {
10941093
int64_t ScalableOffset = N1.getOpcode() == ISD::VSCALE
10951094
? N1.getConstantOperandVal(0)
@@ -2975,8 +2974,7 @@ SDValue DAGCombiner::visitADD(SDNode *N) {
29752974
}
29762975

29772976
// fold a+vscale(c1)+vscale(c2) -> a+vscale(c1+c2)
2978-
if (N0.getOpcode() == ISD::ADD &&
2979-
N0.getOperand(1).getOpcode() == ISD::VSCALE &&
2977+
if (sd_match(N0, m_Add(m_Value(), m_VScale(m_Value()))) &&
29802978
N1.getOpcode() == ISD::VSCALE) {
29812979
const APInt &VS0 = N0.getOperand(1)->getConstantOperandAPInt(0);
29822980
const APInt &VS1 = N1->getConstantOperandAPInt(0);

0 commit comments

Comments
 (0)