@@ -3543,12 +3543,14 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35433543 };
35443544
35453545 VPValue *VecOp = Red->getVecOp ();
3546- VPValue *Sub = nullptr ;
3546+ VPRecipeBase *Sub = nullptr ;
35473547 VPValue *A, *B;
3548+ VPValue *Tmp = nullptr ;
35483549 // Sub reductions could have a sub between the add reduction and vec op.
3549- if (match (VecOp, m_Binary<Instruction::Sub>(m_SpecificInt (0 ), m_VPValue ()))) {
3550- Sub = VecOp;
3551- VecOp = cast<VPWidenRecipe>(VecOp->getDefiningRecipe ())->getOperand (1 );
3550+ if (match (VecOp,
3551+ m_Binary<Instruction::Sub>(m_SpecificInt (0 ), m_VPValue (Tmp)))) {
3552+ Sub = VecOp->getDefiningRecipe ();
3553+ VecOp = Tmp;
35523554 }
35533555 // Try to match reduce.add(mul(...)).
35543556 if (match (VecOp, m_Mul (m_VPValue (A), m_VPValue (B)))) {
@@ -3567,9 +3569,8 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35673569 Instruction::CastOps::ZExt,
35683570 Mul, RecipeA, RecipeB, nullptr )) {
35693571 if (Sub)
3570- return new VPExpressionRecipe (
3571- RecipeA, RecipeB, Mul,
3572- cast<VPWidenRecipe>(Sub->getDefiningRecipe ()), Red);
3572+ return new VPExpressionRecipe (RecipeA, RecipeB, Mul,
3573+ cast<VPWidenRecipe>(Sub), Red);
35733574 return new VPExpressionRecipe (RecipeA, RecipeB, Mul, Red);
35743575 }
35753576 // Match reduce.add(mul).
@@ -3578,12 +3579,15 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
35783579 IsMulAccValidAndClampRange (true , Mul, nullptr , nullptr , nullptr ))
35793580 return new VPExpressionRecipe (Mul, Red);
35803581 }
3582+ // TODO: Add an expression type for negated versions of other expression
3583+ // variants.
3584+ if (Sub)
3585+ return nullptr ;
35813586 // Match reduce.add(ext(mul(ext(A), ext(B)))).
35823587 // All extend recipes must have same opcode or A == B
35833588 // which can be transform to reduce.add(zext(mul(sext(A), sext(B)))).
3584- // TODO: Add an expression type for this variant with a negated mul
3585- if (!Sub && match (VecOp, m_ZExtOrSExt (m_Mul (m_ZExtOrSExt (m_VPValue ()),
3586- m_ZExtOrSExt (m_VPValue ()))))) {
3589+ if (match (VecOp, m_ZExtOrSExt (m_Mul (m_ZExtOrSExt (m_VPValue ()),
3590+ m_ZExtOrSExt (m_VPValue ()))))) {
35873591 auto *Ext = cast<VPWidenCastRecipe>(VecOp->getDefiningRecipe ());
35883592 auto *Mul = cast<VPWidenRecipe>(Ext->getOperand (0 )->getDefiningRecipe ());
35893593 auto *Ext0 =
0 commit comments