Debian Codegraph @

flang/test/Lower/OpenMP/sections-reduction.f90

raw
1 ! RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
3
4 subroutine sectionsReduction(x,y)
5 real :: x, y
6
7 !$omp parallel
8 !$omp sections reduction(+:x,y)
9 x = x + 1
10 y = x
11 !$omp section
12 x = x + 2
13 y = x
14 !$omp end sections
15 !$omp end parallel
16
17 !$omp parallel sections reduction(+:x) reduction(+:y)
18 x = x + 1
19 y = x
20 !$omp section
21 x = x + 2
22 y = x
23 !$omp end parallel sections
24 end subroutine
25
26 ! CHECK-LABEL: omp.declare_reduction @add_reduction_f32 : f32 init {
27 ! CHECK: ^bb0(%[[VAL_0:.*]]: f32):
28 ! CHECK: %[[VAL_1:.*]] = arith.constant 0.000000e+00 : f32
29 ! CHECK: omp.yield(%[[VAL_1]] : f32)
30 ! CHECK-LABEL: } combiner {
31 ! CHECK: ^bb0(%[[VAL_0:.*]]: f32, %[[VAL_1:.*]]: f32):
32 ! CHECK: %[[VAL_2:.*]] = arith.addf %[[VAL_0]], %[[VAL_1]] fastmath<contract> : f32
33 ! CHECK: omp.yield(%[[VAL_2]] : f32)
34 ! CHECK: }
35
36 ! CHECK-LABEL: func.func @_QPsectionsreduction(
37 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "x"},
38 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f32> {fir.bindc_name = "y"}) {
39 ! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
40 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QFsectionsreductionEx"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
41 ! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QFsectionsreductionEy"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
42 ! CHECK: omp.parallel {
43 ! CHECK: omp.sections reduction(@add_reduction_f32 -> %[[VAL_3]]#0 : !fir.ref<f32>, @add_reduction_f32 -> %[[VAL_4]]#0 : !fir.ref<f32>) {
44 ! CHECK: ^bb0(%[[VAL_5:.*]]: !fir.ref<f32>, %[[VAL_6:.*]]: !fir.ref<f32>):
45 ! CHECK: omp.section {
46 ! CHECK: ^bb0(%[[VAL_7:.*]]: !fir.ref<f32>, %[[VAL_8:.*]]: !fir.ref<f32>):
47 ! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_7]] {uniq_name = "_QFsectionsreductionEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
48 ! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]] {uniq_name = "_QFsectionsreductionEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
49 ! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<f32>
50 ! CHECK: %[[VAL_12:.*]] = arith.constant 1.000000e+00 : f32
51 ! CHECK: %[[VAL_13:.*]] = arith.addf %[[VAL_11]], %[[VAL_12]] fastmath<contract> : f32
52 ! CHECK: hlfir.assign %[[VAL_13]] to %[[VAL_9]]#0 : f32, !fir.ref<f32>
53 ! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<f32>
54 ! CHECK: hlfir.assign %[[VAL_14]] to %[[VAL_10]]#0 : f32, !fir.ref<f32>
55 ! CHECK: omp.terminator
56 ! CHECK: }
57 ! CHECK: omp.section {
58 ! CHECK: ^bb0(%[[VAL_15:.*]]: !fir.ref<f32>, %[[VAL_16:.*]]: !fir.ref<f32>):
59 ! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsectionsreductionEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
60 ! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_16]] {uniq_name = "_QFsectionsreductionEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
61 ! CHECK: %[[VAL_19:.*]] = fir.load %[[VAL_17]]#0 : !fir.ref<f32>
62 ! CHECK: %[[VAL_20:.*]] = arith.constant 2.000000e+00 : f32
63 ! CHECK: %[[VAL_21:.*]] = arith.addf %[[VAL_19]], %[[VAL_20]] fastmath<contract> : f32
64 ! CHECK: hlfir.assign %[[VAL_21]] to %[[VAL_17]]#0 : f32, !fir.ref<f32>
65 ! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_17]]#0 : !fir.ref<f32>
66 ! CHECK: hlfir.assign %[[VAL_22]] to %[[VAL_18]]#0 : f32, !fir.ref<f32>
67 ! CHECK: omp.terminator
68 ! CHECK: }
69 ! CHECK: omp.terminator
70 ! CHECK: }
71 ! CHECK: omp.terminator
72 ! CHECK: }
73 ! CHECK: omp.parallel {
74 ! CHECK: omp.sections reduction(@add_reduction_f32 -> %[[VAL_3]]#0 : !fir.ref<f32>, @add_reduction_f32 -> %[[VAL_4]]#0 : !fir.ref<f32>) {
75 ! CHECK: ^bb0(%[[VAL_23:.*]]: !fir.ref<f32>, %[[VAL_24:.*]]: !fir.ref<f32>):
76 ! CHECK: omp.section {
77 ! CHECK: ^bb0(%[[VAL_25:.*]]: !fir.ref<f32>, %[[VAL_26:.*]]: !fir.ref<f32>):
78 ! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_25]] {uniq_name = "_QFsectionsreductionEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
79 ! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_26]] {uniq_name = "_QFsectionsreductionEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
80 ! CHECK: %[[VAL_29:.*]] = fir.load %[[VAL_27]]#0 : !fir.ref<f32>
81 ! CHECK: %[[VAL_30:.*]] = arith.constant 1.000000e+00 : f32
82 ! CHECK: %[[VAL_31:.*]] = arith.addf %[[VAL_29]], %[[VAL_30]] fastmath<contract> : f32
83 ! CHECK: hlfir.assign %[[VAL_31]] to %[[VAL_27]]#0 : f32, !fir.ref<f32>
84 ! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_27]]#0 : !fir.ref<f32>
85 ! CHECK: hlfir.assign %[[VAL_32]] to %[[VAL_28]]#0 : f32, !fir.ref<f32>
86 ! CHECK: omp.terminator
87 ! CHECK: }
88 ! CHECK: omp.section {
89 ! CHECK: ^bb0(%[[VAL_33:.*]]: !fir.ref<f32>, %[[VAL_34:.*]]: !fir.ref<f32>):
90 ! CHECK: %[[VAL_35:.*]]:2 = hlfir.declare %[[VAL_33]] {uniq_name = "_QFsectionsreductionEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
91 ! CHECK: %[[VAL_36:.*]]:2 = hlfir.declare %[[VAL_34]] {uniq_name = "_QFsectionsreductionEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
92 ! CHECK: %[[VAL_37:.*]] = fir.load %[[VAL_35]]#0 : !fir.ref<f32>
93 ! CHECK: %[[VAL_38:.*]] = arith.constant 2.000000e+00 : f32
94 ! CHECK: %[[VAL_39:.*]] = arith.addf %[[VAL_37]], %[[VAL_38]] fastmath<contract> : f32
95 ! CHECK: hlfir.assign %[[VAL_39]] to %[[VAL_35]]#0 : f32, !fir.ref<f32>
96 ! CHECK: %[[VAL_40:.*]] = fir.load %[[VAL_35]]#0 : !fir.ref<f32>
97 ! CHECK: hlfir.assign %[[VAL_40]] to %[[VAL_36]]#0 : f32, !fir.ref<f32>
98 ! CHECK: omp.terminator
99 ! CHECK: }
100 ! CHECK: omp.terminator
101 ! CHECK: }
102 ! CHECK: omp.terminator
103 ! CHECK: }
104 ! CHECK: return
105 ! CHECK: }