1 ! This test checks a few bug fixes in the PRIVATE clause lowering
3 ! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
5 ! CHECK-LABEL: multiple_private_fix
6 ! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFmultiple_private_fixEi"}
7 ! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFmultiple_private_fixEj"}
8 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFmultiple_private_fixEx"}
9 ! CHECK: omp.parallel {
10 ! CHECK: %[[PRIV_J:.*]] = fir.alloca i32 {bindc_name = "j", pinned
11 ! CHECK: %[[PRIV_X:.*]] = fir.alloca i32 {bindc_name = "x", pinned
12 ! CHECK: %[[PRIV_I:.*]] = fir.alloca i32 {{{.*}}, pinned
13 ! CHECK: %[[ONE:.*]] = arith.constant 1 : i32
14 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_4:.*]] : !fir.ref<i32>
15 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32
16 ! CHECK: omp.wsloop for (%[[VAL_6:.*]]) : i32 = (%[[ONE]]) to (%[[VAL_3]]) inclusive step (%[[VAL_5]]) {
17 ! CHECK: fir.store %[[VAL_6]] to %[[PRIV_I]] : !fir.ref<i32>
18 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : i32
19 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index
20 ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32>
21 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
22 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
23 ! CHECK: %[[LB:.*]] = fir.convert %[[VAL_8]] : (index) -> i32
24 ! CHECK: %[[VAL_12:.*]]:2 = fir.do_loop %[[VAL_13:[^ ]*]] =
25 ! CHECK-SAME: %[[VAL_8]] to %[[VAL_10]] step %[[VAL_11]]
26 ! CHECK-SAME: iter_args(%[[IV:.*]] = %[[LB]]) -> (index, i32) {
27 ! CHECK: fir.store %[[IV]] to %[[PRIV_J]] : !fir.ref<i32>
28 ! CHECK: %[[LOAD:.*]] = fir.load %[[PRIV_I]] : !fir.ref<i32>
29 ! CHECK: %[[VAL_15:.*]] = fir.load %[[PRIV_J]] : !fir.ref<i32>
30 ! CHECK: %[[VAL_16:.*]] = arith.addi %[[LOAD]], %[[VAL_15]] : i32
31 ! CHECK: fir.store %[[VAL_16]] to %[[PRIV_X]] : !fir.ref<i32>
32 ! CHECK: %[[VAL_17:.*]] = arith.addi %[[VAL_13]], %[[VAL_11]] : index
33 ! CHECK: %[[STEPCAST:.*]] = fir.convert %[[VAL_11]] : (index) -> i32
34 ! CHECK: %[[IVLOAD:.*]] = fir.load %[[PRIV_J]] : !fir.ref<i32>
35 ! CHECK: %[[IVINC:.*]] = arith.addi %[[IVLOAD]], %[[STEPCAST]]
36 ! CHECK: fir.result %[[VAL_17]], %[[IVINC]] : index, i32
38 ! CHECK: fir.store %[[VAL_12]]#1 to %[[PRIV_J]] : !fir.ref<i32>
41 ! CHECK: omp.terminator
44 subroutine multiple_private_fix(gama
)
45 integer :: i
, j
, x
, gama
46 !$OMP PARALLEL DO PRIVATE(j,x)
55 ! CHECK-LABEL: multiple_private_fix2
56 ! CHECK: %[[X1:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFmultiple_private_fix2Ex"}
57 ! CHECK: omp.parallel {
58 ! CHECK: %[[X2:.*]] = fir.alloca i32 {bindc_name = "x", pinned, uniq_name = "_QFmultiple_private_fix2Ex"}
59 ! CHECK: omp.parallel {
60 ! CHECK: %[[X3:.*]] = fir.alloca i32 {bindc_name = "x", pinned, uniq_name = "_QFmultiple_private_fix2Ex"}
61 ! CHECK: %[[C3:.*]] = arith.constant 1 : i32
62 ! CHECK: fir.store %[[C3]] to %[[X3]] : !fir.ref<i32>
63 ! CHECK: omp.terminator
65 ! CHECK: %[[C2:.*]] = arith.constant 1 : i32
66 ! CHECK: fir.store %[[C2]] to %[[X2]] : !fir.ref<i32>
67 ! CHECK: omp.terminator
69 ! CHECK: %[[C1:.*]] = arith.constant 1 : i32
70 ! CHECK: fir.store %[[C1]] to %[[X1]] : !fir.ref<i32>
72 subroutine multiple_private_fix2()
74 !$omp parallel private(x)
75 !$omp parallel private(x)