@@ -2689,11 +2689,13 @@ class VPExtendedReductionRecipe : public VPReductionRecipe {
2689
2689
// / and needs to be lowered to concrete recipes before codegen. The operands are
2690
2690
// / {ChainOp, VecOp1, VecOp2, [Condition]}.
2691
2691
class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2692
- // / Opcode of the extend for VecOp1 and VecOp2.
2693
- Instruction::CastOps ExtOp;
2692
+ // / Opcodes of the extend recipes.
2693
+ Instruction::CastOps ExtOp0;
2694
+ Instruction::CastOps ExtOp1;
2694
2695
2695
- // / Non-neg flag of the extend recipe.
2696
- bool IsNonNeg = false ;
2696
+ // / Non-neg flags of the extend recipe.
2697
+ bool IsNonNeg0 = false ;
2698
+ bool IsNonNeg1 = false ;
2697
2699
2698
2700
// / The scalar type after extending.
2699
2701
Type *ResultTy = nullptr ;
@@ -2710,7 +2712,8 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2710
2712
MulAcc->getCondOp (), MulAcc->isOrdered(),
2711
2713
WrapFlagsTy(MulAcc->hasNoUnsignedWrap (), MulAcc->hasNoSignedWrap()),
2712
2714
MulAcc->getDebugLoc()),
2713
- ExtOp(MulAcc->getExtOpcode ()), IsNonNeg(MulAcc->isNonNeg ()),
2715
+ ExtOp0(MulAcc->getExt0Opcode ()), ExtOp1(MulAcc->getExt1Opcode ()),
2716
+ IsNonNeg0(MulAcc->isNonNeg0 ()), IsNonNeg1(MulAcc->isNonNeg1 ()),
2714
2717
ResultTy(MulAcc->getResultType ()),
2715
2718
VFScaleFactor(MulAcc->getVFScaleFactor ()) {
2716
2719
transferFlags (*MulAcc);
@@ -2728,19 +2731,23 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2728
2731
R->getCondOp (), R->isOrdered(),
2729
2732
WrapFlagsTy(Mul->hasNoUnsignedWrap (), Mul->hasNoSignedWrap()),
2730
2733
R->getDebugLoc()),
2731
- ExtOp(Ext0->getOpcode ()), ResultTy(ResultTy),
2734
+ ExtOp0(Ext0->getOpcode ()), ExtOp1(Ext1->getOpcode ()),
2735
+ IsNonNeg0(Ext0->hasNonNegFlag () && Ext0->isNonNeg()), IsNonNeg1(Ext1->hasNonNegFlag () && Ext1->isNonNeg()),
2736
+ ResultTy(ResultTy),
2732
2737
VFScaleFactor(ScaleFactor) {
2733
2738
assert (RecurrenceDescriptor::getOpcode (getRecurrenceKind ()) ==
2734
2739
Instruction::Add &&
2735
2740
" The reduction instruction in MulAccumulateteReductionRecipe must "
2736
2741
" be Add" );
2737
- assert ((ExtOp == Instruction::CastOps::ZExt ||
2738
- ExtOp == Instruction::CastOps::SExt) &&
2742
+ assert (((ExtOp0 == Instruction::CastOps::ZExt ||
2743
+ ExtOp0 == Instruction::CastOps::SExt) && (ExtOp1 == Instruction::CastOps::ZExt || ExtOp1 == Instruction::CastOps::SExt) ) &&
2739
2744
" VPMulAccumulateReductionRecipe only supports zext and sext." );
2740
2745
setUnderlyingValue (R->getUnderlyingValue ());
2741
2746
// Only set the non-negative flag if the original recipe contains.
2742
2747
if (Ext0->hasNonNegFlag ())
2743
- IsNonNeg = Ext0->isNonNeg ();
2748
+ IsNonNeg0 = Ext0->isNonNeg ();
2749
+ if (Ext1->hasNonNegFlag ())
2750
+ IsNonNeg1 = Ext1->isNonNeg ();
2744
2751
}
2745
2752
2746
2753
VPMulAccumulateReductionRecipe (VPReductionRecipe *R, VPWidenRecipe *Mul,
@@ -2751,7 +2758,8 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2751
2758
R->getCondOp (), R->isOrdered(),
2752
2759
WrapFlagsTy(Mul->hasNoUnsignedWrap (), Mul->hasNoSignedWrap()),
2753
2760
R->getDebugLoc()),
2754
- ExtOp(Instruction::CastOps::CastOpsEnd), ResultTy(ResultTy) {
2761
+ ExtOp0(Instruction::CastOps::CastOpsEnd),
2762
+ ExtOp1(Instruction::CastOps::CastOpsEnd), ResultTy(ResultTy) {
2755
2763
assert (RecurrenceDescriptor::getOpcode (getRecurrenceKind ()) ==
2756
2764
Instruction::Add &&
2757
2765
" The reduction instruction in MulAccumulateReductionRecipe must be "
@@ -2792,16 +2800,26 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2792
2800
VPValue *getVecOp1 () const { return getOperand (2 ); }
2793
2801
2794
2802
// / Return true if this recipe contains extended operands.
2795
- bool isExtended () const { return ExtOp != Instruction::CastOps::CastOpsEnd; }
2803
+ bool isExtended () const { return ExtOp0 != Instruction::CastOps::CastOpsEnd; }
2804
+
2805
+ // / Return if the operands of mul instruction come from same extend.
2806
+ bool isSameExtendVal () const { return getVecOp0 () == getVecOp1 (); }
2796
2807
2797
2808
// / Return the opcode of the extends for the operands.
2798
- Instruction::CastOps getExtOpcode () const { return ExtOp; }
2809
+ Instruction::CastOps getExt0Opcode () const { return ExtOp0; }
2810
+ Instruction::CastOps getExt1Opcode () const { return ExtOp1; }
2811
+
2812
+ // / Return if the first extend's opcode is ZExt.
2813
+ bool isZExt0 () const { return ExtOp0 == Instruction::CastOps::ZExt; }
2814
+
2815
+ // / Return if the second extend's opcode is ZExt.
2816
+ bool isZExt1 () const { return ExtOp1 == Instruction::CastOps::ZExt; }
2799
2817
2800
- // / Return if the operands are zero-extended .
2801
- bool isZExt () const { return ExtOp == Instruction::CastOps::ZExt ; }
2818
+ // / Return true if the first operand extend has the non-negative flag .
2819
+ bool isNonNeg0 () const { return IsNonNeg0 ; }
2802
2820
2803
- // / Return true if the operand extends have the non-negative flag.
2804
- bool isNonNeg () const { return IsNonNeg ; }
2821
+ // / Return true if the second operand extend has the non-negative flag.
2822
+ bool isNonNeg1 () const { return IsNonNeg1 ; }
2805
2823
2806
2824
// / Return the scaling factor that the VF is divided by to form the recipe's
2807
2825
// / output
0 commit comments