xref: /llvm-project/clang/test/OpenMP/reduction_complex.c (revision 6b1c51bc052ae974e89e623b3d143d010fd09222)
1*6b1c51bcSAkash Banerjee // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
2*6b1c51bcSAkash Banerjee // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ \
3*6b1c51bcSAkash Banerjee // RUN:  -triple powerpc64le-unknown-unknown \
4*6b1c51bcSAkash Banerjee // RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o \
5*6b1c51bcSAkash Banerjee // RUN:  %t-ppc-host.bc
6*6b1c51bcSAkash Banerjee 
7*6b1c51bcSAkash Banerjee // RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ \
8*6b1c51bcSAkash Banerjee // RUN:  -triple nvptx64-unknown-unknown -DCUA \
9*6b1c51bcSAkash Banerjee // RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s \
10*6b1c51bcSAkash Banerjee // RUN:  -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc \
11*6b1c51bcSAkash Banerjee // RUN:  -o - | FileCheck %s --check-prefix CHECK
12*6b1c51bcSAkash Banerjee 
13*6b1c51bcSAkash Banerjee // expected-no-diagnostics
foo()14*6b1c51bcSAkash Banerjee int foo() {
15*6b1c51bcSAkash Banerjee   int i;
16*6b1c51bcSAkash Banerjee   int j;
17*6b1c51bcSAkash Banerjee   _Complex float sum = 0;
18*6b1c51bcSAkash Banerjee 
19*6b1c51bcSAkash Banerjee #pragma omp target teams loop reduction(+:sum) collapse(2) bind(parallel) order(concurrent) lastprivate(j) map(tofrom:sum)
20*6b1c51bcSAkash Banerjee 
21*6b1c51bcSAkash Banerjee   for(i=0; i<10; i++)
22*6b1c51bcSAkash Banerjee     for(j=0; j<10; j++)
23*6b1c51bcSAkash Banerjee       sum += i;
24*6b1c51bcSAkash Banerjee 
25*6b1c51bcSAkash Banerjee   return 0;
26*6b1c51bcSAkash Banerjee }
27*6b1c51bcSAkash Banerjee // CHECK-LABEL: define {{[^@]+}}@_omp_reduction_shuffle_and_reduce_func
28*6b1c51bcSAkash Banerjee // CHECK-SAME: (ptr noundef [[TMP0:%.*]], i16 noundef signext [[TMP1:%.*]], i16 noundef signext [[TMP2:%.*]], i16 noundef signext [[TMP3:%.*]]) #[[ATTR2:[0-9]+]] {
29*6b1c51bcSAkash Banerjee // CHECK-NEXT:  entry:
30*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_228:.*]] = alloca ptr, align 8
31*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_229:.*]] = alloca i16, align 2
32*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_230:.*]] = alloca i16, align 2
33*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_231:.*]] = alloca i16, align 2
34*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_232:.*]] = alloca [1 x ptr], align 8
35*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_233:.*]] = alloca { float, float }, align 8
36*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store ptr %[[VAL_234:.*]], ptr %[[VAL_228]], align 8
37*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store i16 %[[VAL_235:.*]], ptr %[[VAL_229]], align 2
38*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store i16 %[[VAL_236:.*]], ptr %[[VAL_230]], align 2
39*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store i16 %[[VAL_237:.*]], ptr %[[VAL_231]], align 2
40*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_238:.*]] = load ptr, ptr %[[VAL_228]], align 8
41*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_239:.*]] = load i16, ptr %[[VAL_229]], align 2
42*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_240:.*]] = load i16, ptr %[[VAL_230]], align 2
43*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_241:.*]] = load i16, ptr %[[VAL_231]], align 2
44*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_242:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_238]], i64 0, i64 0
45*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_243:.*]] = load ptr, ptr %[[VAL_242]], align 8
46*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_244:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_232]], i64 0, i64 0
47*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_245:.*]] = getelementptr { float, float }, ptr %[[VAL_243]], i64 1
48*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_246:.*]] = load i64, ptr %[[VAL_243]], align 8
49*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_247:.*]] = call i32 @__kmpc_get_warp_size()
50*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_248:.*]] = trunc i32 %[[VAL_247]] to i16
51*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_249:.*]] = call i64 @__kmpc_shuffle_int64(i64 %[[VAL_246]], i16 %[[VAL_240]], i16 %[[VAL_248]])
52*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store i64 %[[VAL_249]], ptr %[[VAL_233]], align 8
53*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_250:.*]] = getelementptr i64, ptr %[[VAL_243]], i64 1
54*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_251:.*]] = getelementptr i64, ptr %[[VAL_233]], i64 1
55*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store ptr %[[VAL_233]], ptr %[[VAL_244]], align 8
56*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_252:.*]] = icmp eq i16 %[[VAL_241]], 0
57*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_253:.*]] = icmp eq i16 %[[VAL_241]], 1
58*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_254:.*]] = icmp ult i16 %[[VAL_239]], %[[VAL_240]]
59*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_255:.*]] = and i1 %[[VAL_253]], %[[VAL_254]]
60*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_256:.*]] = icmp eq i16 %[[VAL_241]], 2
61*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_257:.*]] = and i16 %[[VAL_239]], 1
62*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_258:.*]] = icmp eq i16 %[[VAL_257]], 0
63*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_259:.*]] = and i1 %[[VAL_256]], %[[VAL_258]]
64*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_260:.*]] = icmp sgt i16 %[[VAL_240]], 0
65*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_261:.*]] = and i1 %[[VAL_259]], %[[VAL_260]]
66*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_262:.*]] = or i1 %[[VAL_252]], %[[VAL_255]]
67*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_263:.*]] = or i1 %[[VAL_262]], %[[VAL_261]]
68*6b1c51bcSAkash Banerjee // CHECK-NEXT:         br i1 %[[VAL_263]], label %[[VAL_264:.*]], label %[[VAL_265:.*]]
69*6b1c51bcSAkash Banerjee // CHECK:       then:                                             ; preds = %[[VAL_266:.*]]
70*6b1c51bcSAkash Banerjee // CHECK-NEXT:         call void @"{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}__Z3foov_l{{[0-9]+}}_omp_outlined_omp_outlined_omp$reduction$reduction_func"(ptr %[[VAL_238]], ptr %[[VAL_232]]) #2
71*6b1c51bcSAkash Banerjee // CHECK-NEXT:         br label %[[VAL_267:.*]]
72*6b1c51bcSAkash Banerjee // CHECK:       else:                                             ; preds = %[[VAL_266]]
73*6b1c51bcSAkash Banerjee // CHECK-NEXT:         br label %[[VAL_267]]
74*6b1c51bcSAkash Banerjee // CHECK:       ifcont:                                           ; preds = %[[VAL_265]], %[[VAL_264]]
75*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_268:.*]] = icmp eq i16 %[[VAL_241]], 1
76*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_269:.*]] = icmp uge i16 %[[VAL_239]], %[[VAL_240]]
77*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_270:.*]] = and i1 %[[VAL_268]], %[[VAL_269]]
78*6b1c51bcSAkash Banerjee // CHECK-NEXT:         br i1 %[[VAL_270]], label %[[VAL_271:.*]], label %[[VAL_272:.*]]
79*6b1c51bcSAkash Banerjee // CHECK:       then4:                                            ; preds = %[[VAL_267]]
80*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_273:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_232]], i64 0, i64 0
81*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_274:.*]] = load ptr, ptr %[[VAL_273]], align 8
82*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_275:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_238]], i64 0, i64 0
83*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_276:.*]] = load ptr, ptr %[[VAL_275]], align 8
84*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_277:.*]] = getelementptr inbounds { float, float }, ptr %[[VAL_274]], i32 0, i32 0
85*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_278:.*]] = load float, ptr %[[VAL_277]], align 4
86*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_279:.*]] = getelementptr inbounds { float, float }, ptr %[[VAL_274]], i32 0, i32 1
87*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_280:.*]] = load float, ptr %[[VAL_279]], align 4
88*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_281:.*]] = getelementptr inbounds { float, float }, ptr %[[VAL_276]], i32 0, i32 0
89*6b1c51bcSAkash Banerjee // CHECK-NEXT:         %[[VAL_282:.*]] = getelementptr inbounds { float, float }, ptr %[[VAL_276]], i32 0, i32 1
90*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store float %[[VAL_278]], ptr %[[VAL_281]], align 4
91*6b1c51bcSAkash Banerjee // CHECK-NEXT:         store float %[[VAL_280]], ptr %[[VAL_282]], align 4
92*6b1c51bcSAkash Banerjee // CHECK-NEXT:         br label %[[VAL_283:.*]]
93*6b1c51bcSAkash Banerjee // CHECK:       else7:                                            ; preds = %[[VAL_267]]
94*6b1c51bcSAkash Banerjee // CHECK-NEXT:         br label %[[VAL_283]]
95*6b1c51bcSAkash Banerjee // CHECK:       ifcont8:                                          ; preds = %[[VAL_272]], %[[VAL_271]]
96*6b1c51bcSAkash Banerjee // CHECK-NEXT:         ret void
97