[llvm] 91d4c0d - Reapply "[VPlan] Compute cost of scalar (U|S)Div, (U|S)Rem in computeCost (NFCI)."
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 14 05:15:58 PDT 2025
Author: Florian Hahn
Date: 2025-09-14T13:15:07+01:00
New Revision: 91d4c0dfdf226665c17d4a44e2fab466e6103d18
URL: https://github.com/llvm/llvm-project/commit/91d4c0dfdf226665c17d4a44e2fab466e6103d18
DIFF: https://github.com/llvm/llvm-project/commit/91d4c0dfdf226665c17d4a44e2fab466e6103d18.diff
LOG: Reapply "[VPlan] Compute cost of scalar (U|S)Div, (U|S)Rem in computeCost (NFCI)."
This reverts commit 9490d58fa92bb338db96af331194c9ba26eb0201.
Recommits de7e3a58952 with a fix for an unhandled case, causing crashes
in some configs.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index c6273074778d1..b72088bf1431e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -3154,6 +3154,19 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
return *getCostForRecipeWithOpcode(getOpcode(), ElementCount::getFixed(1),
Ctx) *
(isSingleScalar() ? 1 : VF.getFixedValue());
+ case Instruction::SDiv:
+ case Instruction::UDiv:
+ case Instruction::SRem:
+ case Instruction::URem: {
+ InstructionCost ScalarCost = *getCostForRecipeWithOpcode(
+ getOpcode(), ElementCount::getFixed(1), Ctx);
+ if (isSingleScalar())
+ return ScalarCost;
+
+ return ScalarCost * VF.getFixedValue() +
+ Ctx.getScalarizationOverhead(Ctx.Types.inferScalarType(this),
+ to_vector(operands()), VF);
+ }
case Instruction::Load:
case Instruction::Store: {
if (isSingleScalar()) {
More information about the llvm-commits
mailing list