[llvm] [LV] Fix missing precomptueCosts() in emitInvalidCostRemarks(). (PR #114918)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 23:48:46 PST 2024
https://github.com/ElvisWang123 updated https://github.com/llvm/llvm-project/pull/114918
>From e33b7f0fad655241d9fd1cd5c49a41f5cc6ced47 Mon Sep 17 00:00:00 2001
From: Elvis Wang <elvis.wang at sifive.com>
Date: Mon, 4 Nov 2024 18:58:20 -0800
Subject: [PATCH] [LV] Fix missing precomptueCosts() in
emitInvalidCostRemarks().
We should always update the SkipComputation set in VPCostContext before VPlan.cost().
This patch prevent assertion of in-loop reduction in the `VPReductionRecipe::computeCost()` and other
potentail assertions of partially implemented VPlan-based cost model.
---
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 1 +
llvm/test/Transforms/LoopVectorize/reduction-inloop.ll | 2 ++
2 files changed, 3 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 1ebc62f9843905..ae438281236bd6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4363,6 +4363,7 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
for (ElementCount VF : Plan->vectorFactors()) {
VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(),
CM);
+ precomputeCosts(*Plan, VF, CostCtx);
auto Iter = vp_depth_first_deep(Plan->getVectorLoopRegion()->getEntry());
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) {
for (auto &R : *VPBB) {
diff --git a/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll b/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll
index fe74a7c3a9b27c..0967950d1563eb 100644
--- a/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll
+++ b/llvm/test/Transforms/LoopVectorize/reduction-inloop.ll
@@ -1,5 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -prefer-inloop-reductions -S | FileCheck %s
+; Check remark analysis runs successfully.
+; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -prefer-inloop-reductions -pass-remarks-analysis=loop-vectorize -S
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
More information about the llvm-commits
mailing list