-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang][CodeGen] Fix metadata when vectorization is disabled by pragma #135163
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
Changes from 1 commit
79186af
aed6f10
98bee49
0e60403
16b6d51
375dc8f
6d68a79
32a6d9c
2989929
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 |
|---|---|---|
|
|
@@ -200,7 +200,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs, | |
| LLVMContext &Ctx = Header->getContext(); | ||
|
|
||
| std::optional<bool> Enabled; | ||
| if (Attrs.VectorizeEnable == LoopAttributes::Disable) | ||
| if (Attrs.VectorizeEnable == LoopAttributes::Disable || | ||
| Attrs.VectorizeWidth == 1) | ||
| Enabled = false; | ||
| else if (Attrs.VectorizeEnable != LoopAttributes::Unspecified || | ||
| Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified || | ||
|
|
@@ -643,9 +644,7 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx, | |
| case LoopHintAttr::Disable: | ||
| switch (Option) { | ||
| case LoopHintAttr::Vectorize: | ||
| // Disable vectorization by specifying a width of 1. | ||
| setVectorizeWidth(1); | ||
| setVectorizeScalable(LoopAttributes::Unspecified); | ||
| setVectorizeEnable(false); | ||
|
||
| break; | ||
| case LoopHintAttr::Interleave: | ||
| // Disable interleaving by speciyfing a count of 1. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,8 +37,8 @@ void test3(int *List, int Length) { | |
| List[i] = i * 2; | ||
| } | ||
|
|
||
| // Check that disabling vectorization means a vectorization width of 1, and | ||
| // also that vectorization_predicate isn't enabled. | ||
| // Check that vectorize is disabled, and also that vectorization_predicate is | ||
|
||
| // ignored. | ||
| void test4(int *List, int Length) { | ||
| // CHECK-LABEL: @{{.*}}test4{{.*}}( | ||
| // CHECK: br label {{.*}}, !llvm.loop ![[LOOP4:.*]] | ||
|
|
@@ -48,7 +48,7 @@ void test4(int *List, int Length) { | |
| List[i] = i * 2; | ||
| } | ||
|
|
||
| // Check that vectorize and vectorize_predicate are disabled. | ||
| // Check that vectorize is disabled and vectorize_predicate is ignored. | ||
| void test5(int *List, int Length) { | ||
| // CHECK-LABEL: @{{.*}}test5{{.*}}( | ||
| // CHECK: br label {{.*}}, !llvm.loop ![[LOOP5:.*]] | ||
|
|
@@ -114,16 +114,16 @@ void test9(int *List, int Length) { | |
| // CHECK-NEXT: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], [[GEN6]], [[GEN3]]} | ||
|
|
||
| // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]} | ||
| // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1} | ||
| // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.enable", i1 false} | ||
|
|
||
| // CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN6]], [[GEN10]]} | ||
| // CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]} | ||
|
|
||
| // CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN8]], [[GEN10]], [[GEN11:![0-9]+]]} | ||
| // CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} | ||
| // CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN10]]} | ||
|
|
||
| // CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN12:![0-9]+]], [[GEN11]], [[GEN3]]} | ||
| // CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.width", i32 4} | ||
| // CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN11:![0-9]+]], [[GEN12:![0-9]+]], [[GEN3]]} | ||
| // CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4} | ||
| // CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} | ||
|
|
||
| // CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN6]], [[GEN10]], [[GEN11]]} | ||
| // CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN10]]} | ||
|
|
||
| // CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN12]], [[GEN11]], [[GEN3]]} | ||
| // CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN11]], [[GEN12]], [[GEN3]]} | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -194,7 +194,7 @@ void for_test_scalable(int *List, int Length) { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // Verify for loop is performing scalable vectorization | ||||||||
| // Verify for loop is NOT performing vectorization because the width is 1 | ||||||||
|
||||||||
| // Disable vectorization by specifying a width of 1. | |
| setVectorizeWidth(1); | |
| setVectorizeScalable(LoopAttributes::Unspecified); |
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.
If taking the intent of the original implementation, then it appears to not vectorize the loop.
Yeah I think that makes sense, i.e. we should disable vectorization if (Attrs.VectorizeEnable == LoopAttributes::Disable || (Attrs.VectorizeWidth == 1 && Attrs.VectorizeScalable != LoopAttributes:: Enable)).
We should probably also update this bit in the docs to be explicit about it:
Specifying a non-scalable width/count of 1 disables the optimization, and is equivalent to vectorize(disable) or interleave(disable).
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.
Fixed both code and docs. Thanks.
Outdated
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.
Again, I think this is broken. We should still be vectorising with VF=vscale x 1
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.
Undid this, thanks.
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.
Perhaps this condition has never been met.