@@ -2115,14 +2115,18 @@ class VPReductionRecipe : public VPSingleDefRecipe {
2115
2115
// / The recurrence decriptor for the reduction in question.
2116
2116
const RecurrenceDescriptor &RdxDesc;
2117
2117
bool IsOrdered;
2118
+ // / Whether the reduction is conditional.
2119
+ bool IsConditional = false ;
2118
2120
2119
2121
protected:
2120
2122
VPReductionRecipe (const unsigned char SC, const RecurrenceDescriptor &R,
2121
2123
Instruction *I, ArrayRef<VPValue *> Operands,
2122
2124
VPValue *CondOp, bool IsOrdered)
2123
2125
: VPSingleDefRecipe(SC, Operands, I), RdxDesc(R), IsOrdered(IsOrdered) {
2124
- if (CondOp)
2126
+ if (CondOp) {
2127
+ IsConditional = true ;
2125
2128
addOperand (CondOp);
2129
+ }
2126
2130
}
2127
2131
2128
2132
public:
@@ -2165,13 +2169,15 @@ class VPReductionRecipe : public VPSingleDefRecipe {
2165
2169
}
2166
2170
// / Return true if the in-loop reduction is ordered.
2167
2171
bool isOrdered () const { return IsOrdered; };
2172
+ // / Return true if the in-loop reduction is conditional.
2173
+ bool isConditional () const { return IsConditional; };
2168
2174
// / The VPValue of the scalar Chain being accumulated.
2169
2175
VPValue *getChainOp () const { return getOperand (0 ); }
2170
2176
// / The VPValue of the vector value to be reduced.
2171
2177
VPValue *getVecOp () const { return getOperand (1 ); }
2172
2178
// / The VPValue of the condition for the block.
2173
- virtual VPValue *getCondOp () const {
2174
- return getNumOperands () > 2 ? getOperand (2 ) : nullptr ;
2179
+ VPValue *getCondOp () const {
2180
+ return isConditional () ? getOperand (getNumOperands () - 1 ) : nullptr ;
2175
2181
}
2176
2182
};
2177
2183
@@ -2207,10 +2213,6 @@ class VPReductionEVLRecipe : public VPReductionRecipe {
2207
2213
2208
2214
// / The VPValue of the explicit vector length.
2209
2215
VPValue *getEVL () const { return getOperand (2 ); }
2210
- // / The VPValue of the condition for the block.
2211
- VPValue *getCondOp () const override {
2212
- return getNumOperands () > 3 ? getOperand (3 ) : nullptr ;
2213
- }
2214
2216
2215
2217
// / Returns true if the recipe only uses the first lane of operand \p Op.
2216
2218
bool onlyFirstLaneUsed (const VPValue *Op) const override {
0 commit comments