1 // Test host codegen.
2 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix OMP45
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
4 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix HCHECK --check-prefix OMP45
5 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK --check-prefix OMP45
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK --check-prefix OMP45
8 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix OMP50
9 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s -DOMP5
10 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix HCHECK --check-prefix OMP50
11 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - -DOMP5| FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK --check-prefix OMP50
12 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s -DOMP5
13 // RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK --check-prefix OMP50
14
15 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
17 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
18 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
19 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
20 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
21 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY0 %s
22 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s -DOMP5
23 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY0 %s
24 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY0 %s
25 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s -DOMP5
26 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY0 %s
27 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
28
29 // Test target codegen - host bc file has to be created first. (no significant differences with host version of target region)
30 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
31 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
32 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
33 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
34 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
35 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
36 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
37 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix OMP45
38 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -DOMP5
39 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
40 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s -DOMP5
41 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
42 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc -DOMP5
43 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
44 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s -DOMP5
45 // RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
46
47 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
48 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s
49 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
50 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
51 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
52 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s
53 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
54 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
55 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -DOMP5
56 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY1 %s
57 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s -DOMP5
58 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY1 %s
59 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc -DOMP5
60 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY1 %s
61 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s -DOMP5
62 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - -DOMP5 | FileCheck --check-prefix SIMD-ONLY1 %s
63 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
64
65 // expected-no-diagnostics
66 #ifndef HEADER
67 #define HEADER
68
69 // CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
70 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
71 // CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
72 // CHECK-DAG: [[DEF_LOC_DISTRIBUTE_0:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2050, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
73
74 // CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
without_schedule_clause(float * a,float * b,float * c,float * d)75 void without_schedule_clause(float *a, float *b, float *c, float *d) {
76 #pragma omp target
77 #pragma omp teams
78 #ifdef OMP5
79 #pragma omp distribute simd simdlen(8) aligned(a) if(true)
80 #else
81 #pragma omp distribute simd simdlen(8) aligned(a)
82 #endif // OMP5
83 for (int i = 33; i < 32000000; i += 7) {
84 a[i] = b[i] * c[i] * d[i];
85 }
86 }
87
88 // CHECK: define {{.*}}void @{{.+}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
89 // CHECK: [[TID_ADDR:%.+]] = alloca i32*
90 // CHECK: [[IV:%.+iv]] = alloca i32
91 // CHECK: [[LB:%.+lb]] = alloca i32
92 // CHECK: [[UB:%.+ub]] = alloca i32
93 // CHECK: [[ST:%.+stride]] = alloca i32
94 // CHECK: [[LAST:%.+last]] = alloca i32
95 // CHECK-DAG: store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
96 // CHECK-DAG: call void @llvm.assume(
97 // CHECK-DAG: store i32 0, i32* [[LB]]
98 // CHECK-DAG: store i32 4571423, i32* [[UB]]
99 // CHECK-DAG: store i32 1, i32* [[ST]]
100 // CHECK-DAG: store i32 0, i32* [[LAST]]
101 // CHECK-DAG: [[GBL_TID:%.+]] = load i32*, i32** [[TID_ADDR]]
102 // CHECK-DAG: [[GBL_TIDV:%.+]] = load i32, i32* [[GBL_TID]]
103 // CHECK: call void @__kmpc_for_static_init_{{.+}}(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]], i32 92, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 1)
104 // CHECK-DAG: [[UBV0:%.+]] = load i32, i32* [[UB]]
105 // CHECK-DAG: [[USWITCH:%.+]] = icmp sgt i32 [[UBV0]], 4571423
106 // CHECK: br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
107 // CHECK-DAG: [[BBCT]]:
108 // CHECK-DAG: br label %[[BBCE:.+]]
109 // CHECK-DAG: [[BBCF]]:
110 // CHECK-DAG: [[UBV1:%.+]] = load i32, i32* [[UB]]
111 // CHECK-DAG: br label %[[BBCE]]
112 // CHECK: [[BBCE]]:
113 // CHECK: [[SELUB:%.+]] = phi i32 [ 4571423, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
114 // CHECK: store i32 [[SELUB]], i32* [[UB]]
115 // CHECK: [[LBV0:%.+]] = load i32, i32* [[LB]]
116 // CHECK: store i32 [[LBV0]], i32* [[IV]]
117 // CHECK: br label %[[BBINNFOR:.+]]
118 // CHECK: [[BBINNFOR]]:
119 // CHECK: [[IVVAL0:%.+]] = load i32, i32* [[IV]]
120 // CHECK: [[UBV2:%.+]] = load i32, i32* [[UB]]
121 // CHECK: [[IVLEUB:%.+]] = icmp sle i32 [[IVVAL0]], [[UBV2]]
122 // CHECK: br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
123 // CHECK: [[BBINNBODY]]:
124 // CHECK: {{.+}} = load i32, i32* [[IV]]
125 // ... loop body ...
126 // CHECK: br label %[[BBBODYCONT:.+]]
127 // CHECK: [[BBBODYCONT]]:
128 // CHECK: br label %[[BBINNINC:.+]]
129 // CHECK: [[BBINNINC]]:
130 // CHECK: [[IVVAL1:%.+]] = load i32, i32* [[IV]]
131 // CHECK: [[IVINC:%.+]] = add nsw i32 [[IVVAL1]], 1
132 // CHECK: store i32 [[IVINC]], i32* [[IV]]
133 // CHECK: br label %[[BBINNFOR]]
134 // CHECK: [[BBINNEND]]:
135 // CHECK: br label %[[LPEXIT:.+]]
136 // CHECK: [[LPEXIT]]:
137 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
138 // CHECK: ret void
139
140
141 // CHECK-LABEL: define {{.*void}} @{{.*}}static_not_chunked{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
static_not_chunked(float * a,float * b,float * c,float * d)142 void static_not_chunked(float *a, float *b, float *c, float *d) {
143 #pragma omp target
144 #pragma omp teams
145 #ifdef OMP5
146 #pragma omp distribute simd dist_schedule(static) safelen(32) if(simd: true) nontemporal(a, b)
147 #else
148 #pragma omp distribute simd dist_schedule(static) safelen(32)
149 #endif // OMP5
150 for (int i = 32000000; i > 33; i += -7) {
151 a[i] = b[i] * c[i] * d[i];
152 }
153 }
154
155 // CHECK: define {{.*}}void @.omp_outlined.{{.*}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
156 // CHECK: [[TID_ADDR:%.+]] = alloca i32*
157 // CHECK: [[IV:%.+iv]] = alloca i32
158 // CHECK: [[LB:%.+lb]] = alloca i32
159 // CHECK: [[UB:%.+ub]] = alloca i32
160 // CHECK: [[ST:%.+stride]] = alloca i32
161 // CHECK: [[LAST:%.+last]] = alloca i32
162 // CHECK-DAG: store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
163 // CHECK-DAG: store i32 0, i32* [[LB]]
164 // CHECK-DAG: store i32 4571423, i32* [[UB]]
165 // CHECK-DAG: store i32 1, i32* [[ST]]
166 // CHECK-DAG: store i32 0, i32* [[LAST]]
167 // CHECK-DAG: [[GBL_TID:%.+]] = load i32*, i32** [[TID_ADDR]]
168 // CHECK-DAG: [[GBL_TIDV:%.+]] = load i32, i32* [[GBL_TID]]
169 // CHECK: call void @__kmpc_for_static_init_{{.+}}(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]], i32 92, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 1)
170 // CHECK-DAG: [[UBV0:%.+]] = load i32, i32* [[UB]]
171 // CHECK-DAG: [[USWITCH:%.+]] = icmp sgt i32 [[UBV0]], 4571423
172 // CHECK: br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
173 // CHECK-DAG: [[BBCT]]:
174 // CHECK-DAG: br label %[[BBCE:.+]]
175 // CHECK-DAG: [[BBCF]]:
176 // CHECK-DAG: [[UBV1:%.+]] = load i32, i32* [[UB]]
177 // CHECK-DAG: br label %[[BBCE]]
178 // CHECK: [[BBCE]]:
179 // CHECK: [[SELUB:%.+]] = phi i32 [ 4571423, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
180 // CHECK: store i32 [[SELUB]], i32* [[UB]]
181 // CHECK: [[LBV0:%.+]] = load i32, i32* [[LB]]
182 // CHECK: store i32 [[LBV0]], i32* [[IV]]
183 // CHECK: br label %[[BBINNFOR:.+]]
184 // CHECK: [[BBINNFOR]]:
185 // CHECK: [[IVVAL0:%.+]] = load i32, i32* [[IV]]
186 // CHECK: [[UBV2:%.+]] = load i32, i32* [[UB]]
187 // CHECK: [[IVLEUB:%.+]] = icmp sle i32 [[IVVAL0]], [[UBV2]]
188 // CHECK: br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
189 // CHECK: [[BBINNBODY]]:
190 // CHECK: {{.+}} = load i32, i32* [[IV]]
191 // ... loop body ...
192 // OMP45-NOT: !nontemporal
193 // OMP50: load float*,{{.*}}!nontemporal
194 // OMP50: load float*,{{.*}}!nontemporal
195 // OMP50-NOT: !nontemporal
196
197 // CHECK: br label %[[BBBODYCONT:.+]]
198 // CHECK: [[BBBODYCONT]]:
199 // CHECK: br label %[[BBINNINC:.+]]
200 // CHECK: [[BBINNINC]]:
201 // CHECK: [[IVVAL1:%.+]] = load i32, i32* [[IV]]
202 // CHECK: [[IVINC:%.+]] = add nsw i32 [[IVVAL1]], 1
203 // CHECK: store i32 [[IVINC]], i32* [[IV]]
204 // CHECK: br label %[[BBINNFOR]]
205 // CHECK: [[BBINNEND]]:
206 // CHECK: br label %[[LPEXIT:.+]]
207 // CHECK: [[LPEXIT]]:
208 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
209 // CHECK: ret void
210
211
212 // CHECK-LABEL: define {{.*void}} @{{.*}}static_chunked{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
static_chunked(float * a,float * b,float * c,float * d)213 void static_chunked(float *a, float *b, float *c, float *d) {
214 #pragma omp target
215 #pragma omp teams
216 #pragma omp distribute simd dist_schedule(static, 5)
217 for (unsigned i = 131071; i <= 2147483647; i += 127) {
218 a[i] = b[i] * c[i] * d[i];
219 }
220 }
221
222 // CHECK: define {{.*}}void @.omp_outlined.{{.*}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
223 // CHECK: [[TID_ADDR:%.+]] = alloca i32*
224 // CHECK: [[IV:%.+iv]] = alloca i32
225 // CHECK: [[LB:%.+lb]] = alloca i32
226 // CHECK: [[UB:%.+ub]] = alloca i32
227 // CHECK: [[ST:%.+stride]] = alloca i32
228 // CHECK: [[LAST:%.+last]] = alloca i32
229 // CHECK-DAG: store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
230 // CHECK-DAG: store i32 0, i32* [[LB]]
231 // CHECK-DAG: store i32 16908288, i32* [[UB]]
232 // CHECK-DAG: store i32 1, i32* [[ST]]
233 // CHECK-DAG: store i32 0, i32* [[LAST]]
234 // CHECK-DAG: [[GBL_TID:%.+]] = load i32*, i32** [[TID_ADDR]]
235 // CHECK-DAG: [[GBL_TIDV:%.+]] = load i32, i32* [[GBL_TID]]
236 // CHECK: call void @__kmpc_for_static_init_{{.+}}(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]], i32 91, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 5)
237 // CHECK-DAG: [[UBV0:%.+]] = load i32, i32* [[UB]]
238 // CHECK-DAG: [[USWITCH:%.+]] = icmp ugt i32 [[UBV0]], 16908288
239 // CHECK: br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
240 // CHECK-DAG: [[BBCT]]:
241 // CHECK-DAG: br label %[[BBCE:.+]]
242 // CHECK-DAG: [[BBCF]]:
243 // CHECK-DAG: [[UBV1:%.+]] = load i32, i32* [[UB]]
244 // CHECK-DAG: br label %[[BBCE]]
245 // CHECK: [[BBCE]]:
246 // CHECK: [[SELUB:%.+]] = phi i32 [ 16908288, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
247 // CHECK: store i32 [[SELUB]], i32* [[UB]]
248 // CHECK: [[LBV0:%.+]] = load i32, i32* [[LB]]
249 // CHECK: store i32 [[LBV0]], i32* [[IV]]
250 // CHECK: br label %[[BBINNFOR:.+]]
251 // CHECK: [[BBINNFOR]]:
252 // CHECK: [[IVVAL0:%.+]] = load i32, i32* [[IV]]
253 // CHECK: [[UBV2:%.+]] = load i32, i32* [[UB]]
254 // CHECK: [[IVLEUB:%.+]] = icmp ule i32 [[IVVAL0]], [[UBV2]]
255 // CHECK: br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
256 // CHECK: [[BBINNBODY]]:
257 // CHECK: {{.+}} = load i32, i32* [[IV]]
258 // ... loop body ...
259 // CHECK: br label %[[BBBODYCONT:.+]]
260 // CHECK: [[BBBODYCONT]]:
261 // CHECK: br label %[[BBINNINC:.+]]
262 // CHECK: [[BBINNINC]]:
263 // CHECK: [[IVVAL1:%.+]] = load i32, i32* [[IV]]
264 // CHECK: [[IVINC:%.+]] = add i32 [[IVVAL1]], 1
265 // CHECK: store i32 [[IVINC]], i32* [[IV]]
266 // CHECK: br label %[[BBINNFOR]]
267 // CHECK: [[BBINNEND]]:
268 // CHECK: br label %[[LPEXIT:.+]]
269 // CHECK: [[LPEXIT]]:
270 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
271 // CHECK: ret void
272
273 // CHECK-LABEL: test_precond
test_precond()274 void test_precond() {
275 char a = 0; char i;
276 #pragma omp target
277 #pragma omp teams
278 #ifdef OMP5
279 #pragma omp distribute simd linear(i) if(a) nontemporal(i)
280 #else
281 #pragma omp distribute simd linear(i)
282 #endif // OMP5
283 for(i = a; i < 10; ++i);
284 }
285
286 // a is passed as a parameter to the outlined functions
287 // CHECK: define {{.*}}void @.omp_outlined.{{.*}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], i8* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APARM:%.+]])
288 // CHECK: store i8* [[APARM]], i8** [[APTRADDR:%.+]]
289 // ..many loads of %0..
290 // CHECK: [[A2:%.+]] = load i8*, i8** [[APTRADDR]]
291 // CHECK: [[AVAL0:%.+]] = load i8, i8* [[A2]]
292 // CHECK: store i8 [[AVAL0]], i8* [[CAP_EXPR:%.+]],
293 // CHECK: [[AVAL1:%.+]] = load i8, i8* [[CAP_EXPR]]
294 // CHECK: load i8, i8* [[CAP_EXPR]]
295 // CHECK: [[AVAL2:%.+]] = load i8, i8* [[CAP_EXPR]]
296 // CHECK: [[ACONV:%.+]] = sext i8 [[AVAL2]] to i32
297 // CHECK: [[ACMP:%.+]] = icmp slt i32 [[ACONV]], 10
298 // CHECK: br i1 [[ACMP]], label %[[PRECOND_THEN:.+]], label %[[PRECOND_END:.+]]
299 // CHECK: [[PRECOND_THEN]]
300 // CHECK: call void @__kmpc_for_static_init_4
301 // OMP45-NOT: !nontemporal
302 // OMP50: store i8 {{.*}}!nontemporal
303 // OMP50-NOT: !nontemporal
304 // CHECK: call void @__kmpc_for_static_fini
305 // CHECK: [[PRECOND_END]]
306
307 // no templates for now, as these require special handling in target regions and/or declare target
308
309 // HCHECK-LABEL: fint
310 // HCHECK: call {{.*}}i32 {{.+}}ftemplate
311 // HCHECK: ret i32
312
313 // HCHECK: load i16, i16*
314 // HCHECK: store i16 %
315 // HCHECK: call i32 @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}},
316 // HCHECK: call void @__kmpc_for_static_init_4(
317 template <typename T>
ftemplate()318 T ftemplate() {
319 short aa = 0;
320
321 #pragma omp target
322 #pragma omp teams
323 #pragma omp distribute simd dist_schedule(static, aa)
324 for (int i = 0; i < 100; i++) {
325 }
326 return T();
327 }
328
fint(void)329 int fint(void) { return ftemplate<int>(); }
330
331 #endif
332
333 // OMP45-NOT: !{!"llvm.loop.vectorize.enable", i1 false}
334 // CHECK-DAG: !{!"llvm.loop.vectorize.width", i32 8}
335 // CHECK-DAG: !{!"llvm.loop.vectorize.enable", i1 true}
336 // CHECK-DAG: !{!"llvm.loop.vectorize.width", i32 32}
337 // OMP45-NOT: !{!"llvm.loop.vectorize.enable", i1 false}
338 // OMP50-DAG: !{!"llvm.loop.vectorize.enable", i1 false}
339