-
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
base: main
Are you sure you want to change the base?
Changes from 27 commits
81f1800
6d941ff
c0e6aec
c290bec
109b3fd
3c4c8de
fa19ccc
29d1fa2
117c358
2241343
98a90e9
55af5ac
120a5bf
a509ea9
bc68571
c6a624d
d4f407b
5d656e8
0a933b2
6dfffe8
936d9e3
b895a97
8173da8
835f8f0
7f9fe50
552a8ab
dcd926f
86515c5
5f7c8b0
96d6136
6c1932e
8e0c12b
1ec46e8
f530fd5
60f86af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| ; TEST 1 | ||
| ; This test checks that we emit only the correct debug messages and | ||
| ; optimization remark when the loop vectorizer is disabled by loop metadata. | ||
|
|
||
| ; REQUIRES: asserts | ||
| ; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \ | ||
| ; RUN: -pass-remarks-missed=loop-vectorize \ | ||
| ; RUN: -pass-remarks-analysis=loop-vectorize -debug -disable-output \ | ||
| ; RUN: < %s 2>&1 | FileCheck --check-prefix=METADATA %s | ||
| ; METADATA-NOT: LV: We can vectorize this loop | ||
| ; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint | ||
| ; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set | ||
| ; METADATA-NOT: LV: Not vectorizing: Disabled/already vectorized | ||
| ; METADATA-NOT: LV: Not vectorizing: Cannot prove legality | ||
| ; METADATA: LV: Loop hints: force=disabled | ||
| ; METADATA: LV: Not vectorizing: #pragma vectorize disable. | ||
| ; METADATA: remark: | ||
| ; METADATA-SAME: loop not vectorized: vectorization is explicitly disabled | ||
| ; METADATA: LV: Loop hints prevent vectorization | ||
|
|
||
| ; TEST 2 | ||
| ; This test 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 -passes='loop-vectorize<vectorize-forced-only>' \ | ||
| ; RUN: -pass-remarks=loop-vectorize \ | ||
| ; RUN: -pass-remarks-missed=loop-vectorize \ | ||
| ; RUN: -pass-remarks-analysis=loop-vectorize -debug -disable-output \ | ||
| ; RUN: 2>&1 | FileCheck --check-prefix=FORCEDONLY %s | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; FORCEDONLY-NOT: LV: We can vectorize this loop | ||
| ; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint | ||
| ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable | ||
| ; FORCEDONLY-NOT: LV: Not vectorizing: Disabled/already vectorized | ||
| ; FORCEDONLY-NOT: LV: Not vectorizing: Cannot prove legality | ||
| ; 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 | ||
| ; FORCEDONLY: LV: Loop hints prevent vectorization | ||
|
|
||
| define i64 @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 1.234e+0, ptr %arrayidx, align 8 | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| %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 i64 0 | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| !0 = distinct !{!0, !1} | ||
| !1 = !{!"llvm.loop.vectorize.enable", i1 false} | ||
|
|
||
| ; TEST 3 | ||
| ; This test 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 -passes=loop-vectorize -pass-remarks=loop-vectorize \ | ||
| ; RUN: -pass-remarks-missed=loop-vectorize \ | ||
| ; RUN: -pass-remarks-analysis=loop-vectorize -debug -disable-output \ | ||
| ; RUN: -force-vector-interleave=1 -force-vector-width=2 \ | ||
| ; RUN: < %s 2>&1 | FileCheck %s | ||
| ; 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 %for.body | ||
|
|
||
| for.body: | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv | ||
| %0 = trunc i64 %indvars.iv to i32 | ||
TiborGY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| store i32 %0, ptr %arrayidx, align 4 | ||
| %indvars.iv.next = add i64 %indvars.iv, 1 | ||
| %lftr.wideiv = trunc i64 %indvars.iv.next to i32 | ||
| %exitcond = icmp eq i32 %lftr.wideiv, %n | ||
| br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2 | ||
|
|
||
| for.end: | ||
| ret void | ||
| } | ||
|
|
||
| !2 = !{!2, !{!"llvm.loop.disable_nonforced"}} | ||
Uh oh!
There was an error while loading. Please reload this page.