@@ -2689,13 +2689,6 @@ 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
- // / Opcodes of the extend recipes.
2693
- Instruction::CastOps ExtOp0;
2694
- Instruction::CastOps ExtOp1;
2695
-
2696
- // / Non-neg flags of the extend recipe.
2697
- bool IsNonNeg0 = false ;
2698
- bool IsNonNeg1 = false ;
2699
2692
2700
2693
// / The scalar type after extending.
2701
2694
Type *ResultTy = nullptr ;
@@ -2712,12 +2705,12 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2712
2705
MulAcc->getCondOp (), MulAcc->isOrdered(),
2713
2706
WrapFlagsTy(MulAcc->hasNoUnsignedWrap (), MulAcc->hasNoSignedWrap()),
2714
2707
MulAcc->getDebugLoc()),
2715
- ExtOp0(MulAcc->getExt0Opcode ()), ExtOp1(MulAcc->getExt1Opcode ()),
2716
- IsNonNeg0(MulAcc->isNonNeg0 ()), IsNonNeg1(MulAcc->isNonNeg1 ()),
2717
2708
ResultTy(MulAcc->getResultType ()),
2718
2709
VFScaleFactor(MulAcc->getVFScaleFactor ()) {
2719
2710
transferFlags (*MulAcc);
2720
2711
setUnderlyingValue (MulAcc->getUnderlyingValue ());
2712
+ VecOpInfo[0 ] = MulAcc->getVecOp0Info ();
2713
+ VecOpInfo[1 ] = MulAcc->getVecOp1Info ();
2721
2714
}
2722
2715
2723
2716
public:
@@ -2731,23 +2724,22 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2731
2724
R->getCondOp (), R->isOrdered(),
2732
2725
WrapFlagsTy(Mul->hasNoUnsignedWrap (), Mul->hasNoSignedWrap()),
2733
2726
R->getDebugLoc()),
2734
- ExtOp0(Ext0->getOpcode ()), ExtOp1(Ext1->getOpcode ()),
2735
- IsNonNeg0(Ext0->hasNonNegFlag () && Ext0->isNonNeg()), IsNonNeg1(Ext1->hasNonNegFlag () && Ext1->isNonNeg()),
2736
- ResultTy(ResultTy),
2737
- VFScaleFactor(ScaleFactor) {
2727
+ ResultTy(ResultTy), VFScaleFactor(ScaleFactor) {
2738
2728
assert (RecurrenceDescriptor::getOpcode (getRecurrenceKind ()) ==
2739
2729
Instruction::Add &&
2740
2730
" The reduction instruction in MulAccumulateteReductionRecipe must "
2741
2731
" be Add" );
2742
- assert (((ExtOp0 == Instruction::CastOps::ZExt ||
2743
- ExtOp0 == Instruction::CastOps::SExt) && (ExtOp1 == Instruction::CastOps::ZExt || ExtOp1 == Instruction::CastOps::SExt)) &&
2744
- " VPMulAccumulateReductionRecipe only supports zext and sext." );
2745
2732
setUnderlyingValue (R->getUnderlyingValue ());
2746
- // Only set the non-negative flag if the original recipe contains.
2747
- if (Ext0->hasNonNegFlag ())
2748
- IsNonNeg0 = Ext0->isNonNeg ();
2749
- if (Ext1->hasNonNegFlag ())
2750
- IsNonNeg1 = Ext1->isNonNeg ();
2733
+ // Only set the non-negative flag if the original recipe contains one.
2734
+ VecOpInfo[0 ] = {Ext0->getOpcode (),
2735
+ Ext0->hasNonNegFlag () && Ext0->isNonNeg ()};
2736
+ VecOpInfo[1 ] = {Ext1->getOpcode (),
2737
+ Ext1->hasNonNegFlag () && Ext1->isNonNeg ()};
2738
+ assert (((Ext0->getOpcode () == Instruction::CastOps::ZExt ||
2739
+ Ext0->getOpcode () == Instruction::CastOps::SExt) &&
2740
+ (Ext1->getOpcode () == Instruction::CastOps::ZExt ||
2741
+ Ext1->getOpcode () == Instruction::CastOps::SExt)) &&
2742
+ " VPMulAccumulateReductionRecipe only supports zext and sext." );
2751
2743
}
2752
2744
2753
2745
VPMulAccumulateReductionRecipe (VPReductionRecipe *R, VPWidenRecipe *Mul,
@@ -2758,15 +2750,21 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2758
2750
R->getCondOp (), R->isOrdered(),
2759
2751
WrapFlagsTy(Mul->hasNoUnsignedWrap (), Mul->hasNoSignedWrap()),
2760
2752
R->getDebugLoc()),
2761
- ExtOp0(Instruction::CastOps::CastOpsEnd),
2762
- ExtOp1(Instruction::CastOps::CastOpsEnd), ResultTy(ResultTy) {
2753
+ ResultTy(ResultTy) {
2763
2754
assert (RecurrenceDescriptor::getOpcode (getRecurrenceKind ()) ==
2764
2755
Instruction::Add &&
2765
2756
" The reduction instruction in MulAccumulateReductionRecipe must be "
2766
2757
" Add" );
2767
2758
setUnderlyingValue (R->getUnderlyingValue ());
2768
2759
}
2769
2760
2761
+ struct VecOperandInfo {
2762
+ // / The operand's extend opcode.
2763
+ Instruction::CastOps ExtOp{Instruction::CastOps::CastOpsEnd};
2764
+ // / Non-neg portion of the operand's flags.
2765
+ bool IsNonNeg = false ;
2766
+ };
2767
+
2770
2768
~VPMulAccumulateReductionRecipe () override = default ;
2771
2769
2772
2770
VPMulAccumulateReductionRecipe *clone () override {
@@ -2800,30 +2798,22 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
2800
2798
VPValue *getVecOp1 () const { return getOperand (2 ); }
2801
2799
2802
2800
// / Return true if this recipe contains extended operands.
2803
- bool isExtended () const { return ExtOp0 != Instruction::CastOps::CastOpsEnd; }
2801
+ bool isExtended () const {
2802
+ return getVecOp0Info ().ExtOp != Instruction::CastOps::CastOpsEnd;
2803
+ }
2804
2804
2805
2805
// / Return if the operands of mul instruction come from same extend.
2806
2806
bool isSameExtendVal () const { return getVecOp0 () == getVecOp1 (); }
2807
2807
2808
- // / Return the opcode of the extends for the operands.
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; }
2817
-
2818
- // / Return true if the first operand extend has the non-negative flag.
2819
- bool isNonNeg0 () const { return IsNonNeg0; }
2820
-
2821
- // / Return true if the second operand extend has the non-negative flag.
2822
- bool isNonNeg1 () const { return IsNonNeg1; }
2823
-
2824
2808
// / Return the scaling factor that the VF is divided by to form the recipe's
2825
2809
// / output
2826
2810
unsigned getVFScaleFactor () const { return VFScaleFactor; }
2811
+
2812
+ VecOperandInfo getVecOp0Info () const { return VecOpInfo[0 ]; }
2813
+ VecOperandInfo getVecOp1Info () const { return VecOpInfo[1 ]; }
2814
+
2815
+ protected:
2816
+ VecOperandInfo VecOpInfo[2 ];
2827
2817
};
2828
2818
2829
2819
// / VPReplicateRecipe replicates a given instruction producing multiple scalar
0 commit comments