[llvm] [LV] Prevent query the computeCost() when VF=1 in emitInvalidCostRemarks(). (PR #117288)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 15:34:12 PST 2024
https://github.com/ElvisWang123 updated https://github.com/llvm/llvm-project/pull/117288
>From 2e9579df67c5ab62a7133649dc329f8abe5a669c Mon Sep 17 00:00:00 2001
From: Elvis Wang <elvis.wang at sifive.com>
Date: Thu, 21 Nov 2024 21:02:55 -0800
Subject: [PATCH 1/2] [LV] Prevent query the computeCost() when VF=1 in
emitInvalidCostRemarks().
---
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 90312c1a28df3c..6db52aad9625f9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4372,6 +4372,9 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
SmallVector<RecipeVFPair> InvalidCosts;
for (const auto &Plan : VPlans) {
for (ElementCount VF : Plan->vectorFactors()) {
+ if (VF.isScalar())
+ continue;
+
VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(),
CM);
precomputeCosts(*Plan, VF, CostCtx);
>From f30cdb01be0fda35224afe6562699c7a9eb9ecad Mon Sep 17 00:00:00 2001
From: Elvis Wang <elvis.wang at sifive.com>
Date: Thu, 12 Dec 2024 15:33:02 -0800
Subject: [PATCH 2/2] Add comments to explain why we skip scalar cost.
---
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6db52aad9625f9..cc30d94f7c5037 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4372,6 +4372,9 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
SmallVector<RecipeVFPair> InvalidCosts;
for (const auto &Plan : VPlans) {
for (ElementCount VF : Plan->vectorFactors()) {
+ // The VPlan-based cost model is designed for computing vector cost.
+ // Quering VPlan-based cost model with scarlar VF will cause some error
+ // because we expect the VF is vector for most of the widen recipes.
if (VF.isScalar())
continue;
More information about the llvm-commits
mailing list