@@ -713,6 +713,8 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
713
713
R->getVPDefID () == VPRecipeBase::VPWidenGEPSC ||
714
714
R->getVPDefID () == VPRecipeBase::VPWidenCastSC ||
715
715
R->getVPDefID () == VPRecipeBase::VPWidenIntrinsicSC ||
716
+ R->getVPDefID () == VPRecipeBase::VPReductionSC ||
717
+ R->getVPDefID () == VPRecipeBase::VPReductionEVLSC ||
716
718
R->getVPDefID () == VPRecipeBase::VPReplicateSC ||
717
719
R->getVPDefID () == VPRecipeBase::VPReverseVectorPointerSC ||
718
720
R->getVPDefID () == VPRecipeBase::VPVectorPointerSC;
@@ -788,6 +790,12 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
788
790
}
789
791
}
790
792
793
+ // / Set fast-math flags for this recipe.
794
+ void setFastMathFlags (FastMathFlags FMFs) {
795
+ OpType = OperationType::FPMathOp;
796
+ this ->FMFs = FMFs;
797
+ }
798
+
791
799
CmpInst::Predicate getPredicate () const {
792
800
assert (OpType == OperationType::Cmp &&
793
801
" recipe doesn't have a compare predicate" );
@@ -2286,7 +2294,7 @@ class VPInterleaveRecipe : public VPRecipeBase {
2286
2294
// / A recipe to represent inloop reduction operations, performing a reduction on
2287
2295
// / a vector operand into a scalar value, and adding the result to a chain.
2288
2296
// / The Operands are {ChainOp, VecOp, [Condition]}.
2289
- class VPReductionRecipe : public VPSingleDefRecipe {
2297
+ class VPReductionRecipe : public VPRecipeWithIRFlags {
2290
2298
// / The recurrence decriptor for the reduction in question.
2291
2299
const RecurrenceDescriptor &RdxDesc;
2292
2300
bool IsOrdered;
@@ -2296,29 +2304,32 @@ class VPReductionRecipe : public VPSingleDefRecipe {
2296
2304
protected:
2297
2305
VPReductionRecipe (const unsigned char SC, const RecurrenceDescriptor &R,
2298
2306
Instruction *I, ArrayRef<VPValue *> Operands,
2299
- VPValue *CondOp, bool IsOrdered, DebugLoc DL )
2300
- : VPSingleDefRecipe (SC, Operands, I, DL ), RdxDesc(R),
2307
+ VPValue *CondOp, bool IsOrdered)
2308
+ : VPRecipeWithIRFlags (SC, Operands, *I ), RdxDesc(R),
2301
2309
IsOrdered (IsOrdered) {
2302
2310
if (CondOp) {
2303
2311
IsConditional = true ;
2304
2312
addOperand (CondOp);
2305
2313
}
2314
+ // The inloop reduction may across multiple scalar instruction and the
2315
+ // underlying instruction may not contains the corresponding flags. Set the
2316
+ // flags explicit from the redurrence descriptor.
2317
+ setFastMathFlags (R.getFastMathFlags ());
2306
2318
}
2307
2319
2308
2320
public:
2309
2321
VPReductionRecipe (const RecurrenceDescriptor &R, Instruction *I,
2310
2322
VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp,
2311
- bool IsOrdered, DebugLoc DL = {} )
2323
+ bool IsOrdered)
2312
2324
: VPReductionRecipe(VPDef::VPReductionSC, R, I,
2313
2325
ArrayRef<VPValue *>({ChainOp, VecOp}), CondOp,
2314
- IsOrdered, DL ) {}
2326
+ IsOrdered) {}
2315
2327
2316
2328
~VPReductionRecipe () override = default ;
2317
2329
2318
2330
VPReductionRecipe *clone () override {
2319
2331
return new VPReductionRecipe (RdxDesc, getUnderlyingInstr (), getChainOp (),
2320
- getVecOp (), getCondOp (), IsOrdered,
2321
- getDebugLoc ());
2332
+ getVecOp (), getCondOp (), IsOrdered);
2322
2333
}
2323
2334
2324
2335
static inline bool classof (const VPRecipeBase *R) {
@@ -2373,7 +2384,7 @@ class VPReductionEVLRecipe : public VPReductionRecipe {
2373
2384
VPDef::VPReductionEVLSC, R.getRecurrenceDescriptor(),
2374
2385
cast_or_null<Instruction>(R.getUnderlyingValue()),
2375
2386
ArrayRef<VPValue *>({R.getChainOp (), R.getVecOp (), &EVL}), CondOp,
2376
- R.isOrdered(), R.getDebugLoc() ) {}
2387
+ R.isOrdered()) {}
2377
2388
2378
2389
~VPReductionEVLRecipe () override = default ;
2379
2390
0 commit comments