[llvm] b8dccb7 - [VPlan] Emit note when UserVF > MaxUserVF (NFCI).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 04:40:43 PDT 2024
Author: Florian Hahn
Date: 2024-08-19T12:40:20+01:00
New Revision: b8dccb7d56c7e32b549c00a094d1b6ac32a01328
URL: https://github.com/llvm/llvm-project/commit/b8dccb7d56c7e32b549c00a094d1b6ac32a01328
DIFF: https://github.com/llvm/llvm-project/commit/b8dccb7d56c7e32b549c00a094d1b6ac32a01328.diff
LOG: [VPlan] Emit note when UserVF > MaxUserVF (NFCI).
As suggested in https://github.com/llvm/llvm-project/pull/103033, add a
remark when the UserVF is ignored due to it being larger than MaxUserVF.
Only changes behavior of diagnostic/debug output.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 05a6c5f36d26eb..0bae9ad1844ec4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7014,27 +7014,32 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
ElementCount MaxUserVF =
UserVF.isScalable() ? MaxFactors.ScalableVF : MaxFactors.FixedVF;
- bool UserVFIsLegal = ElementCount::isKnownLE(UserVF, MaxUserVF);
- if (!UserVF.isZero() && UserVFIsLegal) {
- assert(isPowerOf2_32(UserVF.getKnownMinValue()) &&
- "VF needs to be a power of two");
- // Collect the instructions (and their associated costs) that will be more
- // profitable to scalarize.
- CM.collectInLoopReductions();
- if (CM.selectUserVectorizationFactor(UserVF)) {
- LLVM_DEBUG(dbgs() << "LV: Using user VF " << UserVF << ".\n");
- buildVPlansWithVPRecipes(UserVF, UserVF);
- if (!hasPlanWithVF(UserVF)) {
- LLVM_DEBUG(dbgs() << "LV: No VPlan could be built for " << UserVF
- << ".\n");
- return std::nullopt;
- }
+ if (!UserVF.isZero()) {
+ if (!ElementCount::isKnownLE(UserVF, MaxUserVF)) {
+ reportVectorizationInfo(
+ "UserVF ignored because it may be larger than the maximal safe VF",
+ "InvalidUserVF", ORE, OrigLoop);
+ } else {
+ assert(isPowerOf2_32(UserVF.getKnownMinValue()) &&
+ "VF needs to be a power of two");
+ // Collect the instructions (and their associated costs) that will be more
+ // profitable to scalarize.
+ CM.collectInLoopReductions();
+ if (CM.selectUserVectorizationFactor(UserVF)) {
+ LLVM_DEBUG(dbgs() << "LV: Using user VF " << UserVF << ".\n");
+ buildVPlansWithVPRecipes(UserVF, UserVF);
+ if (!hasPlanWithVF(UserVF)) {
+ LLVM_DEBUG(dbgs()
+ << "LV: No VPlan could be built for " << UserVF << ".\n");
+ return std::nullopt;
+ }
- LLVM_DEBUG(printPlans(dbgs()));
- return {{UserVF, 0, 0}};
- } else
- reportVectorizationInfo("UserVF ignored because of invalid costs.",
- "InvalidCost", ORE, OrigLoop);
+ LLVM_DEBUG(printPlans(dbgs()));
+ return {{UserVF, 0, 0}};
+ } else
+ reportVectorizationInfo("UserVF ignored because of invalid costs.",
+ "InvalidCost", ORE, OrigLoop);
+ }
}
// Collect the Vectorization Factor Candidates.
diff --git a/llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll b/llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll
index 0c9fa742765d31..8104441ad19934 100644
--- a/llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll
+++ b/llvm/test/Transforms/LoopVectorize/unsafe-vf-hint-remark.ll
@@ -14,6 +14,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; CHECK: LV: User VF=4 is unsafe, clamping to max safe VF=2.
; CHECK: remark: <unknown>:0:0: User-specified vectorization factor 4 is unsafe, clamping to maximum safe vectorization factor 2
+; CHECK: remark: <unknown>:0:0: UserVF ignored because it may be larger than the maximal safe VF
; CHECK-LABEL: @foo
; CHECK: <2 x i32>
define void @foo(ptr %a, ptr %b) {
More information about the llvm-commits
mailing list