Skip to content

Commit c244065

Browse files
committed
Clear non-fp FMFs in adjustRecipesForReductions
1 parent eb5082d commit c244065

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9803,9 +9803,13 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
98039803
if (CM.blockNeedsPredicationForAnyReason(BB))
98049804
CondOp = RecipeBuilder.getBlockInMask(BB);
98059805

9806+
// Non-FP RdxDescs will have all fast math flags set, so clear them.
9807+
FastMathFlags FMFs = isa<FPMathOperator>(CurrentLinkI)
9808+
? RdxDesc.getFastMathFlags()
9809+
: FastMathFlags();
98069810
auto *RedRecipe = new VPReductionRecipe(
9807-
RdxDesc.getRecurrenceKind(), RdxDesc.getFastMathFlags(), CurrentLinkI,
9808-
PreviousLink, VecOp, CondOp, CM.useOrderedReductions(RdxDesc),
9811+
RdxDesc.getRecurrenceKind(), FMFs, CurrentLinkI, PreviousLink, VecOp,
9812+
CondOp, CM.useOrderedReductions(RdxDesc),
98099813
CurrentLinkI->getDebugLoc());
98109814
// Append the recipe to the end of the VPBasicBlock because we need to
98119815
// ensure that it comes after all of it's inputs, including CondOp.

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,10 +2250,8 @@ class VPReductionRecipe : public VPRecipeWithIRFlags {
22502250
FastMathFlags FMFs, Instruction *I,
22512251
ArrayRef<VPValue *> Operands, VPValue *CondOp,
22522252
bool IsOrdered, DebugLoc DL)
2253-
: VPRecipeWithIRFlags(
2254-
SC, Operands,
2255-
isa_and_nonnull<FPMathOperator>(I) ? FMFs : FastMathFlags(), DL),
2256-
RdxKind(RdxKind), IsOrdered(IsOrdered) {
2253+
: VPRecipeWithIRFlags(SC, Operands, FMFs, DL), RdxKind(RdxKind),
2254+
IsOrdered(IsOrdered) {
22572255
if (CondOp) {
22582256
IsConditional = true;
22592257
addOperand(CondOp);

0 commit comments

Comments
 (0)