[llvm] f5fed78 - [VPlan] Rename VPIRFlags::getFastMathFlags (NFC) (#200487)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 08:13:46 PDT 2026
Author: Ramkumar Ramachandra
Date: 2026-06-08T16:08:16+01:00
New Revision: f5fed78bbe847f7c02fd69c6f33a0f916c8fdadb
URL: https://github.com/llvm/llvm-project/commit/f5fed78bbe847f7c02fd69c6f33a0f916c8fdadb
DIFF: https://github.com/llvm/llvm-project/commit/f5fed78bbe847f7c02fd69c6f33a0f916c8fdadb.diff
LOG: [VPlan] Rename VPIRFlags::getFastMathFlags (NFC) (#200487)
Rename it to getFastMathFlagsOrNone, in line with the recently-landed IR
change 02997d759 ([IR] Introduce Instruction::getFastMathFlagsOrNone,
#200457).
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9b763f0b07def..f146f4638b616 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7017,7 +7017,7 @@ void LoopVectorizationPlanner::addReductionResultComputation(
}
VPIRFlags Flags(RecurrenceKind, PhiR->isOrdered(), PhiR->isInLoop(),
- PhiR->getFastMathFlags());
+ PhiR->getFastMathFlagsOrNone());
FinalReductionResult = Builder.createNaryOp(
VPInstruction::ComputeReductionResult, {ReductionOp}, Flags, ExitDL);
if (ExtendOpc != Instruction::CastOpsEnd)
@@ -7055,7 +7055,7 @@ void LoopVectorizationPlanner::addReductionResultComputation(
!RecurrenceDescriptor::isFindLastRecurrenceKind(RK))) {
VPBuilder PHBuilder(Plan->getVectorPreheader());
VPValue *Iden = Plan->getOrAddLiveIn(
- getRecurrenceIdentity(RK, PhiTy, PhiR->getFastMathFlags()));
+ getRecurrenceIdentity(RK, PhiTy, PhiR->getFastMathFlagsOrNone()));
auto *ScaleFactorVPV = Plan->getConstantInt(32, 1);
VPValue *StartV = PHBuilder.createNaryOp(
VPInstruction::ReductionStartVector,
@@ -7628,7 +7628,7 @@ static SmallVector<Instruction *> preparePlanForEpilogueVectorLoop(
[[maybe_unused]] auto StartValueIsIdentity = [&] {
Value *IdentityValue = getRecurrenceIdentity(
PhiR->getRecurrenceKind(), ResumeV->getType(),
- PhiR->getFastMathFlags());
+ PhiR->getFastMathFlagsOrNone());
auto *StartValue = dyn_cast<VPIRValue>(VPI->getOperand(0));
return StartValue && StartValue->getValue() == IdentityValue;
};
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index c00d199b5e4c4..db6280912a16a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1001,7 +1001,7 @@ class VPIRFlags {
OpType == OperationType::ReductionOp;
}
- LLVM_ABI_FOR_TEST FastMathFlags getFastMathFlags() const;
+ LLVM_ABI_FOR_TEST FastMathFlags getFastMathFlagsOrNone() const;
/// Returns true if the recipe has non-negative flag.
bool hasNonNegFlag() const { return OpType == OperationType::NonNegOp; }
@@ -3291,7 +3291,7 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
~VPReductionRecipe() override = default;
VPReductionRecipe *clone() override {
- return new VPReductionRecipe(RdxKind, getFastMathFlags(),
+ return new VPReductionRecipe(RdxKind, getFastMathFlagsOrNone(),
getUnderlyingInstr(), getChainOp(), getVecOp(),
getCondOp(), Style, getDebugLoc());
}
@@ -3367,7 +3367,7 @@ class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe {
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp,
DebugLoc DL = DebugLoc::getUnknown())
: VPReductionRecipe(VPRecipeBase::VPReductionEVLSC, R.getRecurrenceKind(),
- R.getFastMathFlags(),
+ R.getFastMathFlagsOrNone(),
cast_or_null<Instruction>(R.getUnderlyingValue()),
{R.getChainOp(), R.getVecOp(), &EVL}, CondOp,
getReductionStyle(/*InLoop=*/true, R.isOrdered(), 1),
@@ -4278,9 +4278,9 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags {
~VPScalarIVStepsRecipe() override = default;
VPScalarIVStepsRecipe *clone() override {
- auto *NewR = new VPScalarIVStepsRecipe(getOperand(0), getOperand(1),
- getOperand(2), InductionOpcode,
- getFastMathFlags(), getDebugLoc());
+ auto *NewR = new VPScalarIVStepsRecipe(
+ getOperand(0), getOperand(1), getOperand(2), InductionOpcode,
+ getFastMathFlagsOrNone(), getDebugLoc());
if (VPValue *StartIndex = getStartIndex())
NewR->setStartIndex(StartIndex);
return NewR;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index 55c0b748ade64..aa14c0329be66 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -1108,10 +1108,10 @@ void VPlanTransforms::createInLoopReductionRecipes(VPlan &Plan,
if (IsFPRecurrence) {
FastMathFlags CurFMF =
- cast<VPRecipeWithIRFlags>(CurrentLink)->getFastMathFlags();
+ cast<VPRecipeWithIRFlags>(CurrentLink)->getFastMathFlagsOrNone();
if (match(CurrentLink, m_Select(m_VPValue(), m_VPValue(), m_VPValue())))
CurFMF |= cast<VPRecipeWithIRFlags>(CurrentLink->getOperand(0))
- ->getFastMathFlags();
+ ->getFastMathFlagsOrNone();
FMFs &= CurFMF;
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index f718635691e50..05f145d105b4f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -387,7 +387,7 @@ void VPIRFlags::intersectFlags(const VPIRFlags &Other) {
}
}
-FastMathFlags VPIRFlags::getFastMathFlags() const {
+FastMathFlags VPIRFlags::getFastMathFlagsOrNone() const {
assert((OpType == OperationType::FPMathOp || OpType == OperationType::FCmp ||
OpType == OperationType::ReductionOp ||
OpType == OperationType::Other) &&
@@ -723,7 +723,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
OnlyFirstLaneUsed || vputils::isSingleScalar(getOperand(0)));
Value *Op1 = State.get(getOperand(1), OnlyFirstLaneUsed);
Value *Op2 = State.get(getOperand(2), OnlyFirstLaneUsed);
- return Builder.CreateSelectFMF(Cond, Op1, Op2, getFastMathFlags(), Name);
+ return Builder.CreateSelectFMF(Cond, Op1, Op2, getFastMathFlagsOrNone(),
+ Name);
}
case VPInstruction::ActiveLaneMask: {
// Get first lane of vector induction variable.
@@ -853,7 +854,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
if (State.VF.isScalar())
return State.get(getOperand(0), true);
IRBuilderBase::FastMathFlagGuard FMFG(Builder);
- Builder.setFastMathFlags(getFastMathFlags());
+ Builder.setFastMathFlags(getFastMathFlagsOrNone());
// If this start vector is scaled then it should produce a vector with fewer
// elements than the VF.
ElementCount VF = State.VF.divideCoefficientBy(
@@ -876,7 +877,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
RdxParts[Part] = State.get(getOperand(Part), IsInLoop);
IRBuilderBase::FastMathFlagGuard FMFG(Builder);
- Builder.setFastMathFlags(getFastMathFlags());
+ Builder.setFastMathFlags(getFastMathFlagsOrNone());
// Reduce multiple operands into one.
Value *ReducedPartRdx = RdxParts[0];
@@ -1513,7 +1514,7 @@ void VPInstruction::execute(VPTransformState &State) {
assert(hasRequiredFlagsForOpcode(getOpcode()) &&
"Opcode requires specific flags to be set");
if (hasFastMathFlags())
- State.Builder.setFastMathFlags(getFastMathFlags());
+ State.Builder.setFastMathFlags(getFastMathFlagsOrNone());
Value *GeneratedValue = generate(State);
if (!hasResult())
return;
@@ -2218,7 +2219,7 @@ InstructionCost VPWidenIntrinsicRecipe::computeCallCost(
// TODO: Rework TTI interface to avoid reliance on underlying IntrinsicInst.
IntrinsicCostAttributes CostAttrs(
- ID, RetTy, Arguments, ParamTys, R.getFastMathFlags(),
+ ID, RetTy, Arguments, ParamTys, R.getFastMathFlagsOrNone(),
dyn_cast_or_null<IntrinsicInst>(R.getUnderlyingValue()),
InstructionCost::getInvalid());
return Ctx.TTI.getIntrinsicInstrCost(CostAttrs, Ctx.CostKind);
@@ -2577,7 +2578,7 @@ void VPIRFlags::printFlags(raw_ostream &O) const {
break;
case OperationType::FCmp:
O << " " << CmpInst::getPredicateName(getPredicate());
- getFastMathFlags().print(O);
+ getFastMathFlagsOrNone().print(O);
break;
case OperationType::DisjointOp:
if (DisjointFlags.IsDisjoint)
@@ -2600,7 +2601,7 @@ void VPIRFlags::printFlags(raw_ostream &O) const {
O << " nsw";
break;
case OperationType::FPMathOp:
- getFastMathFlags().print(O);
+ getFastMathFlagsOrNone().print(O);
break;
case OperationType::GEPOp: {
GEPNoWrapFlags Flags = getGEPNoWrapFlags();
@@ -2624,7 +2625,7 @@ void VPIRFlags::printFlags(raw_ostream &O) const {
if (isReductionOrdered())
O << ", ordered";
O << ")";
- getFastMathFlags().print(O);
+ getFastMathFlagsOrNone().print(O);
break;
}
case OperationType::Other:
@@ -2946,7 +2947,7 @@ void VPDerivedIVRecipe::printRecipe(raw_ostream &O, const Twine &Indent,
void VPScalarIVStepsRecipe::execute(VPTransformState &State) {
// Fast-math-flags propagate from the original induction instruction.
IRBuilder<>::FastMathFlagGuard FMFG(State.Builder);
- State.Builder.setFastMathFlags(getFastMathFlags());
+ State.Builder.setFastMathFlags(getFastMathFlagsOrNone());
/// Compute scalar induction steps. \p ScalarIV is the scalar induction
/// variable on which to base the steps, \p Step is the size of the step.
@@ -3206,14 +3207,15 @@ void VPReductionRecipe::execute(VPTransformState &State) {
"In-loop AnyOf reductions aren't currently supported");
// Propagate the fast-math flags carried by the underlying instruction.
IRBuilderBase::FastMathFlagGuard FMFGuard(State.Builder);
- State.Builder.setFastMathFlags(getFastMathFlags());
+ State.Builder.setFastMathFlags(getFastMathFlagsOrNone());
Value *NewVecOp = State.get(getVecOp());
if (VPValue *Cond = getCondOp()) {
Value *NewCond = State.get(Cond, State.VF.isScalar());
VectorType *VecTy = dyn_cast<VectorType>(NewVecOp->getType());
Type *ElementTy = VecTy ? VecTy->getElementType() : NewVecOp->getType();
- Value *Start = getRecurrenceIdentity(Kind, ElementTy, getFastMathFlags());
+ Value *Start =
+ getRecurrenceIdentity(Kind, ElementTy, getFastMathFlagsOrNone());
if (State.VF.isVector())
Start = State.Builder.CreateVectorSplat(VecTy->getElementCount(), Start);
@@ -3265,7 +3267,7 @@ void VPReductionEVLRecipe::execute(VPTransformState &State) {
auto &Builder = State.Builder;
// Propagate the fast-math flags carried by the underlying instruction.
IRBuilderBase::FastMathFlagGuard FMFGuard(Builder);
- Builder.setFastMathFlags(getFastMathFlags());
+ Builder.setFastMathFlags(getFastMathFlagsOrNone());
RecurKind Kind = getRecurrenceKind();
Value *Prev = State.get(getChainOp(), /*IsScalar*/ true);
@@ -3299,7 +3301,7 @@ InstructionCost VPReductionRecipe::computeCost(ElementCount VF,
Type *ElementTy = this->getScalarType();
auto *VectorTy = cast<VectorType>(toVectorTy(ElementTy, VF));
unsigned Opcode = RecurrenceDescriptor::getOpcode(RdxKind);
- FastMathFlags FMFs = getFastMathFlags();
+ FastMathFlags FMFs = getFastMathFlagsOrNone();
std::optional<FastMathFlags> OptionalFMF =
ElementTy->isFloatingPointTy() ? std::make_optional(FMFs) : std::nullopt;
@@ -3434,8 +3436,9 @@ InstructionCost VPExpressionRecipe::computeCost(ElementCount VF,
Opcode, getOperand(0)->getScalarType(), nullptr, RedTy, VF,
TargetTransformInfo::getPartialReductionExtendKind(ExtR->getOpcode()),
TargetTransformInfo::PR_None, std::nullopt, Ctx.CostKind,
- RedTy->isFloatingPointTy() ? std::optional{RedR->getFastMathFlags()}
- : std::nullopt);
+ RedTy->isFloatingPointTy()
+ ? std::optional{RedR->getFastMathFlagsOrNone()}
+ : std::nullopt);
else if (!RedTy->isFloatingPointTy())
// TTI::getExtendedReductionCost only supports integer types.
return Ctx.TTI.getExtendedReductionCost(
@@ -3474,8 +3477,9 @@ InstructionCost VPExpressionRecipe::computeCost(ElementCount VF,
TargetTransformInfo::getPartialReductionExtendKind(
Ext1R->getOpcode()),
Mul->getOpcode(), Ctx.CostKind,
- RedTy->isFloatingPointTy() ? std::optional{RedR->getFastMathFlags()}
- : std::nullopt);
+ RedTy->isFloatingPointTy()
+ ? std::optional{RedR->getFastMathFlagsOrNone()}
+ : std::nullopt);
}
assert(Opcode != Instruction::FSub && "Only integer types are supported");
return Ctx.TTI.getMulAccReductionCost(
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index be09e990b9e3b..f1c59ba43bfa2 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -4184,7 +4184,7 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) {
unsigned MulOpc;
if (IVTy->isFloatingPointTy()) {
MulOpc = Instruction::FMul;
- Flags = VPI->getFastMathFlags();
+ Flags = VPI->getFastMathFlagsOrNone();
} else {
MulOpc = Instruction::Mul;
Flags = VPIRFlags::getDefaultFlags(MulOpc);
@@ -4619,7 +4619,7 @@ tryToMatchAndCreateExtendedReduction(VPReductionRecipe *Red, VPCostContext &Ctx,
"getExtendedReductionCost only supports integer types");
ExtRedCost = Ctx.TTI.getExtendedReductionCost(
Opcode, ExtOpc == Instruction::CastOps::ZExt, RedTy, SrcVecTy,
- Red->getFastMathFlags(), CostKind);
+ Red->getFastMathFlagsOrNone(), CostKind);
return ExtRedCost.isValid() && ExtRedCost < ExtCost + RedCost;
},
Range);
@@ -6489,7 +6489,7 @@ static void transformToPartialReduction(const VPPartialReductionChain &Chain,
PhiType->isFloatingPointTy() ? RecurKind::FAdd : RecurKind::Add;
auto *PartialRed = new VPReductionRecipe(
RdxKind,
- RdxKind == RecurKind::FAdd ? WidenRecipe->getFastMathFlags()
+ RdxKind == RecurKind::FAdd ? WidenRecipe->getFastMathFlagsOrNone()
: FastMathFlags(),
WidenRecipe->getUnderlyingInstr(), Accumulator, ExtendedOp, Cond,
RdxUnordered{/*VFScaleFactor=*/Chain.ScaleFactor});
@@ -6556,7 +6556,7 @@ getPartialReductionLinkCost(VPCostContext &CostCtx,
std::optional<llvm::FastMathFlags> Flags;
if (RdxType->isFloatingPointTy())
- Flags = Link.ReductionBinOp->getFastMathFlags();
+ Flags = Link.ReductionBinOp->getFastMathFlagsOrNone();
auto GetLinkOpcode = [&Link]() -> unsigned {
switch (Link.RK) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
index 4fffcb51374fc..5276aeba2fba0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
@@ -179,7 +179,7 @@ void UnrollState::unrollWidenInductionByUF(
VPIRFlags::WrapFlagsTy WrapFlags(false, false);
if (auto *IntOrFPInd = dyn_cast<VPWidenIntOrFpInductionRecipe>(IV)) {
if (IntOrFPInd->hasFastMathFlags())
- FMF = IntOrFPInd->getFastMathFlags();
+ FMF = IntOrFPInd->getFastMathFlagsOrNone();
if (IntOrFPInd->hasNoWrapFlags())
WrapFlags = IntOrFPInd->getNoWrapFlags();
}
More information about the llvm-commits
mailing list