[flang][openacc] Use OpenACC terminator instead of fir.unreachable after Stop stmt...
[llvm-project.git] / flang / test / Lower / array-constructor-index.f90
blob8332fc5f7209179588d33383a92b0796a4631a74
1 ! Check that the implied-do index value is converted to proper type.
2 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
4 function test1(k)
5 integer*1 :: k
6 integer*1 :: test1(4)
7 test1 = ([(i*k, integer(8)::i=1,4)])
8 end function test1
9 ! CHECK-LABEL: func.func @_QPtest1(
10 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i8> {fir.bindc_name = "k"}) -> !fir.array<4xi8> {
11 ! CHECK: %[[VAL_1:.*]] = fir.alloca index {bindc_name = ".buff.pos"}
12 ! CHECK: %[[VAL_2:.*]] = fir.alloca index {bindc_name = ".buff.size"}
13 ! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
14 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.array<4xi8> {bindc_name = "test1", uniq_name = "_QFtest1Etest1"}
15 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
16 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_4]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xi8>>, !fir.shape<1>) -> !fir.array<4xi8>
17 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
18 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<index>
19 ! CHECK: %[[VAL_8:.*]] = fir.allocmem !fir.array<4xi64>
20 ! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
21 ! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<index>
22 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
23 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
24 ! CHECK: %[[VAL_12:.*]] = arith.constant 4 : i64
25 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
26 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i64
27 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
28 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_15]] iter_args(%[[VAL_18:.*]] = %[[VAL_8]]) -> (!fir.heap<!fir.array<4xi64>>) {
29 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
30 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_0]] : !fir.ref<i8>
31 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i8) -> i64
32 ! CHECK: %[[VAL_22:.*]] = arith.muli %[[VAL_19]], %[[VAL_21]] : i64
33 ! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
34 ! CHECK: %[[VAL_24:.*]] = fir.zero_bits !fir.ref<!fir.array<4xi64>>
35 ! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_24]], %[[VAL_23]] : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
36 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<i64>) -> index
37 ! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
38 ! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_2]] : !fir.ref<index>
39 ! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
40 ! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_27]], %[[VAL_29]] : index
41 ! CHECK: %[[VAL_31:.*]] = arith.cmpi sle, %[[VAL_28]], %[[VAL_30]] : index
42 ! CHECK: %[[VAL_32:.*]] = fir.if %[[VAL_31]] -> (!fir.heap<!fir.array<4xi64>>) {
43 ! CHECK: %[[VAL_33:.*]] = arith.constant 2 : index
44 ! CHECK: %[[VAL_34:.*]] = arith.muli %[[VAL_30]], %[[VAL_33]] : index
45 ! CHECK: fir.store %[[VAL_34]] to %[[VAL_2]] : !fir.ref<index>
46 ! CHECK: %[[VAL_35:.*]] = arith.muli %[[VAL_34]], %[[VAL_26]] : index
47 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<4xi64>>) -> !fir.ref<i8>
48 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
49 ! CHECK: %[[VAL_38:.*]] = fir.call @realloc(%[[VAL_36]], %[[VAL_37]]) fastmath<contract> : (!fir.ref<i8>, i64) -> !fir.ref<i8>
50 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<i8>) -> !fir.heap<!fir.array<4xi64>>
51 ! CHECK: fir.result %[[VAL_39]] : !fir.heap<!fir.array<4xi64>>
52 ! CHECK: } else {
53 ! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<4xi64>>
54 ! CHECK: }
55 ! CHECK: %[[VAL_40:.*]] = fir.coordinate_of %[[VAL_41:.*]], %[[VAL_27]] : (!fir.heap<!fir.array<4xi64>>, index) -> !fir.ref<i64>
56 ! CHECK: fir.store %[[VAL_22]] to %[[VAL_40]] : !fir.ref<i64>
57 ! CHECK: fir.store %[[VAL_30]] to %[[VAL_1]] : !fir.ref<index>
58 ! CHECK: fir.result %[[VAL_41]] : !fir.heap<!fir.array<4xi64>>
59 ! CHECK: }
60 ! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
61 ! CHECK: %[[VAL_43:.*]] = fir.shape %[[VAL_42]] : (index) -> !fir.shape<1>
62 ! CHECK: %[[VAL_44:.*]] = fir.array_load %[[VAL_45:.*]](%[[VAL_43]]) : (!fir.heap<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
63 ! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
64 ! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
65 ! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_3]], %[[VAL_46]] : index
66 ! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_47]] to %[[VAL_48]] step %[[VAL_46]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_6]]) -> (!fir.array<4xi8>) {
67 ! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_44]], %[[VAL_50]] : (!fir.array<4xi64>, index) -> i64
68 ! CHECK: %[[VAL_53:.*]] = fir.no_reassoc %[[VAL_52]] : i64
69 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i8
70 ! CHECK: %[[VAL_55:.*]] = fir.array_update %[[VAL_51]], %[[VAL_54]], %[[VAL_50]] : (!fir.array<4xi8>, i8, index) -> !fir.array<4xi8>
71 ! CHECK: fir.result %[[VAL_55]] : !fir.array<4xi8>
72 ! CHECK: }
73 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_56:.*]] to %[[VAL_4]] : !fir.array<4xi8>, !fir.array<4xi8>, !fir.ref<!fir.array<4xi8>>
74 ! CHECK: fir.freemem %[[VAL_45]] : !fir.heap<!fir.array<4xi64>>
75 ! CHECK: %[[VAL_57:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.array<4xi8>>
76 ! CHECK: return %[[VAL_57]] : !fir.array<4xi8>
77 ! CHECK: }
79 function test2(k)
80 integer*2 :: k
81 integer*2 :: test2(4)
82 test2 = ([(i*k, integer(8)::i=1,4)])
83 end function test2
84 ! CHECK-LABEL: func.func @_QPtest2(
85 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i16> {fir.bindc_name = "k"}) -> !fir.array<4xi16> {
86 ! CHECK: %[[VAL_1:.*]] = fir.alloca index {bindc_name = ".buff.pos"}
87 ! CHECK: %[[VAL_2:.*]] = fir.alloca index {bindc_name = ".buff.size"}
88 ! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
89 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.array<4xi16> {bindc_name = "test2", uniq_name = "_QFtest2Etest2"}
90 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
91 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_4]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xi16>>, !fir.shape<1>) -> !fir.array<4xi16>
92 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
93 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<index>
94 ! CHECK: %[[VAL_8:.*]] = fir.allocmem !fir.array<4xi64>
95 ! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
96 ! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<index>
97 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
98 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
99 ! CHECK: %[[VAL_12:.*]] = arith.constant 4 : i64
100 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
101 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i64
102 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
103 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_15]] iter_args(%[[VAL_18:.*]] = %[[VAL_8]]) -> (!fir.heap<!fir.array<4xi64>>) {
104 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
105 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_0]] : !fir.ref<i16>
106 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i16) -> i64
107 ! CHECK: %[[VAL_22:.*]] = arith.muli %[[VAL_19]], %[[VAL_21]] : i64
108 ! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
109 ! CHECK: %[[VAL_24:.*]] = fir.zero_bits !fir.ref<!fir.array<4xi64>>
110 ! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_24]], %[[VAL_23]] : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
111 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<i64>) -> index
112 ! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
113 ! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_2]] : !fir.ref<index>
114 ! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
115 ! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_27]], %[[VAL_29]] : index
116 ! CHECK: %[[VAL_31:.*]] = arith.cmpi sle, %[[VAL_28]], %[[VAL_30]] : index
117 ! CHECK: %[[VAL_32:.*]] = fir.if %[[VAL_31]] -> (!fir.heap<!fir.array<4xi64>>) {
118 ! CHECK: %[[VAL_33:.*]] = arith.constant 2 : index
119 ! CHECK: %[[VAL_34:.*]] = arith.muli %[[VAL_30]], %[[VAL_33]] : index
120 ! CHECK: fir.store %[[VAL_34]] to %[[VAL_2]] : !fir.ref<index>
121 ! CHECK: %[[VAL_35:.*]] = arith.muli %[[VAL_34]], %[[VAL_26]] : index
122 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<4xi64>>) -> !fir.ref<i8>
123 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
124 ! CHECK: %[[VAL_38:.*]] = fir.call @realloc(%[[VAL_36]], %[[VAL_37]]) fastmath<contract> : (!fir.ref<i8>, i64) -> !fir.ref<i8>
125 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<i8>) -> !fir.heap<!fir.array<4xi64>>
126 ! CHECK: fir.result %[[VAL_39]] : !fir.heap<!fir.array<4xi64>>
127 ! CHECK: } else {
128 ! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<4xi64>>
129 ! CHECK: }
130 ! CHECK: %[[VAL_40:.*]] = fir.coordinate_of %[[VAL_41:.*]], %[[VAL_27]] : (!fir.heap<!fir.array<4xi64>>, index) -> !fir.ref<i64>
131 ! CHECK: fir.store %[[VAL_22]] to %[[VAL_40]] : !fir.ref<i64>
132 ! CHECK: fir.store %[[VAL_30]] to %[[VAL_1]] : !fir.ref<index>
133 ! CHECK: fir.result %[[VAL_41]] : !fir.heap<!fir.array<4xi64>>
134 ! CHECK: }
135 ! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
136 ! CHECK: %[[VAL_43:.*]] = fir.shape %[[VAL_42]] : (index) -> !fir.shape<1>
137 ! CHECK: %[[VAL_44:.*]] = fir.array_load %[[VAL_45:.*]](%[[VAL_43]]) : (!fir.heap<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
138 ! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
139 ! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
140 ! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_3]], %[[VAL_46]] : index
141 ! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_47]] to %[[VAL_48]] step %[[VAL_46]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_6]]) -> (!fir.array<4xi16>) {
142 ! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_44]], %[[VAL_50]] : (!fir.array<4xi64>, index) -> i64
143 ! CHECK: %[[VAL_53:.*]] = fir.no_reassoc %[[VAL_52]] : i64
144 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i16
145 ! CHECK: %[[VAL_55:.*]] = fir.array_update %[[VAL_51]], %[[VAL_54]], %[[VAL_50]] : (!fir.array<4xi16>, i16, index) -> !fir.array<4xi16>
146 ! CHECK: fir.result %[[VAL_55]] : !fir.array<4xi16>
147 ! CHECK: }
148 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_56:.*]] to %[[VAL_4]] : !fir.array<4xi16>, !fir.array<4xi16>, !fir.ref<!fir.array<4xi16>>
149 ! CHECK: fir.freemem %[[VAL_45]] : !fir.heap<!fir.array<4xi64>>
150 ! CHECK: %[[VAL_57:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.array<4xi16>>
151 ! CHECK: return %[[VAL_57]] : !fir.array<4xi16>
152 ! CHECK: }
154 function test3(k)
155 integer*4 :: k
156 integer*4 :: test3(4)
157 test3 = ([(i*k, integer(8)::i=1,4)])
158 end function test3
159 ! CHECK-LABEL: func.func @_QPtest3(
160 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "k"}) -> !fir.array<4xi32> {
161 ! CHECK: %[[VAL_1:.*]] = fir.alloca index {bindc_name = ".buff.pos"}
162 ! CHECK: %[[VAL_2:.*]] = fir.alloca index {bindc_name = ".buff.size"}
163 ! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
164 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.array<4xi32> {bindc_name = "test3", uniq_name = "_QFtest3Etest3"}
165 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
166 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_4]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
167 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
168 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<index>
169 ! CHECK: %[[VAL_8:.*]] = fir.allocmem !fir.array<4xi64>
170 ! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
171 ! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<index>
172 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
173 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
174 ! CHECK: %[[VAL_12:.*]] = arith.constant 4 : i64
175 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
176 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i64
177 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
178 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_15]] iter_args(%[[VAL_18:.*]] = %[[VAL_8]]) -> (!fir.heap<!fir.array<4xi64>>) {
179 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
180 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
181 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i32) -> i64
182 ! CHECK: %[[VAL_22:.*]] = arith.muli %[[VAL_19]], %[[VAL_21]] : i64
183 ! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
184 ! CHECK: %[[VAL_24:.*]] = fir.zero_bits !fir.ref<!fir.array<4xi64>>
185 ! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_24]], %[[VAL_23]] : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
186 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<i64>) -> index
187 ! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
188 ! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_2]] : !fir.ref<index>
189 ! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
190 ! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_27]], %[[VAL_29]] : index
191 ! CHECK: %[[VAL_31:.*]] = arith.cmpi sle, %[[VAL_28]], %[[VAL_30]] : index
192 ! CHECK: %[[VAL_32:.*]] = fir.if %[[VAL_31]] -> (!fir.heap<!fir.array<4xi64>>) {
193 ! CHECK: %[[VAL_33:.*]] = arith.constant 2 : index
194 ! CHECK: %[[VAL_34:.*]] = arith.muli %[[VAL_30]], %[[VAL_33]] : index
195 ! CHECK: fir.store %[[VAL_34]] to %[[VAL_2]] : !fir.ref<index>
196 ! CHECK: %[[VAL_35:.*]] = arith.muli %[[VAL_34]], %[[VAL_26]] : index
197 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<4xi64>>) -> !fir.ref<i8>
198 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
199 ! CHECK: %[[VAL_38:.*]] = fir.call @realloc(%[[VAL_36]], %[[VAL_37]]) fastmath<contract> : (!fir.ref<i8>, i64) -> !fir.ref<i8>
200 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<i8>) -> !fir.heap<!fir.array<4xi64>>
201 ! CHECK: fir.result %[[VAL_39]] : !fir.heap<!fir.array<4xi64>>
202 ! CHECK: } else {
203 ! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<4xi64>>
204 ! CHECK: }
205 ! CHECK: %[[VAL_40:.*]] = fir.coordinate_of %[[VAL_41:.*]], %[[VAL_27]] : (!fir.heap<!fir.array<4xi64>>, index) -> !fir.ref<i64>
206 ! CHECK: fir.store %[[VAL_22]] to %[[VAL_40]] : !fir.ref<i64>
207 ! CHECK: fir.store %[[VAL_30]] to %[[VAL_1]] : !fir.ref<index>
208 ! CHECK: fir.result %[[VAL_41]] : !fir.heap<!fir.array<4xi64>>
209 ! CHECK: }
210 ! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
211 ! CHECK: %[[VAL_43:.*]] = fir.shape %[[VAL_42]] : (index) -> !fir.shape<1>
212 ! CHECK: %[[VAL_44:.*]] = fir.array_load %[[VAL_45:.*]](%[[VAL_43]]) : (!fir.heap<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
213 ! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
214 ! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
215 ! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_3]], %[[VAL_46]] : index
216 ! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_47]] to %[[VAL_48]] step %[[VAL_46]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_6]]) -> (!fir.array<4xi32>) {
217 ! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_44]], %[[VAL_50]] : (!fir.array<4xi64>, index) -> i64
218 ! CHECK: %[[VAL_53:.*]] = fir.no_reassoc %[[VAL_52]] : i64
219 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i32
220 ! CHECK: %[[VAL_55:.*]] = fir.array_update %[[VAL_51]], %[[VAL_54]], %[[VAL_50]] : (!fir.array<4xi32>, i32, index) -> !fir.array<4xi32>
221 ! CHECK: fir.result %[[VAL_55]] : !fir.array<4xi32>
222 ! CHECK: }
223 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_56:.*]] to %[[VAL_4]] : !fir.array<4xi32>, !fir.array<4xi32>, !fir.ref<!fir.array<4xi32>>
224 ! CHECK: fir.freemem %[[VAL_45]] : !fir.heap<!fir.array<4xi64>>
225 ! CHECK: %[[VAL_57:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.array<4xi32>>
226 ! CHECK: return %[[VAL_57]] : !fir.array<4xi32>
227 ! CHECK: }
229 function test4(k)
230 integer*8 :: k
231 integer*8 :: test4(4)
232 test4 = ([(i*k, integer(8)::i=1,4)])
233 end function test4
234 ! CHECK-LABEL: func.func @_QPtest4(
235 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64> {fir.bindc_name = "k"}) -> !fir.array<4xi64> {
236 ! CHECK: %[[VAL_1:.*]] = fir.alloca index {bindc_name = ".buff.pos"}
237 ! CHECK: %[[VAL_2:.*]] = fir.alloca index {bindc_name = ".buff.size"}
238 ! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
239 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.array<4xi64> {bindc_name = "test4", uniq_name = "_QFtest4Etest4"}
240 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
241 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_4]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
242 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
243 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<index>
244 ! CHECK: %[[VAL_8:.*]] = fir.allocmem !fir.array<4xi64>
245 ! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
246 ! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<index>
247 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
248 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
249 ! CHECK: %[[VAL_12:.*]] = arith.constant 4 : i64
250 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
251 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i64
252 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
253 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_15]] iter_args(%[[VAL_18:.*]] = %[[VAL_8]]) -> (!fir.heap<!fir.array<4xi64>>) {
254 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
255 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
256 ! CHECK: %[[VAL_21:.*]] = arith.muli %[[VAL_19]], %[[VAL_20]] : i64
257 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : index
258 ! CHECK: %[[VAL_23:.*]] = fir.zero_bits !fir.ref<!fir.array<4xi64>>
259 ! CHECK: %[[VAL_24:.*]] = fir.coordinate_of %[[VAL_23]], %[[VAL_22]] : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
260 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<i64>) -> index
261 ! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
262 ! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_2]] : !fir.ref<index>
263 ! CHECK: %[[VAL_28:.*]] = arith.constant 1 : index
264 ! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_26]], %[[VAL_28]] : index
265 ! CHECK: %[[VAL_30:.*]] = arith.cmpi sle, %[[VAL_27]], %[[VAL_29]] : index
266 ! CHECK: %[[VAL_31:.*]] = fir.if %[[VAL_30]] -> (!fir.heap<!fir.array<4xi64>>) {
267 ! CHECK: %[[VAL_32:.*]] = arith.constant 2 : index
268 ! CHECK: %[[VAL_33:.*]] = arith.muli %[[VAL_29]], %[[VAL_32]] : index
269 ! CHECK: fir.store %[[VAL_33]] to %[[VAL_2]] : !fir.ref<index>
270 ! CHECK: %[[VAL_34:.*]] = arith.muli %[[VAL_33]], %[[VAL_25]] : index
271 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<4xi64>>) -> !fir.ref<i8>
272 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_34]] : (index) -> i64
273 ! CHECK: %[[VAL_37:.*]] = fir.call @realloc(%[[VAL_35]], %[[VAL_36]]) fastmath<contract> : (!fir.ref<i8>, i64) -> !fir.ref<i8>
274 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (!fir.ref<i8>) -> !fir.heap<!fir.array<4xi64>>
275 ! CHECK: fir.result %[[VAL_38]] : !fir.heap<!fir.array<4xi64>>
276 ! CHECK: } else {
277 ! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<4xi64>>
278 ! CHECK: }
279 ! CHECK: %[[VAL_39:.*]] = fir.coordinate_of %[[VAL_40:.*]], %[[VAL_26]] : (!fir.heap<!fir.array<4xi64>>, index) -> !fir.ref<i64>
280 ! CHECK: fir.store %[[VAL_21]] to %[[VAL_39]] : !fir.ref<i64>
281 ! CHECK: fir.store %[[VAL_29]] to %[[VAL_1]] : !fir.ref<index>
282 ! CHECK: fir.result %[[VAL_40]] : !fir.heap<!fir.array<4xi64>>
283 ! CHECK: }
284 ! CHECK: %[[VAL_41:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
285 ! CHECK: %[[VAL_42:.*]] = fir.shape %[[VAL_41]] : (index) -> !fir.shape<1>
286 ! CHECK: %[[VAL_43:.*]] = fir.array_load %[[VAL_44:.*]](%[[VAL_42]]) : (!fir.heap<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
287 ! CHECK: %[[VAL_45:.*]] = arith.constant 1 : index
288 ! CHECK: %[[VAL_46:.*]] = arith.constant 0 : index
289 ! CHECK: %[[VAL_47:.*]] = arith.subi %[[VAL_3]], %[[VAL_45]] : index
290 ! CHECK: %[[VAL_48:.*]] = fir.do_loop %[[VAL_49:.*]] = %[[VAL_46]] to %[[VAL_47]] step %[[VAL_45]] unordered iter_args(%[[VAL_50:.*]] = %[[VAL_6]]) -> (!fir.array<4xi64>) {
291 ! CHECK: %[[VAL_51:.*]] = fir.array_fetch %[[VAL_43]], %[[VAL_49]] : (!fir.array<4xi64>, index) -> i64
292 ! CHECK: %[[VAL_52:.*]] = fir.no_reassoc %[[VAL_51]] : i64
293 ! CHECK: %[[VAL_53:.*]] = fir.array_update %[[VAL_50]], %[[VAL_52]], %[[VAL_49]] : (!fir.array<4xi64>, i64, index) -> !fir.array<4xi64>
294 ! CHECK: fir.result %[[VAL_53]] : !fir.array<4xi64>
295 ! CHECK: }
296 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_54:.*]] to %[[VAL_4]] : !fir.array<4xi64>, !fir.array<4xi64>, !fir.ref<!fir.array<4xi64>>
297 ! CHECK: fir.freemem %[[VAL_44]] : !fir.heap<!fir.array<4xi64>>
298 ! CHECK: %[[VAL_55:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.array<4xi64>>
299 ! CHECK: return %[[VAL_55]] : !fir.array<4xi64>
300 ! CHECK: }