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