-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LV] Emit better debug and opt-report messages when vectorization is disallowed in the LoopVectorizer #158513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TiborGY
wants to merge
35
commits into
llvm:main
Choose a base branch
from
TiborGY:lvmsg_disabled
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+127
−4
Open
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
81f1800
Emit better debug and opt-report messages when vectorization is disal…
6d941ff
Trafo -> Transforms
c0e6aec
Testing part 1: explicitly disabled code path
c290bec
Testing part 2: VectorizeOnlyWhenForced code path
109b3fd
Rename the two new tests so far to begin with diag-
3c4c8de
Testing part 3: hasDisableAllTransformsHint code path
fa19ccc
fix test 3
29d1fa2
use [BUG] instead of [FIXME] in the sanity check fail debug msg
117c358
Clean up function name and remove excessive attributes from Test 1 an…
2241343
Try combining Test1 and Test2 into one file
98a90e9
Address IR review pt1: datalayout
TiborGY 55af5ac
Address IR review pt2: use llvm_unreachable
120a5bf
Address IR review pt3: only 1 load
a509ea9
Address IR review pt4: exit block
bc68571
Refactor the printing of the new messages
c6a624d
fix
d4f407b
update message in tests
5d656e8
give test fn a more descriptive name
0a933b2
Address IR review pt5: simplify entry block of disable_nonforced
6dfffe8
Address IR review pt6: simplify some variable and label names
936d9e3
Apply suggestions from code review
TiborGY b895a97
update check-nots as the message was removed in favor of llvm_unreach…
8173da8
fix test
835f8f0
try simplifying disabled_loop_vectorization test fn to constant store
7f9fe50
fix return type
552a8ab
try moving Test3 into the same file as Test 1&2
dcd926f
somehow a suggestion did not apply
86515c5
More reviewer suggestions, pt1
5f7c8b0
use CHECK-LABEL
96d6136
fix check-label
6c1932e
shorten loop control flow labels
8e0c12b
shorten %indvars.iv to %iv, make it 32 bits to remove truncates and s…
1ec46e8
group all RUN lines at the top, reduce check duplication between Test…
f530fd5
remove dump-input from FileCheck lines
60f86af
perform all checks on the second fn with all three RUN lines, also pe…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| ; REQUIRES: asserts | ||
|
|
||
| ; TEST 1 | ||
| ; Checks that we emit only the correct debug messages and | ||
| ; optimization remark when the loop vectorizer is disabled by loop metadata. | ||
| ; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \ | ||
| ; RUN: -pass-remarks-missed=loop-vectorize \ | ||
| ; RUN: -pass-remarks-analysis=loop-vectorize -debug \ | ||
| ; RUN: < %s 2>&1 | FileCheck --check-prefixes=METADATA,BOTH %s | ||
| ; TEST 2 | ||
| ; Checks that we emit only the correct debug messages and | ||
| ; optimization remark when the loop is not vectorized due to the | ||
| ; vectorize-forced-only pass option being set. | ||
| ; Strip metadata for FORCEDONLY run, keep it for METADATA run | ||
| ; RUN: sed 's/,[[:space:]]*!llvm\.loop[[:space:]]*!0//' %s | \ | ||
| ; RUN: opt -S -passes='loop-vectorize<vectorize-forced-only>' \ | ||
| ; RUN: -pass-remarks=loop-vectorize \ | ||
| ; RUN: -pass-remarks-missed=loop-vectorize \ | ||
| ; RUN: -pass-remarks-analysis=loop-vectorize -debug \ | ||
| ; RUN: 2>&1 | FileCheck --check-prefixes=FORCEDONLY,BOTH %s | ||
| ; TEST 3 | ||
| ; Checks that we emit only the correct debug messages and | ||
| ; optimization remark when the loop vectorizer is disabled by loop metadata | ||
| ; that requests no loop transformations. | ||
| ; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \ | ||
| ; RUN: -pass-remarks-missed=loop-vectorize \ | ||
| ; RUN: -pass-remarks-analysis=loop-vectorize -debug \ | ||
| ; RUN: -force-vector-interleave=1 -force-vector-width=2 \ | ||
| ; RUN: < %s 2>&1 | FileCheck %s | ||
|
|
||
| ; BOTH-LABEL: 'disabled_loop_vectorization' from <stdin> | ||
| ; BOTH-NOT: LV: We can vectorize this loop | ||
| ; BOTH-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint | ||
| ; BOTH-NOT: LV: Not vectorizing: Disabled/already vectorized | ||
| ; BOTH-NOT: LV: Not vectorizing: Cannot prove legality | ||
| ; | ||
| ; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set | ||
| ; METADATA: LV: Loop hints: force=disabled | ||
| ; METADATA: LV: Not vectorizing: #pragma vectorize disable. | ||
| ; METADATA: remark: | ||
| ; METADATA-SAME: loop not vectorized: vectorization is explicitly disabled | ||
| ; | ||
| ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable | ||
| ; FORCEDONLY: LV: Loop hints: force=? | ||
| ; FORCEDONLY: LV: Not vectorizing: VectorizeOnlyWhenForced is set, and no #pragma vectorize enable | ||
| ; FORCEDONLY: remark: | ||
| ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it | ||
| ; | ||
| ; BOTH: LV: Loop hints prevent vectorization | ||
| define void @disabled_loop_vectorization(ptr %src) { | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: | ||
| %iv = phi i64 [ 0, %entry ], [ %inc, %loop ] | ||
| %arrayidx = getelementptr inbounds nuw double, ptr %src, i64 %iv | ||
| store double 0.0, ptr %arrayidx, align 8 | ||
| %inc = add nuw nsw i64 %iv, 1 | ||
| %exitcond.not = icmp eq i64 %inc, 15 | ||
| br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !0 | ||
|
|
||
| exit: | ||
| ret void | ||
| } | ||
| !0 = distinct !{!0, !1} | ||
| !1 = !{!"llvm.loop.vectorize.enable", i1 false} | ||
|
|
||
| ; CHECK-LABEL: 'disable_nonforced' from <stdin> | ||
| ; CHECK-NOT: LV: We can vectorize this loop | ||
| ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable. | ||
| ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set | ||
| ; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized | ||
| ; CHECK-NOT: LV: Not vectorizing: Cannot prove legality | ||
| ; CHECK: LV: Loop hints: force=disabled | ||
| ; CHECK: LV: Not vectorizing: loop hasDisableAllTransformsHint. | ||
| ; CHECK: remark: | ||
| ; CHECK-SAME: loop not vectorized: loop transformations are disabled | ||
| ; CHECK: LV: Loop hints prevent vectorization | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| define void @disable_nonforced(ptr nocapture %a, i32 %n) { | ||
| entry: | ||
| br label %loop | ||
|
|
||
| loop: | ||
| %iv = phi i32 [ %iv.next, %loop ], [ 0, %entry ] | ||
| %arrayidx = getelementptr inbounds i32, ptr %a, i32 %iv | ||
| store i32 %iv, ptr %arrayidx, align 4 | ||
| %iv.next = add i32 %iv, 1 | ||
| %exitcond = icmp eq i32 %iv.next, %n | ||
| br i1 %exitcond, label %end, label %loop, !llvm.loop !2 | ||
|
|
||
| end: | ||
| ret void | ||
| } | ||
| !2 = !{!2, !{!"llvm.loop.disable_nonforced"}} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add CHECK-LABEL to match the 2 functions so it is clear to which function the debug output applies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since opt seems to always output all of the remarks and debug messages first, before any of the IR, I could not get CHECK-LABEL to match on the actual function name. As a workaround I made it match a message that contains the function name in question. This is less elegant than I would like, but I cannot see a better solution without putting the two functions into separate files.