| 1 |
! This test checks lowering of `COPYIN` clause. |
| 2 |
! Note: The test is autogenerated. |
| 3 |
|
| 4 |
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s |
| 5 |
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s |
| 6 |
|
| 7 |
|
| 8 |
! CHECK-LABEL: func.func @_QPcopyin_scalar_array() { |
| 9 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QFcopyin_scalar_arrayEx1) : !fir.ref<i32> |
| 10 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFcopyin_scalar_arrayEx1"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 11 |
! CHECK: %[[VAL_2:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 12 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFcopyin_scalar_arrayEx1"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 13 |
! CHECK: %[[VAL_4:.*]] = fir.address_of(@_QFcopyin_scalar_arrayEx2) : !fir.ref<!fir.array<10xi64>> |
| 14 |
! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index |
| 15 |
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1> |
| 16 |
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_6]]) {uniq_name = "_QFcopyin_scalar_arrayEx2"} : (!fir.ref<!fir.array<10xi64>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>>) |
| 17 |
! CHECK: %[[VAL_8:.*]] = omp.threadprivate %[[VAL_7]]#1 : !fir.ref<!fir.array<10xi64>> -> !fir.ref<!fir.array<10xi64>> |
| 18 |
! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1> |
| 19 |
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]](%[[VAL_9]]) {uniq_name = "_QFcopyin_scalar_arrayEx2"} : (!fir.ref<!fir.array<10xi64>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>>) |
| 20 |
! CHECK: omp.parallel { |
| 21 |
! CHECK: %[[VAL_11:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 22 |
! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_11]] {uniq_name = "_QFcopyin_scalar_arrayEx1"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 23 |
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32> |
| 24 |
! CHECK: hlfir.assign %[[VAL_13]] to %[[VAL_12]]#0 temporary_lhs : i32, !fir.ref<i32> |
| 25 |
! CHECK: %[[VAL_14:.*]] = omp.threadprivate %[[VAL_7]]#1 : !fir.ref<!fir.array<10xi64>> -> !fir.ref<!fir.array<10xi64>> |
| 26 |
! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1> |
| 27 |
! CHECK: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_14]](%[[VAL_15]]) {uniq_name = "_QFcopyin_scalar_arrayEx2"} : (!fir.ref<!fir.array<10xi64>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>>) |
| 28 |
! CHECK: hlfir.assign %[[VAL_10]]#0 to %[[VAL_16]]#0 temporary_lhs : !fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10xi64>> |
| 29 |
! CHECK: omp.barrier |
| 30 |
! CHECK: fir.call @_QPsub1(%[[VAL_12]]#1, %[[VAL_16]]#1) fastmath<contract> : (!fir.ref<i32>, !fir.ref<!fir.array<10xi64>>) -> () |
| 31 |
! CHECK: omp.terminator |
| 32 |
! CHECK: } |
| 33 |
! CHECK: return |
| 34 |
! CHECK: } |
| 35 |
|
| 36 |
subroutine copyin_scalar_array() |
| 37 |
integer(kind=4), save :: x1 |
| 38 |
integer(kind=8), save :: x2(10) |
| 39 |
!$omp threadprivate(x1, x2) |
| 40 |
|
| 41 |
!$omp parallel copyin(x1) copyin(x2) |
| 42 |
call sub1(x1, x2) |
| 43 |
!$omp end parallel |
| 44 |
|
| 45 |
end |
| 46 |
|
| 47 |
! CHECK-LABEL: func.func @_QPcopyin_char_chararray() { |
| 48 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QFcopyin_char_chararrayEx3) : !fir.ref<!fir.char<1,5>> |
| 49 |
! CHECK: %[[VAL_1:.*]] = arith.constant 5 : index |
| 50 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_1]] {uniq_name = "_QFcopyin_char_chararrayEx3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>) |
| 51 |
! CHECK: %[[VAL_3:.*]] = omp.threadprivate %[[VAL_2]]#1 : !fir.ref<!fir.char<1,5>> -> !fir.ref<!fir.char<1,5>> |
| 52 |
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] typeparams %[[VAL_1]] {uniq_name = "_QFcopyin_char_chararrayEx3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>) |
| 53 |
! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QFcopyin_char_chararrayEx4) : !fir.ref<!fir.array<10x!fir.char<1,5>>> |
| 54 |
! CHECK: %[[VAL_6:.*]] = arith.constant 5 : index |
| 55 |
! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index |
| 56 |
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1> |
| 57 |
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_8]]) typeparams %[[VAL_6]] {uniq_name = "_QFcopyin_char_chararrayEx4"} : (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>>) |
| 58 |
! CHECK: %[[VAL_10:.*]] = omp.threadprivate %[[VAL_9]]#1 : !fir.ref<!fir.array<10x!fir.char<1,5>>> -> !fir.ref<!fir.array<10x!fir.char<1,5>>> |
| 59 |
! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1> |
| 60 |
! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_10]](%[[VAL_11]]) typeparams %[[VAL_6]] {uniq_name = "_QFcopyin_char_chararrayEx4"} : (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>>) |
| 61 |
! CHECK: omp.parallel { |
| 62 |
! CHECK: %[[VAL_13:.*]] = omp.threadprivate %[[VAL_2]]#1 : !fir.ref<!fir.char<1,5>> -> !fir.ref<!fir.char<1,5>> |
| 63 |
! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_13]] typeparams %[[VAL_1]] {uniq_name = "_QFcopyin_char_chararrayEx3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>) |
| 64 |
! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_14]]#0 temporary_lhs : !fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>> |
| 65 |
! CHECK: %[[VAL_15:.*]] = omp.threadprivate %[[VAL_9]]#1 : !fir.ref<!fir.array<10x!fir.char<1,5>>> -> !fir.ref<!fir.array<10x!fir.char<1,5>>> |
| 66 |
! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1> |
| 67 |
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]](%[[VAL_16]]) typeparams %[[VAL_6]] {uniq_name = "_QFcopyin_char_chararrayEx4"} : (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>>) |
| 68 |
! CHECK: hlfir.assign %[[VAL_12]]#0 to %[[VAL_17]]#0 temporary_lhs : !fir.ref<!fir.array<10x!fir.char<1,5>>>, !fir.ref<!fir.array<10x!fir.char<1,5>>> |
| 69 |
! CHECK: omp.barrier |
| 70 |
! CHECK: %[[VAL_18:.*]] = fir.emboxchar %[[VAL_14]]#1, %[[VAL_1]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1> |
| 71 |
! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,5>>>) -> !fir.ref<!fir.char<1,5>> |
| 72 |
! CHECK: %[[VAL_20:.*]] = fir.emboxchar %[[VAL_19]], %[[VAL_6]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1> |
| 73 |
! CHECK: fir.call @_QPsub2(%[[VAL_18]], %[[VAL_20]]) fastmath<contract> : (!fir.boxchar<1>, !fir.boxchar<1>) -> () |
| 74 |
! CHECK: omp.terminator |
| 75 |
! CHECK: } |
| 76 |
! CHECK: return |
| 77 |
! CHECK: } |
| 78 |
subroutine copyin_char_chararray() |
| 79 |
character(5), save :: x3, x4(10) |
| 80 |
!$omp threadprivate(x3, x4) |
| 81 |
|
| 82 |
!$omp parallel copyin(x3) copyin(x4) |
| 83 |
call sub2(x3, x4) |
| 84 |
!$omp end parallel |
| 85 |
|
| 86 |
end |
| 87 |
|
| 88 |
! CHECK-LABEL: func.func @_QPcopyin_derived_type() { |
| 89 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QFcopyin_derived_typeE.b.my_type.t_arr) : !fir.ref<!fir.array<2x1x!fir.type<_QM__fortran_type_infoTvalue{genre:i8,__padding0:!fir.array<7xi8>,value:i64}>>> |
| 90 |
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : index |
| 91 |
! CHECK: %[[VAL_2:.*]] = arith.constant 2 : index |
| 92 |
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index |
| 93 |
! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index |
| 94 |
! CHECK: %[[VAL_5:.*]] = fir.shape_shift %[[VAL_1]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]] : (index, index, index, index) -> !fir.shapeshift<2> |
| 95 |
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_5]]) {{{.*}}, uniq_name = "_QFcopyin_derived_typeE.b.my_type.t_arr"} |
| 96 |
! CHECK: %[[VAL_7:.*]] = fir.address_of(@_QFcopyin_derived_typeE.n.t_i) : !fir.ref<!fir.char<1,3>> |
| 97 |
! CHECK: %[[VAL_8:.*]] = arith.constant 3 : index |
| 98 |
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_7]] typeparams %[[VAL_8]] {{{.*}}, uniq_name = "_QFcopyin_derived_typeE.n.t_i"} |
| 99 |
! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QFcopyin_derived_typeE.n.t_arr) : !fir.ref<!fir.char<1,5>> |
| 100 |
! CHECK: %[[VAL_11:.*]] = arith.constant 5 : index |
| 101 |
! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_10]] typeparams %[[VAL_11]] {{{.*}}, uniq_name = "_QFcopyin_derived_typeE.n.t_arr"} |
| 102 |
! CHECK: %[[VAL_13:.*]] = fir.address_of(@_QFcopyin_derived_typeE.n.my_type) : !fir.ref<!fir.char<1,7>> |
| 103 |
! CHECK: %[[VAL_14:.*]] = arith.constant 7 : index |
| 104 |
! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_13]] typeparams %[[VAL_14]] {{{.*}}, uniq_name = "_QFcopyin_derived_typeE.n.my_type"} |
| 105 |
! CHECK: %[[VAL_16:.*]] = fir.address_of(@_QFcopyin_derived_typeEx5) : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> |
| 106 |
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_16]] {uniq_name = "_QFcopyin_derived_typeEx5"} : (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) -> (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) |
| 107 |
! CHECK: %[[VAL_18:.*]] = omp.threadprivate %[[VAL_17]]#1 : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> -> !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> |
| 108 |
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFcopyin_derived_typeEx5"} : (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) -> (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) |
| 109 |
! CHECK: %[[VAL_20:.*]] = fir.address_of(@_QFcopyin_derived_typeE.c.my_type) |
| 110 |
! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index |
| 111 |
! CHECK: %[[VAL_22:.*]] = arith.constant 2 : index |
| 112 |
! CHECK: %[[VAL_23:.*]] = fir.shape_shift %[[VAL_21]], %[[VAL_22]] : (index, index) -> !fir.shapeshift<1> |
| 113 |
! CHECK: %[[VAL_24:.*]]:2 = hlfir.declare %[[VAL_20]](%[[VAL_23]]) {{{.*}}, uniq_name = "_QFcopyin_derived_typeE.c.my_type"} |
| 114 |
! CHECK: %[[VAL_25:.*]] = fir.address_of(@_QFcopyin_derived_typeE.dt.my_type) |
| 115 |
! CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_25]] {{{.*}}, uniq_name = "_QFcopyin_derived_typeE.dt.my_type"} |
| 116 |
! CHECK: omp.parallel { |
| 117 |
! CHECK: %[[VAL_27:.*]] = omp.threadprivate %[[VAL_17]]#1 : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> -> !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> |
| 118 |
! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_27]] {uniq_name = "_QFcopyin_derived_typeEx5"} : (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) -> (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) |
| 119 |
! CHECK: hlfir.assign %[[VAL_19]]#0 to %[[VAL_28]]#0 temporary_lhs : !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>, !fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>> |
| 120 |
! CHECK: omp.barrier |
| 121 |
! CHECK: fir.call @_QPsub3(%[[VAL_28]]#1) fastmath<contract> : (!fir.ref<!fir.type<_QFcopyin_derived_typeTmy_type{t_i:i32,t_arr:!fir.array<5xi32>}>>) -> () |
| 122 |
! CHECK: omp.terminator |
| 123 |
! CHECK: } |
| 124 |
! CHECK: return |
| 125 |
! CHECK: } |
| 126 |
|
| 127 |
subroutine copyin_derived_type() |
| 128 |
type my_type |
| 129 |
integer :: t_i |
| 130 |
integer :: t_arr(5) |
| 131 |
end type my_type |
| 132 |
type(my_type), save :: x5 |
| 133 |
!$omp threadprivate(x5) |
| 134 |
|
| 135 |
!$omp parallel copyin(x5) |
| 136 |
call sub3(x5) |
| 137 |
!$omp end parallel |
| 138 |
|
| 139 |
end |
| 140 |
|
| 141 |
! CHECK-LABEL: func.func @_QPcombined_parallel_worksharing_loop() { |
| 142 |
! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcombined_parallel_worksharing_loopEi"} |
| 143 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFcombined_parallel_worksharing_loopEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 144 |
! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QFcombined_parallel_worksharing_loopEx6) : !fir.ref<i32> |
| 145 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFcombined_parallel_worksharing_loopEx6"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 146 |
! CHECK: %[[VAL_4:.*]] = omp.threadprivate %[[VAL_3]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 147 |
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFcombined_parallel_worksharing_loopEx6"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 148 |
! CHECK: omp.parallel { |
| 149 |
|
| 150 |
! CHECK: %[[VAL_8:.*]] = omp.threadprivate %[[VAL_3]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 151 |
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] {uniq_name = "_QFcombined_parallel_worksharing_loopEx6"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 152 |
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<i32> |
| 153 |
! CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_9]]#0 temporary_lhs : i32, !fir.ref<i32> |
| 154 |
|
| 155 |
! CHECK: omp.barrier |
| 156 |
|
| 157 |
! CHECK: %[[VAL_6:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}} |
| 158 |
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFcombined_parallel_worksharing_loopEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 159 |
|
| 160 |
! CHECK: %[[VAL_11:.*]] = arith.constant 1 : i32 |
| 161 |
! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<i32> |
| 162 |
! CHECK: %[[VAL_13:.*]] = arith.constant 1 : i32 |
| 163 |
! CHECK: omp.wsloop { |
| 164 |
! CHECK-NEXT: omp.loop_nest (%[[VAL_14:.*]]) : i32 = (%[[VAL_11]]) to (%[[VAL_12]]) inclusive step (%[[VAL_13]]) { |
| 165 |
! CHECK: fir.store %[[VAL_14]] to %[[VAL_7]]#1 : !fir.ref<i32> |
| 166 |
! CHECK: fir.call @_QPsub4(%[[VAL_9]]#1) fastmath<contract> : (!fir.ref<i32>) -> () |
| 167 |
! CHECK: omp.yield |
| 168 |
! CHECK: } |
| 169 |
! CHECK: omp.terminator |
| 170 |
! CHECK: } |
| 171 |
! CHECK: omp.terminator |
| 172 |
! CHECK: } |
| 173 |
! CHECK: return |
| 174 |
! CHECK: } |
| 175 |
|
| 176 |
subroutine combined_parallel_worksharing_loop() |
| 177 |
integer, save :: x6 |
| 178 |
!$omp threadprivate(x6) |
| 179 |
|
| 180 |
!$omp parallel do copyin(x6) |
| 181 |
do i=1, x6 |
| 182 |
call sub4(x6) |
| 183 |
end do |
| 184 |
!$omp end parallel do |
| 185 |
|
| 186 |
end |
| 187 |
|
| 188 |
! CHECK-LABEL: func.func @_QPcombined_parallel_sections() { |
| 189 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QFcombined_parallel_sectionsEx7) : !fir.ref<i32> |
| 190 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFcombined_parallel_sectionsEx7"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 191 |
! CHECK: %[[VAL_2:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 192 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFcombined_parallel_sectionsEx7"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 193 |
! CHECK: omp.parallel { |
| 194 |
! CHECK: %[[VAL_4:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 195 |
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFcombined_parallel_sectionsEx7"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 196 |
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32> |
| 197 |
! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_5]]#0 temporary_lhs : i32, !fir.ref<i32> |
| 198 |
! CHECK: omp.barrier |
| 199 |
! CHECK: omp.sections { |
| 200 |
! CHECK: omp.section { |
| 201 |
! CHECK: fir.call @_QPsub5(%[[VAL_5]]#1) fastmath<contract> : (!fir.ref<i32>) -> () |
| 202 |
! CHECK: omp.terminator |
| 203 |
! CHECK: } |
| 204 |
! CHECK: omp.section { |
| 205 |
! CHECK: fir.call @_QPsub6(%[[VAL_5]]#1) fastmath<contract> : (!fir.ref<i32>) -> () |
| 206 |
! CHECK: omp.terminator |
| 207 |
! CHECK: } |
| 208 |
! CHECK: omp.terminator |
| 209 |
! CHECK: } |
| 210 |
! CHECK: omp.terminator |
| 211 |
! CHECK: } |
| 212 |
! CHECK: return |
| 213 |
! CHECK: } |
| 214 |
subroutine combined_parallel_sections() |
| 215 |
integer, save :: x7 |
| 216 |
!$omp threadprivate(x7) |
| 217 |
|
| 218 |
!$omp parallel sections copyin(x7) |
| 219 |
!$omp section |
| 220 |
call sub5(x7) |
| 221 |
!$omp section |
| 222 |
call sub6(x7) |
| 223 |
!$omp end parallel sections |
| 224 |
|
| 225 |
end |
| 226 |
|
| 227 |
! CHECK-LABEL: func.func @_QPcommon_1() { |
| 228 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<4xi8>> |
| 229 |
! CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 230 |
! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index |
| 231 |
! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 232 |
! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 233 |
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 234 |
! CHECK: %[[VAL_6:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>> |
| 235 |
! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 236 |
! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index |
| 237 |
! CHECK: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_7]], %[[VAL_8]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 238 |
! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 239 |
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 240 |
! CHECK: %[[VAL_12:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFcommon_1Ey"} |
| 241 |
! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {uniq_name = "_QFcommon_1Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 242 |
! CHECK: omp.parallel { |
| 243 |
! CHECK: %[[VAL_14:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>> |
| 244 |
! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 245 |
! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index |
| 246 |
! CHECK: %[[VAL_17:.*]] = fir.coordinate_of %[[VAL_15]], %[[VAL_16]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 247 |
! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 248 |
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFcommon_1Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 249 |
! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_11]]#0 : !fir.ref<i32> |
| 250 |
! CHECK: hlfir.assign %[[VAL_20]] to %[[VAL_19]]#0 temporary_lhs : i32, !fir.ref<i32> |
| 251 |
! CHECK: omp.barrier |
| 252 |
! CHECK: omp.sections { |
| 253 |
! CHECK: omp.section { |
| 254 |
! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_19]]#0 : !fir.ref<i32> |
| 255 |
! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i32 |
| 256 |
! CHECK: %[[VAL_23:.*]] = arith.addi %[[VAL_21]], %[[VAL_22]] : i32 |
| 257 |
! CHECK: hlfir.assign %[[VAL_23]] to %[[VAL_13]]#0 : i32, !fir.ref<i32> |
| 258 |
! CHECK: omp.terminator |
| 259 |
! CHECK: } |
| 260 |
! CHECK: omp.section { |
| 261 |
! CHECK: %[[VAL_24:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<i32> |
| 262 |
! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<i32> |
| 263 |
! CHECK: %[[VAL_26:.*]] = arith.muli %[[VAL_24]], %[[VAL_25]] : i32 |
| 264 |
! CHECK: hlfir.assign %[[VAL_26]] to %[[VAL_19]]#0 : i32, !fir.ref<i32> |
| 265 |
! CHECK: omp.terminator |
| 266 |
! CHECK: } |
| 267 |
! CHECK: omp.terminator |
| 268 |
! CHECK: } |
| 269 |
! CHECK: omp.terminator |
| 270 |
! CHECK: } |
| 271 |
! CHECK: return |
| 272 |
! CHECK: } |
| 273 |
subroutine common_1() |
| 274 |
integer :: x |
| 275 |
integer :: y |
| 276 |
common /c/ x |
| 277 |
!$omp threadprivate(/c/) |
| 278 |
|
| 279 |
!$omp parallel sections copyin(/c/) |
| 280 |
!$omp section |
| 281 |
y = x + 1 |
| 282 |
!$omp section |
| 283 |
x = y * y |
| 284 |
!$omp end parallel sections |
| 285 |
end subroutine |
| 286 |
|
| 287 |
! CHECK-LABEL: func.func @_QPcommon_2() { |
| 288 |
! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcommon_2Ei"} |
| 289 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFcommon_2Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 290 |
! CHECK: %[[VAL_2:.*]] = fir.address_of(@d_) : !fir.ref<!fir.array<8xi8>> |
| 291 |
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 292 |
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index |
| 293 |
! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_4]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 294 |
! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 295 |
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFcommon_2Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 296 |
! CHECK: %[[VAL_8:.*]] = omp.threadprivate %[[VAL_2]] : !fir.ref<!fir.array<8xi8>> -> !fir.ref<!fir.array<8xi8>> |
| 297 |
! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 298 |
! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index |
| 299 |
! CHECK: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_10]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 300 |
! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 301 |
! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {uniq_name = "_QFcommon_2Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 302 |
! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 303 |
! CHECK: %[[VAL_15:.*]] = arith.constant 4 : index |
| 304 |
! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_14]], %[[VAL_15]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 305 |
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 306 |
! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_17]] {uniq_name = "_QFcommon_2Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 307 |
! CHECK: omp.parallel { |
| 308 |
|
| 309 |
! CHECK: %[[VAL_21:.*]] = omp.threadprivate %[[VAL_2]] : !fir.ref<!fir.array<8xi8>> -> !fir.ref<!fir.array<8xi8>> |
| 310 |
! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 311 |
! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index |
| 312 |
! CHECK: %[[VAL_24:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_23]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 313 |
! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 314 |
! CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_25]] {uniq_name = "_QFcommon_2Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 315 |
! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_21]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>> |
| 316 |
! CHECK: %[[VAL_28:.*]] = arith.constant 4 : index |
| 317 |
! CHECK: %[[VAL_29:.*]] = fir.coordinate_of %[[VAL_27]], %[[VAL_28]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> |
| 318 |
! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<i8>) -> !fir.ref<i32> |
| 319 |
! CHECK: %[[VAL_31:.*]]:2 = hlfir.declare %[[VAL_30]] {uniq_name = "_QFcommon_2Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 320 |
! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<i32> |
| 321 |
! CHECK: hlfir.assign %[[VAL_32]] to %[[VAL_26]]#0 temporary_lhs : i32, !fir.ref<i32> |
| 322 |
! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_18]]#0 : !fir.ref<i32> |
| 323 |
! CHECK: hlfir.assign %[[VAL_33]] to %[[VAL_31]]#0 temporary_lhs : i32, !fir.ref<i32> |
| 324 |
! CHECK: omp.barrier |
| 325 |
|
| 326 |
! CHECK: %[[VAL_19:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}} |
| 327 |
! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]] {uniq_name = "_QFcommon_2Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 328 |
|
| 329 |
! CHECK: %[[VAL_34:.*]] = arith.constant 1 : i32 |
| 330 |
! CHECK: %[[VAL_35:.*]] = fir.load %[[VAL_26]]#0 : !fir.ref<i32> |
| 331 |
! CHECK: %[[VAL_36:.*]] = arith.constant 1 : i32 |
| 332 |
! CHECK: omp.wsloop { |
| 333 |
! CHECK-NEXT: omp.loop_nest (%[[VAL_37:.*]]) : i32 = (%[[VAL_34]]) to (%[[VAL_35]]) inclusive step (%[[VAL_36]]) { |
| 334 |
! CHECK: fir.store %[[VAL_37]] to %[[VAL_20]]#1 : !fir.ref<i32> |
| 335 |
! CHECK: %[[VAL_38:.*]] = fir.load %[[VAL_31]]#0 : !fir.ref<i32> |
| 336 |
! CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_20]]#0 : !fir.ref<i32> |
| 337 |
! CHECK: %[[VAL_40:.*]] = arith.addi %[[VAL_38]], %[[VAL_39]] : i32 |
| 338 |
! CHECK: hlfir.assign %[[VAL_40]] to %[[VAL_31]]#0 : i32, !fir.ref<i32> |
| 339 |
! CHECK: omp.yield |
| 340 |
! CHECK: } |
| 341 |
! CHECK: omp.terminator |
| 342 |
! CHECK: } |
| 343 |
! CHECK: omp.terminator |
| 344 |
! CHECK: } |
| 345 |
! CHECK: return |
| 346 |
! CHECK: } |
| 347 |
subroutine common_2() |
| 348 |
integer :: x |
| 349 |
integer :: y |
| 350 |
common /d/ x, y |
| 351 |
!$omp threadprivate(/d/) |
| 352 |
|
| 353 |
!$omp parallel do copyin(/d/) |
| 354 |
do i = 1, x |
| 355 |
y = y + i |
| 356 |
end do |
| 357 |
!$omp end parallel do |
| 358 |
end subroutine |