
This adds a new vectorize predication loop hint: #pragma clang loop vectorize_predicate(enable) that can be used to indicate to the vectoriser that all (load/store) instructions should be predicated (masked). This allows, for example, folding of the remainder loop into the main loop. This patch will be followed up with D64916 and D65197. The former is a refactoring in the loopvectorizer and the groundwork to make tail loop folding a more general concept, and in the latter the actual tail loop folding transformation will be implemented. Differential Revision: https://reviews.llvm.org/D64744 llvm-svn: 366989
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
|
|
|
|
void test0(int *List, int Length) {
|
|
// CHECK-LABEL: @{{.*}}test0{{.*}}(
|
|
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP0:.*]]
|
|
|
|
#pragma clang loop vectorize(enable)
|
|
for (int i = 0; i < Length; i++)
|
|
List[i] = i * 2;
|
|
}
|
|
|
|
void test1(int *List, int Length) {
|
|
// CHECK-LABEL: @{{.*}}test1{{.*}}(
|
|
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP1:.*]]
|
|
|
|
#pragma clang loop vectorize(enable) vectorize_predicate(enable)
|
|
for (int i = 0; i < Length; i++)
|
|
List[i] = i * 2;
|
|
}
|
|
|
|
void test2(int *List, int Length) {
|
|
// CHECK-LABEL: @{{.*}}test2{{.*}}(
|
|
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP2:.*]]
|
|
|
|
#pragma clang loop vectorize(enable) vectorize_predicate(disable)
|
|
for (int i = 0; i < Length; i++)
|
|
List[i] = i * 2;
|
|
}
|
|
|
|
// CHECK: ![[LOOP0]] = distinct !{![[LOOP0]], !3}
|
|
// CHECK-NEXT: !3 = !{!"llvm.loop.vectorize.enable", i1 true}
|
|
// CHECK-NEXT: ![[LOOP1]] = distinct !{![[LOOP1]], !5, !3}
|
|
// CHECK-NEXT: !5 = !{!"llvm.loop.vectorize.predicate.enable", i1 true}
|
|
// CHECK-NEXT: ![[LOOP2]] = distinct !{![[LOOP2]], !7, !3}
|
|
// CHECK-NEXT: !7 = !{!"llvm.loop.vectorize.predicate.enable", i1 false}
|