[llvm] abf5969 - [VPlan] Don't compute costs if there are no vector VPlans.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 00:39:22 PDT 2024


Author: Florian Hahn
Date: 2024-06-24T08:38:31+01:00
New Revision: abf5969f76c6b4196b08fe5ea9c2890e97a61357

URL: https://github.com/llvm/llvm-project/commit/abf5969f76c6b4196b08fe5ea9c2890e97a61357
DIFF: https://github.com/llvm/llvm-project/commit/abf5969f76c6b4196b08fe5ea9c2890e97a61357.diff

LOG: [VPlan] Don't compute costs if there are no vector VPlans.

In some cases, no vector VPlans can be constructed due to failing VPlan
legality checks (e.g. unable to perform sinking for first order
recurrences or plans being incompatible with EVL).

There's no need to compute costs in those cases, so check directly if
there are no vector plans.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    llvm/test/Transforms/LoopVectorize/RISCV/only-compute-cost-for-vplan-vfs.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9571cfe358bf3..771fb247f201f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7294,7 +7294,8 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
   buildVPlansWithVPRecipes(ElementCount::getScalable(1), MaxFactors.ScalableVF);
 
   LLVM_DEBUG(printPlans(dbgs()));
-  if (!MaxFactors.hasVector())
+  if (all_of(VPlans,
+             [](std::unique_ptr<VPlan> &P) { return P->hasScalarVFOnly(); }))
     return VectorizationFactor::Disabled();
 
   // Select the optimal vectorization factor.

diff  --git a/llvm/test/Transforms/LoopVectorize/RISCV/only-compute-cost-for-vplan-vfs.ll b/llvm/test/Transforms/LoopVectorize/RISCV/only-compute-cost-for-vplan-vfs.ll
index da44245578403..f404b89492886 100644
--- a/llvm/test/Transforms/LoopVectorize/RISCV/only-compute-cost-for-vplan-vfs.ll
+++ b/llvm/test/Transforms/LoopVectorize/RISCV/only-compute-cost-for-vplan-vfs.ll
@@ -5,9 +5,8 @@
 ; REQUIRES: asserts
 
 ; Make sure we do not vectorize a loop with a widened int induction.
-; TODO: There's no need to compute costs for any VF, as no VPlans have been generated.
 define void @test_wide_integer_induction(ptr noalias %a, i64 %N) {
-; CHECK: LV: Vector loop of width {{.+}} costs:
+; CHECK-NOT: LV: Vector loop of width {{.+}} costs:
 ;
 ; CHECK: define void @test_wide_integer_induction(
 ; CHECK-NOT: vector.body


        


More information about the llvm-commits mailing list