Skip to content

Commit c762c23

Browse files
committed
Use pattern matcher
1 parent 99bae91 commit c762c23

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
@@ -2924,21 +2924,23 @@ tryToCreateAbstractPartialReductionRecipe(VPPartialReductionRecipe *PRed) {
29242924
if (PRed->getOpcode() != Instruction::Add)
29252925
return;
29262926

2927-
VPRecipeBase *BinOpR = PRed->getBinOp()->getDefiningRecipe();
2928-
auto *BinOp = dyn_cast<VPWidenRecipe>(BinOpR);
2929-
if (!BinOp || BinOp->getOpcode() != Instruction::Mul)
2927+
using namespace llvm::VPlanPatternMatch;
2928+
auto *BinOp = PRed->getBinOp();
2929+
if (!match(BinOp,
2930+
m_Mul(m_ZExtOrSExt(m_VPValue()), m_ZExtOrSExt(m_VPValue()))))
29302931
return;
29312932

2932-
auto *Ext0 = dyn_cast<VPWidenCastRecipe>(BinOp->getOperand(0));
2933-
auto *Ext1 = dyn_cast<VPWidenCastRecipe>(BinOp->getOperand(1));
2933+
auto *BinOpR = cast<VPWidenRecipe>(BinOp->getDefiningRecipe());
2934+
VPWidenCastRecipe *Ext0R = dyn_cast<VPWidenCastRecipe>(BinOpR->getOperand(0));
2935+
VPWidenCastRecipe *Ext1R = dyn_cast<VPWidenCastRecipe>(BinOpR->getOperand(1));
2936+
29342937
// TODO: Make work with extends of different signedness
2935-
if (!Ext0 || Ext0->hasMoreThanOneUniqueUser() || !Ext1 ||
2936-
Ext1->hasMoreThanOneUniqueUser() ||
2937-
Ext0->getOpcode() != Ext1->getOpcode())
2938+
if (Ext0R->hasMoreThanOneUniqueUser() || Ext1R->hasMoreThanOneUniqueUser() ||
2939+
Ext0R->getOpcode() != Ext1R->getOpcode())
29382940
return;
29392941

2940-
auto *AbstractR = new VPMulAccumulateReductionRecipe(PRed, BinOp, Ext0, Ext1,
2941-
Ext0->getResultType());
2942+
auto *AbstractR = new VPMulAccumulateReductionRecipe(
2943+
PRed, BinOpR, Ext0R, Ext1R, Ext0R->getResultType());
29422944
AbstractR->insertBefore(PRed);
29432945
PRed->replaceAllUsesWith(AbstractR);
29442946
}

0 commit comments

Comments
 (0)