@@ -2172,14 +2172,18 @@ class VPReductionRecipe : public VPSingleDefRecipe {
2172
2172
// / The recurrence decriptor for the reduction in question.
2173
2173
const RecurrenceDescriptor &RdxDesc;
2174
2174
bool IsOrdered;
2175
+ // / Whether the reduction is conditional.
2176
+ bool IsConditional = false ;
2175
2177
2176
2178
protected:
2177
2179
VPReductionRecipe (const unsigned char SC, const RecurrenceDescriptor &R,
2178
2180
Instruction *I, ArrayRef<VPValue *> Operands,
2179
2181
VPValue *CondOp, bool IsOrdered)
2180
2182
: VPSingleDefRecipe(SC, Operands, I), RdxDesc(R), IsOrdered(IsOrdered) {
2181
- if (CondOp)
2183
+ if (CondOp) {
2184
+ IsConditional = true ;
2182
2185
addOperand (CondOp);
2186
+ }
2183
2187
}
2184
2188
2185
2189
public:
@@ -2222,13 +2226,15 @@ class VPReductionRecipe : public VPSingleDefRecipe {
2222
2226
}
2223
2227
// / Return true if the in-loop reduction is ordered.
2224
2228
bool isOrdered () const { return IsOrdered; };
2229
+ // / Return true if the in-loop reduction is conditional.
2230
+ bool isConditional () const { return IsConditional; };
2225
2231
// / The VPValue of the scalar Chain being accumulated.
2226
2232
VPValue *getChainOp () const { return getOperand (0 ); }
2227
2233
// / The VPValue of the vector value to be reduced.
2228
2234
VPValue *getVecOp () const { return getOperand (1 ); }
2229
2235
// / The VPValue of the condition for the block.
2230
- virtual VPValue *getCondOp () const {
2231
- return getNumOperands () > 2 ? getOperand (2 ) : nullptr ;
2236
+ VPValue *getCondOp () const {
2237
+ return isConditional () ? getOperand (getNumOperands () - 1 ) : nullptr ;
2232
2238
}
2233
2239
};
2234
2240
@@ -2264,10 +2270,6 @@ class VPReductionEVLRecipe : public VPReductionRecipe {
2264
2270
2265
2271
// / The VPValue of the explicit vector length.
2266
2272
VPValue *getEVL () const { return getOperand (2 ); }
2267
- // / The VPValue of the condition for the block.
2268
- VPValue *getCondOp () const override {
2269
- return getNumOperands () > 3 ? getOperand (3 ) : nullptr ;
2270
- }
2271
2273
2272
2274
// / Returns true if the recipe only uses the first lane of operand \p Op.
2273
2275
bool onlyFirstLaneUsed (const VPValue *Op) const override {
0 commit comments