Skip to content

Commit 01f0425

Browse files
authored
[LV] Get FMFs from VectorBuilder in createSimpleReduction. NFC (llvm#132017)
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.
1 parent 0738f70 commit 01f0425

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

llvm/include/llvm/IR/VectorBuilder.h

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class VectorBuilder {
8787
StaticVectorLength = ElementCount::getFixed(NewFixedVL);
8888
return *this;
8989
}
90+
91+
/// Get the flags to be applied to created floating point ops.
92+
const FastMathFlags &getFastMathFlags() const {
93+
return Builder.getFastMathFlags();
94+
}
95+
9096
// TODO: setStaticVL(ElementCount) for scalable types.
9197

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

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

+1-2
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

+3-2
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

+1-1
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)