Debian Codegraph @

flang/test/Lower/OpenMP/parallel-reduction-complex-mul.f90

raw
1 ! RUN: bbc -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
2 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
3
4 !CHECK-LABEL: omp.declare_reduction
5 !CHECK-SAME: @[[RED_NAME:.*]] : !fir.complex<8> init {
6 !CHECK: ^bb0(%{{.*}}: !fir.complex<8>):
7 !CHECK: %[[C0_1:.*]] = arith.constant 1.000000e+00 : f64
8 !CHECK: %[[C0_2:.*]] = arith.constant 0.000000e+00 : f64
9 !CHECK: %[[UNDEF:.*]] = fir.undefined !fir.complex<8>
10 !CHECK: %[[RES_1:.*]] = fir.insert_value %[[UNDEF]], %[[C0_1]], [0 : index]
11 !CHECK: %[[RES_2:.*]] = fir.insert_value %[[RES_1]], %[[C0_2]], [1 : index]
12 !CHECK: omp.yield(%[[RES_2]] : !fir.complex<8>)
13 !CHECK: } combiner {
14 !CHECK: ^bb0(%[[ARG0:.*]]: !fir.complex<8>, %[[ARG1:.*]]: !fir.complex<8>):
15 !CHECK: %[[RES:.*]] = fir.mulc %[[ARG0]], %[[ARG1]] {{.*}}: !fir.complex<8>
16 !CHECK: omp.yield(%[[RES]] : !fir.complex<8>)
17 !CHECK: }
18
19 !CHECK-LABEL: func.func @_QPsimple_complex_mul
20 !CHECK: %[[CREF:.*]] = fir.alloca !fir.complex<8> {bindc_name = "c", {{.*}}}
21 !CHECK: %[[C_DECL:.*]]:2 = hlfir.declare %[[CREF]] {uniq_name = "_QFsimple_complex_mulEc"} : (!fir.ref<!fir.complex<8>>) -> (!fir.ref<!fir.complex<8>>, !fir.ref<!fir.complex<8>>)
22 !CHECK: %[[C_START_RE:.*]] = arith.constant 0.000000e+00 : f64
23 !CHECK: %[[C_START_IM:.*]] = arith.constant 0.000000e+00 : f64
24 !CHECK: %[[UNDEF_1:.*]] = fir.undefined !fir.complex<8>
25 !CHECK: %[[VAL_1:.*]] = fir.insert_value %[[UNDEF_1]], %[[C_START_RE]], [0 : index]
26 !CHECK: %[[VAL_2:.*]] = fir.insert_value %[[VAL_1]], %[[C_START_IM]], [1 : index]
27 !CHECK: hlfir.assign %[[VAL_2]] to %[[C_DECL]]#0 : !fir.complex<8>, !fir.ref<!fir.complex<8>>
28 !CHECK: omp.parallel reduction(@[[RED_NAME]] %[[C_DECL]]#0 -> %[[PRV:.+]] : !fir.ref<!fir.complex<8>>) {
29 !CHECK: %[[P_DECL:.+]]:2 = hlfir.declare %[[PRV]] {{.*}} : (!fir.ref<!fir.complex<8>>) -> (!fir.ref<!fir.complex<8>>, !fir.ref<!fir.complex<8>>)
30 !CHECK: %[[LPRV:.+]] = fir.load %[[P_DECL]]#0 : !fir.ref<!fir.complex<8>>
31 !CHECK: %[[C_INCR_RE:.*]] = arith.constant 1.000000e+00 : f64
32 !CHECK: %[[C_INCR_IM:.*]] = arith.constant -2.000000e+00 : f64
33 !CHECK: %[[UNDEF_2:.*]] = fir.undefined !fir.complex<8>
34 !CHECK: %[[INCR_1:.*]] = fir.insert_value %[[UNDEF_2]], %[[C_INCR_RE]], [0 : index]
35 !CHECK: %[[INCR_2:.*]] = fir.insert_value %[[INCR_1]], %[[C_INCR_IM]], [1 : index]
36 !CHECK: %[[RES:.+]] = fir.mulc %[[LPRV]], %[[INCR_2]] {{.*}} : !fir.complex<8>
37 !CHECK: hlfir.assign %[[RES]] to %[[P_DECL]]#0 : !fir.complex<8>, !fir.ref<!fir.complex<8>>
38 !CHECK: omp.terminator
39 !CHECK: }
40 !CHECK: return
41 subroutine simple_complex_mul
42 complex(8) :: c
43 c = 0
44
45 !$omp parallel reduction(*:c)
46 c = c * cmplx(1, -2)
47 !$omp end parallel
48
49 print *, c
50 end subroutine