1 // RUN: %clang_cc1 -fopenmp=libiomp5 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=NORMAL
2 // RUN: %clang_cc1 -fopenmp=libiomp5 -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=NORMAL
3 // RUN: %clang_cc1 -fopenmp=libiomp5 -triple powerpc64-unknown-unknown -target-abi elfv1-qpx -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=QPX
4
h1(float * c,float * a,double b[],int size)5 void h1(float *c, float *a, double b[], int size)
6 {
7 // CHECK-LABEL: define void @h1
8 int t = 0;
9 #pragma omp simd safelen(16) linear(t) aligned(c:32) aligned(a,b)
10 // CHECK: [[C_PTRINT:%.+]] = ptrtoint
11 // CHECK-NEXT: [[C_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[C_PTRINT]], 31
12 // CHECK-NEXT: [[C_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[C_MASKEDPTR]], 0
13 // CHECK-NEXT: call void @llvm.assume(i1 [[C_MASKCOND]])
14 // CHECK: [[A_PTRINT:%.+]] = ptrtoint
15 // CHECK-NEXT: [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
16 // CHECK-NEXT: [[A_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[A_MASKEDPTR]], 0
17 // CHECK-NEXT: call void @llvm.assume(i1 [[A_MASKCOND]])
18 // CHECK: [[B_PTRINT:%.+]] = ptrtoint
19 // NORMAL-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
20 // QPX-NEXT: [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 31
21 // CHECK-NEXT: [[B_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[B_MASKEDPTR]], 0
22 // CHECK-NEXT: call void @llvm.assume(i1 [[B_MASKCOND]])
23 for (int i = 0; i < size; ++i) {
24 c[i] = a[i] * a[i] + b[i] * b[t];
25 ++t;
26 // do not emit parallel_loop_access metadata due to usage of safelen clause.
27 // CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
28 }
29 }
30
h2(float * c,float * a,float * b,int size)31 void h2(float *c, float *a, float *b, int size)
32 {
33 // CHECK-LABEL: define void @h2
34 int t = 0;
35 #pragma omp simd linear(t)
36 for (int i = 0; i < size; ++i) {
37 c[i] = a[i] * a[i] + b[i] * b[t];
38 ++t;
39 // CHECK: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access [[LOOP_H2_HEADER:![0-9]+]]
40 }
41 }
42
h3(float * c,float * a,float * b,int size)43 void h3(float *c, float *a, float *b, int size)
44 {
45 // CHECK-LABEL: define void @h3
46 #pragma omp simd
47 for (int i = 0; i < size; ++i) {
48 for (int j = 0; j < size; ++j) {
49 c[j*i] = a[i] * b[j];
50 }
51 }
52 // do not emit parallel_loop_access for nested loop.
53 // CHECK-NOT: store float {{.+}}, float* {{.+}}, align {{.+}}, !llvm.mem.parallel_loop_access {{![0-9]+}}
54 }
55
56 // Metadata for h1:
57 // CHECK: [[LOOP_H1_HEADER:![0-9]+]] = distinct !{[[LOOP_H1_HEADER]], [[LOOP_WIDTH_16:![0-9]+]], [[LOOP_VEC_ENABLE:![0-9]+]]}
58 // CHECK: [[LOOP_WIDTH_16]] = !{!"llvm.loop.vectorize.width", i32 16}
59 // CHECK: [[LOOP_VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true}
60 //
61 // Metadata for h2:
62 // CHECK: [[LOOP_H2_HEADER]] = distinct !{[[LOOP_H2_HEADER]], [[LOOP_VEC_ENABLE]]}
63 //
64 // Metadata for h3:
65 // CHECK: [[LOOP_H3_HEADER:![0-9]+]] = distinct !{[[LOOP_H3_HEADER]], [[LOOP_VEC_ENABLE]]}
66 //
67