Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang] Pragma vectorize_width() implies vectorize(enable)
Let's try this again; this has been reverted/recommited a few times. Last time this got reverted because for this loop: void a() { #pragma clang loop vectorize(disable) for (;;) ; } vectorisation was incorrectly enabled and the vectorize.enable metadata was set due to a logic error. But with this fixed, we now imply vectorisation when: 1) vectorisation is enabled, which means: VectorizeWidth > 1, 2) and don't want to add it when it is disabled or enabled, otherwise we would be incorrectly setting it or duplicating the metadata, respectively. This should fix PR27643. Differential Revision: https://reviews.llvm.org/D69628
- Loading branch information
Sjoerd Meijer
committed
Dec 11, 2019
1 parent
987e732
commit 0216854
Showing
3 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 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,52 @@ | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s | ||
|
||
void loop1(int *List, int Length) { | ||
// CHECK-LABEL: @{{.*}}loop1{{.*}}( | ||
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP1:.*]] | ||
|
||
#pragma clang loop vectorize(enable) vectorize_width(1) | ||
for (int i = 0; i < Length; i++) | ||
List[i] = i * 2; | ||
} | ||
|
||
// Here, vectorize.enable should be set, obviously, but also check that | ||
// metadata isn't added twice. | ||
void loop2(int *List, int Length) { | ||
// CHECK-LABEL: @{{.*}}loop2{{.*}}( | ||
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP2:.*]] | ||
|
||
#pragma clang loop vectorize(enable) vectorize_width(2) | ||
for (int i = 0; i < Length; i++) | ||
List[i] = i * 2; | ||
} | ||
|
||
// Test that we do *not* imply vectorize.enable. | ||
void loop3(int *List, int Length) { | ||
// CHECK-LABEL: @{{.*}}loop3{{.*}}( | ||
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP3:.*]] | ||
|
||
#pragma clang loop vectorize_width(1) | ||
for (int i = 0; i < Length; i++) | ||
List[i] = i * 2; | ||
} | ||
|
||
// Test that we *do* imply vectorize.enable. | ||
void loop4(int *List, int Length) { | ||
// CHECK-LABEL: @{{.*}}loop4{{.*}}( | ||
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP4:.*]] | ||
|
||
#pragma clang loop vectorize_width(2) | ||
for (int i = 0; i < Length; i++) | ||
List[i] = i * 2; | ||
} | ||
|
||
// CHECK: ![[LOOP1]] = distinct !{![[LOOP1]], ![[VEC_WIDTH_1:.*]], ![[VEC_ENABLE:.*]]} | ||
// CHECK: ![[VEC_WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1} | ||
// CHECK: ![[VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true} | ||
|
||
// CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], ![[VEC_WIDTH_2:.*]], ![[VEC_ENABLE]]} | ||
// CHECK: ![[VEC_WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2} | ||
|
||
// CHECK: ![[LOOP3]] = distinct !{![[LOOP3]], ![[VEC_WIDTH_1]]} | ||
|
||
// CHECK: ![[LOOP4]] = distinct !{![[LOOP4]], ![[VEC_WIDTH_2]], ![[VEC_ENABLE]]} |
This file contains 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