Skip to content

Commit f809c68

Browse files
committed
Use pattern matcher
1 parent 6d1d4ab commit f809c68

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,21 +2444,23 @@ tryToCreateAbstractPartialReductionRecipe(VPPartialReductionRecipe *PRed) {
24442444
if (PRed->getOpcode() != Instruction::Add)
24452445
return;
24462446

2447-
VPRecipeBase *BinOpR = PRed->getBinOp()->getDefiningRecipe();
2448-
auto *BinOp = dyn_cast<VPWidenRecipe>(BinOpR);
2449-
if (!BinOp || BinOp->getOpcode() != Instruction::Mul)
2447+
using namespace llvm::VPlanPatternMatch;
2448+
auto *BinOp = PRed->getBinOp();
2449+
if (!match(BinOp,
2450+
m_Mul(m_ZExtOrSExt(m_VPValue()), m_ZExtOrSExt(m_VPValue()))))
24502451
return;
24512452

2452-
auto *Ext0 = dyn_cast<VPWidenCastRecipe>(BinOp->getOperand(0));
2453-
auto *Ext1 = dyn_cast<VPWidenCastRecipe>(BinOp->getOperand(1));
2453+
auto *BinOpR = cast<VPWidenRecipe>(BinOp->getDefiningRecipe());
2454+
VPWidenCastRecipe *Ext0R = dyn_cast<VPWidenCastRecipe>(BinOpR->getOperand(0));
2455+
VPWidenCastRecipe *Ext1R = dyn_cast<VPWidenCastRecipe>(BinOpR->getOperand(1));
2456+
24542457
// TODO: Make work with extends of different signedness
2455-
if (!Ext0 || Ext0->hasMoreThanOneUniqueUser() || !Ext1 ||
2456-
Ext1->hasMoreThanOneUniqueUser() ||
2457-
Ext0->getOpcode() != Ext1->getOpcode())
2458+
if (Ext0R->hasMoreThanOneUniqueUser() || Ext1R->hasMoreThanOneUniqueUser() ||
2459+
Ext0R->getOpcode() != Ext1R->getOpcode())
24582460
return;
24592461

2460-
auto *AbstractR = new VPMulAccumulateReductionRecipe(PRed, BinOp, Ext0, Ext1,
2461-
Ext0->getResultType());
2462+
auto *AbstractR = new VPMulAccumulateReductionRecipe(
2463+
PRed, BinOpR, Ext0R, Ext1R, Ext0R->getResultType());
24622464
AbstractR->insertBefore(PRed);
24632465
PRed->replaceAllUsesWith(AbstractR);
24642466
}

0 commit comments

Comments
 (0)