Skip to content

Commit 9e815ce

Browse files
committed
[LV] Get FMFs from VectorBuilder in createSimpleReduction. NFC
The other createSimpleReduction takes the FMFs from the IRBuilder, so this aligns the VectorBuilder variant to do the same and reduce the possibility of there being a mismatch in flags. Stacked on #132014
1 parent 824559b commit 9e815ce

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

llvm/include/llvm/IR/VectorBuilder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ class VectorBuilder {
8787
StaticVectorLength = ElementCount::getFixed(NewFixedVL);
8888
return *this;
8989
}
90+
91+
FastMathFlags &getFastMathFlags() const { return Builder.getFastMathFlags(); }
92+
9093
// TODO: setStaticVL(ElementCount) for scalable types.
9194

9295
// Emit a VP intrinsic call that mimics a regular instruction.

llvm/include/llvm/Transforms/Utils/LoopUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
411411
RecurKind RdxKind);
412412
/// Overloaded function to generate vector-predication intrinsics for
413413
/// reduction.
414-
Value *createSimpleReduction(VectorBuilder &VB, Value *Src, RecurKind RdxKind,
415-
FastMathFlags FMFs);
414+
Value *createSimpleReduction(VectorBuilder &VB, Value *Src, RecurKind RdxKind);
416415

417416
/// Create a reduction of the given vector \p Src for a reduction of the
418417
/// kind RecurKind::IAnyOf or RecurKind::FAnyOf. The reduction operation is

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,14 +1333,15 @@ Value *llvm::createSimpleReduction(IRBuilderBase &Builder, Value *Src,
13331333
}
13341334

13351335
Value *llvm::createSimpleReduction(VectorBuilder &VBuilder, Value *Src,
1336-
RecurKind Kind, FastMathFlags FMFs) {
1336+
RecurKind Kind) {
13371337
assert(!RecurrenceDescriptor::isAnyOfRecurrenceKind(Kind) &&
13381338
!RecurrenceDescriptor::isFindLastIVRecurrenceKind(Kind) &&
13391339
"AnyOf or FindLastIV reductions are not supported.");
13401340
Intrinsic::ID Id = getReductionIntrinsicID(Kind);
13411341
auto *SrcTy = cast<VectorType>(Src->getType());
13421342
Type *SrcEltTy = SrcTy->getElementType();
1343-
Value *Iden = getRecurrenceIdentity(Kind, SrcEltTy, FMFs);
1343+
Value *Iden =
1344+
getRecurrenceIdentity(Kind, SrcEltTy, VBuilder.getFastMathFlags());
13441345
Value *Ops[] = {Iden, Src};
13451346
return VBuilder.createSimpleReduction(Id, SrcTy, Ops);
13461347
}

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2358,7 +2358,7 @@ void VPReductionEVLRecipe::execute(VPTransformState &State) {
23582358
if (isOrdered()) {
23592359
NewRed = createOrderedReduction(VBuilder, Kind, VecOp, Prev);
23602360
} else {
2361-
NewRed = createSimpleReduction(VBuilder, VecOp, Kind, getFastMathFlags());
2361+
NewRed = createSimpleReduction(VBuilder, VecOp, Kind);
23622362
if (RecurrenceDescriptor::isMinMaxRecurrenceKind(Kind))
23632363
NewRed = createMinMaxOp(Builder, Kind, NewRed, Prev);
23642364
else

0 commit comments

Comments
 (0)