Skip to content

[LV] Get FMFs from VectorBuilder in createSimpleReduction. NFC #132017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/include/llvm/IR/VectorBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class VectorBuilder {
StaticVectorLength = ElementCount::getFixed(NewFixedVL);
return *this;
}

/// Get the flags to be applied to created floating point ops.
const FastMathFlags &getFastMathFlags() const {
return Builder.getFastMathFlags();
}

// TODO: setStaticVL(ElementCount) for scalable types.

// Emit a VP intrinsic call that mimics a regular instruction.
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/Transforms/Utils/LoopUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
RecurKind RdxKind);
/// Overloaded function to generate vector-predication intrinsics for
/// reduction.
Value *createSimpleReduction(VectorBuilder &VB, Value *Src, RecurKind RdxKind,
FastMathFlags FMFs);
Value *createSimpleReduction(VectorBuilder &VB, Value *Src, RecurKind RdxKind);

/// Create a reduction of the given vector \p Src for a reduction of the
/// kind RecurKind::IAnyOf or RecurKind::FAnyOf. The reduction operation is
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Transforms/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,14 +1333,15 @@ Value *llvm::createSimpleReduction(IRBuilderBase &Builder, Value *Src,
}

Value *llvm::createSimpleReduction(VectorBuilder &VBuilder, Value *Src,
RecurKind Kind, FastMathFlags FMFs) {
RecurKind Kind) {
assert(!RecurrenceDescriptor::isAnyOfRecurrenceKind(Kind) &&
!RecurrenceDescriptor::isFindLastIVRecurrenceKind(Kind) &&
"AnyOf or FindLastIV reductions are not supported.");
Intrinsic::ID Id = getReductionIntrinsicID(Kind);
auto *SrcTy = cast<VectorType>(Src->getType());
Type *SrcEltTy = SrcTy->getElementType();
Value *Iden = getRecurrenceIdentity(Kind, SrcEltTy, FMFs);
Value *Iden =
getRecurrenceIdentity(Kind, SrcEltTy, VBuilder.getFastMathFlags());
Value *Ops[] = {Iden, Src};
return VBuilder.createSimpleReduction(Id, SrcTy, Ops);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2358,7 +2358,7 @@ void VPReductionEVLRecipe::execute(VPTransformState &State) {
if (isOrdered()) {
NewRed = createOrderedReduction(VBuilder, Kind, VecOp, Prev);
} else {
NewRed = createSimpleReduction(VBuilder, VecOp, Kind, getFastMathFlags());
NewRed = createSimpleReduction(VBuilder, VecOp, Kind);
if (RecurrenceDescriptor::isMinMaxRecurrenceKind(Kind))
NewRed = createMinMaxOp(Builder, Kind, NewRed, Prev);
else
Expand Down