[llvm] [LV] Fix emission of debug message in legality check (PR #101924)
Madhur Amilkanthwar via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 4 23:19:39 PDT 2024
https://github.com/madhur13490 created https://github.com/llvm/llvm-project/pull/101924
Successful vectorization message is emitted even
after "Result" is false. "Result" = false indicates failure of one of the legality check and thus
successful message should not be printed.
>From 6782629300d8e25bab09a588b4650c569c9c642e Mon Sep 17 00:00:00 2001
From: Madhur Amilkanthwar <madhura at nvidia.com>
Date: Wed, 31 Jul 2024 22:17:56 +0530
Subject: [PATCH] [LV] Fix emission of debug message in legality check
Successful vectorization message is emitted even
after "Result" is false. "Result" = false indicates
failure of one of the legality check and thus
successful message should not be printed.
---
.../Vectorize/LoopVectorizationLegality.cpp | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 465d0df30e3f7..35c841f470261 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1441,10 +1441,12 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
// Check whether the loop-related control flow in the loop nest is expected by
// vectorizer.
if (!canVectorizeLoopNestCFG(TheLoop, UseVPlanNativePath)) {
- if (DoExtraAnalysis)
+ if (DoExtraAnalysis) {
+ LLVM_DEBUG(dbgs() << "LV legality check failed: loop nest");
Result = false;
- else
+ } else {
return false;
+ }
}
// We need to have a loop header.
@@ -1509,11 +1511,6 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
return false;
}
- LLVM_DEBUG(dbgs() << "LV: We can vectorize this loop"
- << (LAI->getRuntimePointerChecking()->Need
- ? " (with a runtime bound check)"
- : "")
- << "!\n");
unsigned SCEVThreshold = VectorizeSCEVCheckThreshold;
if (Hints->getForce() == LoopVectorizeHints::FK_Enabled)
@@ -1528,6 +1525,13 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
else
return false;
}
+ if (Result) {
+ LLVM_DEBUG(dbgs() << "LV: We can vectorize this loop"
+ << (LAI->getRuntimePointerChecking()->Need
+ ? " (with a runtime bound check)"
+ : "")
+ << "!\n");
+ }
// Okay! We've done all the tests. If any have failed, return false. Otherwise
// we can vectorize, and at this point we don't have any other mem analysis
More information about the llvm-commits
mailing list