3 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
5 !*** Test forall with multiple assignment statements
6 subroutine test2_forall_construct(a
,b
)
7 real :: a(100,400), b(200,200)
8 forall (i
=1:100, j
=1:200)
9 a(i
,j
) = b(i
,j
) + b(i
+1,j
)
10 a(i
,200+j
) = 1.0 / b(j
, i
)
12 end subroutine test2_forall_construct
14 ! CHECK-LABEL: func @_QPtest2_forall_construct(
15 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x400xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<200x200xf32>>{{.*}}) {
16 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
17 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
18 ! CHECK: %[[VAL_4:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
19 ! CHECK: %[[VAL_5:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
20 ! CHECK: %[[VAL_6:.*]] = arith.constant 100 : index
21 ! CHECK: %[[VAL_7:.*]] = arith.constant 400 : index
22 ! CHECK: %[[VAL_8:.*]] = arith.constant 200 : index
23 ! CHECK: %[[VAL_9:.*]] = arith.constant 200 : index
24 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i32
25 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i32) -> index
26 ! CHECK: %[[VAL_12:.*]] = arith.constant 100 : i32
27 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i32) -> index
28 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
29 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : i32
30 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
31 ! CHECK: %[[VAL_17:.*]] = arith.constant 200 : i32
32 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i32) -> index
33 ! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
34 ! CHECK: %[[VAL_20:.*]] = fir.shape %[[VAL_6]], %[[VAL_7]] : (index, index) -> !fir.shape<2>
35 ! CHECK: %[[VAL_21:.*]] = fir.array_load %[[VAL_0]](%[[VAL_20]]) : (!fir.ref<!fir.array<100x400xf32>>, !fir.shape<2>) -> !fir.array<100x400xf32>
36 ! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_8]], %[[VAL_9]] : (index, index) -> !fir.shape<2>
37 ! CHECK: %[[VAL_23:.*]] = fir.array_load %[[VAL_1]](%[[VAL_22]]) : (!fir.ref<!fir.array<200x200xf32>>, !fir.shape<2>) -> !fir.array<200x200xf32>
38 ! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_8]], %[[VAL_9]] : (index, index) -> !fir.shape<2>
39 ! CHECK: %[[VAL_25:.*]] = fir.array_load %[[VAL_1]](%[[VAL_24]]) : (!fir.ref<!fir.array<200x200xf32>>, !fir.shape<2>) -> !fir.array<200x200xf32>
40 ! CHECK: %[[VAL_26:.*]] = fir.do_loop %[[VAL_27:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_14]] unordered iter_args(%[[VAL_28:.*]] = %[[VAL_21]]) -> (!fir.array<100x400xf32>) {
41 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_27]] : (index) -> i32
42 ! CHECK: fir.store %[[VAL_29]] to %[[VAL_5]] : !fir.ref<i32>
43 ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_16]] to %[[VAL_18]] step %[[VAL_19]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_28]]) -> (!fir.array<100x400xf32>) {
44 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_31]] : (index) -> i32
45 ! CHECK: fir.store %[[VAL_33]] to %[[VAL_4]] : !fir.ref<i32>
46 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
47 ! CHECK: %[[VAL_35:.*]] = fir.load %[[VAL_5]] : !fir.ref<i32>
48 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_35]] : (i32) -> i64
49 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
50 ! CHECK: %[[VAL_38:.*]] = arith.subi %[[VAL_37]], %[[VAL_34]] : index
51 ! CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32>
52 ! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_39]] : (i32) -> i64
53 ! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_40]] : (i64) -> index
54 ! CHECK: %[[VAL_42:.*]] = arith.subi %[[VAL_41]], %[[VAL_34]] : index
55 ! CHECK: %[[VAL_54:.*]] = fir.array_fetch %[[VAL_23]], %[[VAL_38]], %[[VAL_42]] : (!fir.array<200x200xf32>, index, index) -> f32
56 ! CHECK: %[[VAL_43:.*]] = arith.constant 1 : index
57 ! CHECK-DAG: %[[VAL_44:.*]] = fir.load %[[VAL_5]] : !fir.ref<i32>
58 ! CHECK-DAG: %[[VAL_45:.*]] = arith.constant 1 : i32
59 ! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_44]], %[[VAL_45]] : i32
60 ! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_46]] : (i32) -> i64
61 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_47]] : (i64) -> index
62 ! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_48]], %[[VAL_43]] : index
63 ! CHECK: %[[VAL_50:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32>
64 ! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_50]] : (i32) -> i64
65 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_51]] : (i64) -> index
66 ! CHECK: %[[VAL_53:.*]] = arith.subi %[[VAL_52]], %[[VAL_43]] : index
67 ! CHECK: %[[VAL_55:.*]] = fir.array_fetch %[[VAL_25]], %[[VAL_49]], %[[VAL_53]] : (!fir.array<200x200xf32>, index, index) -> f32
68 ! CHECK: %[[VAL_56:.*]] = arith.addf %[[VAL_54]], %[[VAL_55]] {{.*}}: f32
69 ! CHECK: %[[VAL_57:.*]] = arith.constant 1 : index
70 ! CHECK: %[[VAL_58:.*]] = fir.load %[[VAL_5]] : !fir.ref<i32>
71 ! CHECK: %[[VAL_59:.*]] = fir.convert %[[VAL_58]] : (i32) -> i64
72 ! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_59]] : (i64) -> index
73 ! CHECK: %[[VAL_61:.*]] = arith.subi %[[VAL_60]], %[[VAL_57]] : index
74 ! CHECK: %[[VAL_62:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32>
75 ! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_62]] : (i32) -> i64
76 ! CHECK: %[[VAL_64:.*]] = fir.convert %[[VAL_63]] : (i64) -> index
77 ! CHECK: %[[VAL_65:.*]] = arith.subi %[[VAL_64]], %[[VAL_57]] : index
78 ! CHECK: %[[VAL_66:.*]] = fir.array_update %[[VAL_32]], %[[VAL_56]], %[[VAL_61]], %[[VAL_65]] : (!fir.array<100x400xf32>, f32, index, index) -> !fir.array<100x400xf32>
79 ! CHECK: fir.result %[[VAL_66]] : !fir.array<100x400xf32>
81 ! CHECK: fir.result %[[VAL_67:.*]] : !fir.array<100x400xf32>
83 ! CHECK: fir.array_merge_store %[[VAL_21]], %[[VAL_68:.*]] to %[[VAL_0]] : !fir.array<100x400xf32>, !fir.array<100x400xf32>, !fir.ref<!fir.array<100x400xf32>>
84 ! CHECK: %[[VAL_69:.*]] = fir.shape %[[VAL_6]], %[[VAL_7]] : (index, index) -> !fir.shape<2>
85 ! CHECK: %[[VAL_70:.*]] = fir.array_load %[[VAL_0]](%[[VAL_69]]) : (!fir.ref<!fir.array<100x400xf32>>, !fir.shape<2>) -> !fir.array<100x400xf32>
86 ! CHECK: %[[VAL_71:.*]] = fir.shape %[[VAL_8]], %[[VAL_9]] : (index, index) -> !fir.shape<2>
87 ! CHECK: %[[VAL_72:.*]] = fir.array_load %[[VAL_1]](%[[VAL_71]]) : (!fir.ref<!fir.array<200x200xf32>>, !fir.shape<2>) -> !fir.array<200x200xf32>
88 ! CHECK: %[[VAL_73:.*]] = fir.do_loop %[[VAL_74:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_14]] unordered iter_args(%[[VAL_75:.*]] = %[[VAL_70]]) -> (!fir.array<100x400xf32>) {
89 ! CHECK: %[[VAL_76:.*]] = fir.convert %[[VAL_74]] : (index) -> i32
90 ! CHECK: fir.store %[[VAL_76]] to %[[VAL_3]] : !fir.ref<i32>
91 ! CHECK: %[[VAL_77:.*]] = fir.do_loop %[[VAL_78:.*]] = %[[VAL_16]] to %[[VAL_18]] step %[[VAL_19]] unordered iter_args(%[[VAL_79:.*]] = %[[VAL_75]]) -> (!fir.array<100x400xf32>) {
92 ! CHECK: %[[VAL_80:.*]] = fir.convert %[[VAL_78]] : (index) -> i32
93 ! CHECK: fir.store %[[VAL_80]] to %[[VAL_2]] : !fir.ref<i32>
94 ! CHECK: %[[VAL_81:.*]] = arith.constant 1.000000e+00 : f32
95 ! CHECK: %[[VAL_82:.*]] = arith.constant 1 : index
96 ! CHECK: %[[VAL_83:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
97 ! CHECK: %[[VAL_84:.*]] = fir.convert %[[VAL_83]] : (i32) -> i64
98 ! CHECK: %[[VAL_85:.*]] = fir.convert %[[VAL_84]] : (i64) -> index
99 ! CHECK: %[[VAL_86:.*]] = arith.subi %[[VAL_85]], %[[VAL_82]] : index
100 ! CHECK: %[[VAL_87:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
101 ! CHECK: %[[VAL_88:.*]] = fir.convert %[[VAL_87]] : (i32) -> i64
102 ! CHECK: %[[VAL_89:.*]] = fir.convert %[[VAL_88]] : (i64) -> index
103 ! CHECK: %[[VAL_90:.*]] = arith.subi %[[VAL_89]], %[[VAL_82]] : index
104 ! CHECK: %[[VAL_91:.*]] = fir.array_fetch %[[VAL_72]], %[[VAL_86]], %[[VAL_90]] : (!fir.array<200x200xf32>, index, index) -> f32
105 ! CHECK: %[[VAL_92:.*]] = arith.divf %[[VAL_81]], %[[VAL_91]] {{.*}}: f32
106 ! CHECK: %[[VAL_93:.*]] = arith.constant 1 : index
107 ! CHECK: %[[VAL_94:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
108 ! CHECK: %[[VAL_95:.*]] = fir.convert %[[VAL_94]] : (i32) -> i64
109 ! CHECK: %[[VAL_96:.*]] = fir.convert %[[VAL_95]] : (i64) -> index
110 ! CHECK: %[[VAL_97:.*]] = arith.subi %[[VAL_96]], %[[VAL_93]] : index
111 ! CHECK: %[[VAL_98:.*]] = arith.constant 200 : i32
112 ! CHECK: %[[VAL_99:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
113 ! CHECK: %[[VAL_100:.*]] = arith.addi %[[VAL_98]], %[[VAL_99]] : i32
114 ! CHECK: %[[VAL_101:.*]] = fir.convert %[[VAL_100]] : (i32) -> i64
115 ! CHECK: %[[VAL_102:.*]] = fir.convert %[[VAL_101]] : (i64) -> index
116 ! CHECK: %[[VAL_103:.*]] = arith.subi %[[VAL_102]], %[[VAL_93]] : index
117 ! CHECK: %[[VAL_104:.*]] = fir.array_update %[[VAL_79]], %[[VAL_92]], %[[VAL_97]], %[[VAL_103]] : (!fir.array<100x400xf32>, f32, index, index) -> !fir.array<100x400xf32>
118 ! CHECK: fir.result %[[VAL_104]] : !fir.array<100x400xf32>
120 ! CHECK: fir.result %[[VAL_105:.*]] : !fir.array<100x400xf32>
122 ! CHECK: fir.array_merge_store %[[VAL_70]], %[[VAL_106:.*]] to %[[VAL_0]] : !fir.array<100x400xf32>, !fir.array<100x400xf32>, !fir.ref<!fir.array<100x400xf32>>