1 // RUN: fir-opt --canonicalize %s | FileCheck %s
3 // CHECK-LABEL: func.func @_QPtest1(
4 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<120x2xi32>> {fir.bindc_name = "u"}) {
5 // CHECK: %[[VAL_6:.*]] = fir.shape
6 // CHECK: %[[VAL_7:.*]] = fir.declare %[[VAL_0]](%[[VAL_6]])
7 // CHECK: %[[VAL_8:.*]] = fir.slice
10 // CHECK: %[[VAL_11:.*]] = fir.array_coor %[[VAL_7]](%[[VAL_6]]) {{\[}}%[[VAL_8]]]
11 func.func @_QPtest1(%arg0: !fir.ref<!fir.array<120x2xi32>> {fir.bindc_name = "u"}) {
12 %c1 = arith.constant 1 : index
13 %c2_i32 = arith.constant 2 : i32
14 %c2 = arith.constant 2 : index
15 %c120 = arith.constant 120 : index
16 %0 = fir.dummy_scope : !fir.dscope
17 %1 = fir.shape %c120, %c2 : (index, index) -> !fir.shape<2>
18 %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest1Eu"} : (!fir.ref<!fir.array<120x2xi32>>, !fir.shape<2>, !fir.dscope) -> !fir.ref<!fir.array<120x2xi32>>
19 %3 = fir.slice %c1, %c120, %c1, %c1, %c2, %c1 : (index, index, index, index, index, index) -> !fir.slice<2>
20 %4 = fir.embox %2(%1) [%3] : (!fir.ref<!fir.array<120x2xi32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.box<!fir.array<120x2xi32>>
21 fir.do_loop %arg1 = %c1 to %c2 step %c1 unordered {
22 fir.do_loop %arg2 = %c1 to %c120 step %c1 unordered {
23 %5 = fir.array_coor %4 %arg2, %arg1 : (!fir.box<!fir.array<120x2xi32>>, index, index) -> !fir.ref<i32>
24 fir.store %c2_i32 to %5 : !fir.ref<i32>
30 // CHECK-LABEL: func.func @_QPtest2(
31 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xi32>> {fir.bindc_name = "u"}) {
32 // CHECK: %[[VAL_8:.*]] = fir.shift
33 // CHECK: %[[VAL_9:.*]] = fir.declare %[[VAL_0]](%[[VAL_8]])
36 // CHECK: %[[VAL_17:.*]] = fir.array_coor %[[VAL_9]](%[[VAL_8]])
37 func.func @_QPtest2(%arg0: !fir.box<!fir.array<?x?xi32>> {fir.bindc_name = "u"}) {
38 %c9 = arith.constant 9 : index
39 %c1 = arith.constant 1 : index
40 %c0 = arith.constant 0 : index
41 %c11 = arith.constant 11 : index
42 %c10 = arith.constant 10 : index
43 %c2_i32 = arith.constant 2 : i32
44 %0 = fir.dummy_scope : !fir.dscope
45 %1 = fir.shift %c10, %c11 : (index, index) -> !fir.shift<2>
46 %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest2Eu"} : (!fir.box<!fir.array<?x?xi32>>, !fir.shift<2>, !fir.dscope) -> !fir.box<!fir.array<?x?xi32>>
47 %3 = fir.rebox %2(%1) : (!fir.box<!fir.array<?x?xi32>>, !fir.shift<2>) -> !fir.box<!fir.array<?x?xi32>>
48 %4:3 = fir.box_dims %3, %c0 : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
49 %5:3 = fir.box_dims %3, %c1 : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
50 fir.do_loop %arg1 = %c1 to %5#1 step %c1 unordered {
51 fir.do_loop %arg2 = %c1 to %4#1 step %c1 unordered {
52 %6 = arith.addi %arg2, %c9 : index
53 %7 = arith.addi %arg1, %c10 : index
54 %8 = fir.array_coor %3(%1) %6, %7 : (!fir.box<!fir.array<?x?xi32>>, !fir.shift<2>, index, index) -> !fir.ref<i32>
55 fir.store %c2_i32 to %8 : !fir.ref<i32>
61 // CHECK-LABEL: func.func @_QPtest3(
62 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xi32>> {fir.bindc_name = "u"}) {
63 // CHECK: %[[VAL_10:.*]] = fir.shift
64 // CHECK: %[[VAL_11:.*]] = fir.declare %[[VAL_0]](%[[VAL_10]])
65 // CHECK: %[[VAL_12:.*]] = fir.slice
68 // CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_11]](%[[VAL_10]]) {{\[}}%[[VAL_12]]]
69 func.func @_QPtest3(%arg0: !fir.box<!fir.array<?x?xi32>> {fir.bindc_name = "u"}) {
70 %c2 = arith.constant 2 : index
71 %c12 = arith.constant 12 : index
72 %c11 = arith.constant 11 : index
73 %c111 = arith.constant 111 : index
74 %c1 = arith.constant 1 : index
75 %c120 = arith.constant 120 : index
76 %c10 = arith.constant 10 : index
77 %c2_i32 = arith.constant 2 : i32
78 %0 = fir.dummy_scope : !fir.dscope
79 %1 = fir.shift %c10, %c11 : (index, index) -> !fir.shift<2>
80 %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest3Eu"} : (!fir.box<!fir.array<?x?xi32>>, !fir.shift<2>, !fir.dscope) -> !fir.box<!fir.array<?x?xi32>>
81 %3 = fir.rebox %2(%1) : (!fir.box<!fir.array<?x?xi32>>, !fir.shift<2>) -> !fir.box<!fir.array<?x?xi32>>
82 %4 = fir.slice %c10, %c120, %c1, %c11, %c12, %c1 : (index, index, index, index, index, index) -> !fir.slice<2>
83 %5 = fir.rebox %3(%1) [%4] : (!fir.box<!fir.array<?x?xi32>>, !fir.shift<2>, !fir.slice<2>) -> !fir.box<!fir.array<111x2xi32>>
84 fir.do_loop %arg1 = %c1 to %c2 step %c1 unordered {
85 fir.do_loop %arg2 = %c1 to %c111 step %c1 unordered {
86 %6 = fir.array_coor %5 %arg2, %arg1 : (!fir.box<!fir.array<111x2xi32>>, index, index) -> !fir.ref<i32>
87 fir.store %c2_i32 to %6 : !fir.ref<i32>
93 // TODO: fir.array_coor with slices changing the number of dimensions
94 // is not supported yet.
95 // CHECK-LABEL: func.func @_QPtest4() {
96 // CHECK: %[[VAL_3:.*]] = fir.alloca !fir.array<100x100x100xi32> {bindc_name = "u", uniq_name = "_QFtest4Eu"}
97 // CHECK: %[[VAL_4:.*]] = fir.shape
98 // CHECK: %[[VAL_5:.*]] = fir.declare %[[VAL_3]](%[[VAL_4]]) {uniq_name = "_QFtest4Eu"} : (!fir.ref<!fir.array<100x100x100xi32>>, !fir.shape<3>) -> !fir.ref<!fir.array<100x100x100xi32>>
99 // CHECK: %[[VAL_7:.*]] = fir.slice
100 // CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_5]](%[[VAL_4]]) {{\[}}%[[VAL_7]]] : (!fir.ref<!fir.array<100x100x100xi32>>, !fir.shape<3>, !fir.slice<3>) -> !fir.box<!fir.array<100x100xi32>>
101 // CHECK: fir.do_loop
102 // CHECK: fir.do_loop
103 // CHECK: %[[VAL_11:.*]] = fir.array_coor %[[VAL_8]]
104 func.func @_QPtest4() {
105 %c1 = arith.constant 1 : index
106 %c2_i32 = arith.constant 2 : i32
107 %c100 = arith.constant 100 : index
108 %0 = fir.alloca !fir.array<100x100x100xi32> {bindc_name = "u", uniq_name = "_QFtest4Eu"}
109 %1 = fir.shape %c100, %c100, %c100 : (index, index, index) -> !fir.shape<3>
110 %2 = fir.declare %0(%1) {uniq_name = "_QFtest4Eu"} : (!fir.ref<!fir.array<100x100x100xi32>>, !fir.shape<3>) -> !fir.ref<!fir.array<100x100x100xi32>>
111 %3 = fir.undefined index
112 %4 = fir.slice %c1, %c100, %c1, %c1, %3, %3, %c1, %c100, %c1 : (index, index, index, index, index, index, index, index, index) -> !fir.slice<3>
113 %5 = fir.embox %2(%1) [%4] : (!fir.ref<!fir.array<100x100x100xi32>>, !fir.shape<3>, !fir.slice<3>) -> !fir.box<!fir.array<100x100xi32>>
114 fir.do_loop %arg0 = %c1 to %c100 step %c1 unordered {
115 fir.do_loop %arg1 = %c1 to %c100 step %c1 unordered {
116 %6 = fir.array_coor %5 %arg1, %arg0 : (!fir.box<!fir.array<100x100xi32>>, index, index) -> !fir.ref<i32>
117 fir.store %c2_i32 to %6 : !fir.ref<i32>
123 // CHECK-LABEL: func.func @test5_1(
124 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
125 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
126 // CHECK: %[[VAL_2:.*]] = arith.constant 9 : index
127 // CHECK: %[[VAL_3:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
128 // CHECK: %[[VAL_4:.*]] = fir.array_coor %[[VAL_0]] {{\[}}%[[VAL_3]]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
129 // CHECK: return %[[VAL_4]] : !fir.ref<i32>
131 func.func @test5_1(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
132 %c1 = arith.constant 1 : index
133 %c10 = arith.constant 10 : index
134 %c9 = arith.constant 9 : index
135 %sh = fir.shift %c10 : (index) -> !fir.shift<1>
136 %2 = fir.rebox %arg0(%sh) : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>) -> !fir.box<!fir.array<?xi32>>
137 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
138 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
139 return %3 : !fir.ref<i32>
142 // CHECK-LABEL: func.func @test5_2(
143 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
144 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
145 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
146 // CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
147 // CHECK: %[[VAL_4:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
148 // CHECK: %[[VAL_5:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_3]]) {{\[}}%[[VAL_4]]] %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<i32>
149 // CHECK: return %[[VAL_5]] : !fir.ref<i32>
151 func.func @test5_2(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
152 %c1 = arith.constant 1 : index
153 %c10 = arith.constant 10 : index
154 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
155 %s = fir.slice %c1, %c10, %c1 : (index, index, index) -> !fir.slice<1>
156 %2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
157 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
158 return %3 : !fir.ref<i32>
161 // CHECK-LABEL: func.func @test5_3(
162 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
163 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
164 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
165 // CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
166 // CHECK: %[[VAL_4:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
167 // CHECK: %[[VAL_5:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_3]]) {{\[}}%[[VAL_4]]] %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<i32>
168 // CHECK: return %[[VAL_5]] : !fir.ref<i32>
170 func.func @test5_3(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
171 %c1 = arith.constant 1 : index
172 %c10 = arith.constant 10 : index
173 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
174 %s = fir.slice %c1, %c10, %c1 : (index, index, index) -> !fir.slice<1>
175 %2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<10xi32>>
176 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
177 return %3 : !fir.ref<i32>
180 // CHECK-LABEL: func.func @test6_1(
181 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
182 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
183 // CHECK: %[[VAL_2:.*]] = arith.constant 9 : index
184 // CHECK: %[[VAL_3:.*]] = fir.shift %[[VAL_1]] : (index) -> !fir.shift<1>
185 // CHECK: %[[VAL_4:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
186 // CHECK: %[[VAL_5:.*]] = fir.rebox %[[VAL_0]](%[[VAL_3]]) {{\[}}%[[VAL_4]]] : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>, !fir.slice<1>) -> !fir.box<!fir.array<?xi32>>
187 // CHECK: %[[VAL_6:.*]] = fir.array_coor %[[VAL_5]] {{\[}}%[[VAL_4]]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
188 // CHECK: return %[[VAL_6]] : !fir.ref<i32>
190 func.func @test6_1(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
191 %c1 = arith.constant 1 : index
192 %c10 = arith.constant 10 : index
193 %c9 = arith.constant 9 : index
194 %sh = fir.shift %c1 : (index) -> !fir.shift<1>
195 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
196 %2 = fir.rebox %arg0(%sh) [%s] : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>, !fir.slice<1>) -> !fir.box<!fir.array<?xi32>>
197 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
198 return %3 : !fir.ref<i32>
201 // CHECK-LABEL: func.func @test6_2(
202 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
203 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
204 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
205 // CHECK: %[[VAL_3:.*]] = arith.constant 19 : index
206 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
207 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_2]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
208 // CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
209 // CHECK: %[[VAL_7:.*]] = fir.array_coor %[[VAL_6]] {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.box<!fir.array<10xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
210 // CHECK: return %[[VAL_7]] : !fir.ref<i32>
212 func.func @test6_2(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
213 %c1 = arith.constant 1 : index
214 %c10 = arith.constant 10 : index
215 %c19 = arith.constant 19 : index
216 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
217 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
218 %2 = fir.embox %arg0(%1) [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
219 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
220 return %3 : !fir.ref<i32>
223 // CHECK-LABEL: func.func @test6_3(
224 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
225 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
226 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
227 // CHECK: %[[VAL_3:.*]] = arith.constant 19 : index
228 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
229 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_2]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
230 // CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
231 // CHECK: %[[VAL_7:.*]] = fir.array_coor %[[VAL_6]] {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.box<!fir.array<10xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
232 // CHECK: return %[[VAL_7]] : !fir.ref<i32>
234 func.func @test6_3(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
235 %c1 = arith.constant 1 : index
236 %c10 = arith.constant 10 : index
237 %c19 = arith.constant 19 : index
238 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
239 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
240 %2 = fir.embox %arg0(%1) [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
241 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
242 return %3 : !fir.ref<i32>
245 // CHECK-LABEL: func.func @test7_1(
246 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
247 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
248 // CHECK: %[[VAL_2:.*]] = fir.array_coor %[[VAL_0]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
249 // CHECK: return %[[VAL_2]] : !fir.ref<i32>
251 func.func @test7_1(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
252 %c1 = arith.constant 1 : index
253 %c10 = arith.constant 10 : index
254 %c9 = arith.constant 9 : index
255 %sh = fir.shift %c10 : (index) -> !fir.shift<1>
256 %2 = fir.rebox %arg0(%sh) : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>) -> !fir.box<!fir.array<?xi32>>
257 %3 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
258 return %3 : !fir.ref<i32>
261 // CHECK-LABEL: func.func @test7_2(
262 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
263 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
264 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
265 // CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
266 // CHECK: %[[VAL_4:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_3]]) %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
267 // CHECK: return %[[VAL_4]] : !fir.ref<i32>
269 func.func @test7_2(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
270 %c1 = arith.constant 1 : index
271 %c10 = arith.constant 10 : index
272 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
273 %2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
274 %3 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<10xi32>>, index) -> !fir.ref<i32>
275 return %3 : !fir.ref<i32>
278 // CHECK-LABEL: func.func @test7_3(
279 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
280 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
281 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
282 // CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
283 // CHECK: %[[VAL_4:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_3]]) %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
284 // CHECK: return %[[VAL_4]] : !fir.ref<i32>
286 func.func @test7_3(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
287 %c1 = arith.constant 1 : index
288 %c10 = arith.constant 10 : index
289 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
290 %2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<10xi32>>
291 %3 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<10xi32>>, index) -> !fir.ref<i32>
292 return %3 : !fir.ref<i32>
295 // CHECK-LABEL: func.func @test8_1(
296 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>,
297 // CHECK-SAME: %[[VAL_1:.*]]: index,
298 // CHECK-SAME: %[[VAL_2:.*]]: index) -> !fir.ref<i32> {
299 // CHECK: %[[VAL_3:.*]] = arith.constant 1 : index
300 // CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
301 // CHECK: %[[VAL_5:.*]] = arith.constant 19 : index
302 // CHECK: %[[VAL_6:.*]] = fir.shift %[[VAL_1]] : (index) -> !fir.shift<1>
303 // CHECK: %[[VAL_7:.*]] = fir.slice %[[VAL_4]], %[[VAL_5]], %[[VAL_3]] : (index, index, index) -> !fir.slice<1>
304 // CHECK: %[[VAL_8:.*]] = arith.addi %[[VAL_2]], %[[VAL_1]] overflow<nsw> : index
305 // CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_8]], %[[VAL_3]] overflow<nsw> : index
306 // CHECK: %[[VAL_10:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_6]]) {{\[}}%[[VAL_7]]] %[[VAL_9]] : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
307 // CHECK: return %[[VAL_10]] : !fir.ref<i32>
309 func.func @test8_1(%arg0: !fir.box<!fir.array<?xi32>>, %lb: index, %idx: index) -> !fir.ref<i32> {
310 %c1 = arith.constant 1 : index
311 %c10 = arith.constant 10 : index
312 %c19 = arith.constant 19 : index
313 %sh = fir.shift %lb : (index) -> !fir.shift<1>
314 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
315 %2 = fir.rebox %arg0(%sh) [%s] : (!fir.box<!fir.array<?xi32>>, !fir.shift<1>, !fir.slice<1>) -> !fir.box<!fir.array<?xi32>>
316 %3 = fir.array_coor %2 %idx : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
317 return %3 : !fir.ref<i32>
320 // CHECK-LABEL: func.func @test8_2(
321 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
322 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
323 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
324 // CHECK: %[[VAL_3:.*]] = arith.constant 9 : index
325 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
326 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_1]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
327 // CHECK: %[[VAL_6:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<i32>
328 // CHECK: return %[[VAL_6]] : !fir.ref<i32>
330 func.func @test8_2(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
331 %c1 = arith.constant 1 : index
332 %c10 = arith.constant 10 : index
333 %c9 = arith.constant 9 : index
334 %1 = fir.shape %c10 : (index) -> !fir.shape<1>
335 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
336 %2 = fir.embox %arg0(%1) [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
337 %3 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<10xi32>>, index) -> !fir.ref<i32>
338 return %3 : !fir.ref<i32>
341 // CHECK-LABEL: func.func @test8_3(
342 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>,
343 // CHECK-SAME: %[[VAL_1:.*]]: index,
344 // CHECK-SAME: %[[VAL_2:.*]]: index) -> !fir.ref<i32> {
345 // CHECK: %[[VAL_3:.*]] = arith.constant 1 : index
346 // CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
347 // CHECK: %[[VAL_5:.*]] = arith.constant 19 : index
348 // CHECK: %[[VAL_6:.*]] = fir.shape_shift %[[VAL_1]], %[[VAL_4]] : (index, index) -> !fir.shapeshift<1>
349 // CHECK: %[[VAL_7:.*]] = fir.slice %[[VAL_4]], %[[VAL_5]], %[[VAL_3]] : (index, index, index) -> !fir.slice<1>
350 // CHECK: %[[VAL_8:.*]] = arith.addi %[[VAL_2]], %[[VAL_1]] overflow<nsw> : index
351 // CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_8]], %[[VAL_3]] overflow<nsw> : index
352 // CHECK: %[[VAL_10:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_6]]) {{\[}}%[[VAL_7]]] %[[VAL_9]] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
353 // CHECK: return %[[VAL_10]] : !fir.ref<i32>
355 func.func @test8_3(%arg0: !fir.ref<!fir.array<10xi32>>, %lb: index, %idx: index) -> !fir.ref<i32> {
356 %c1 = arith.constant 1 : index
357 %c10 = arith.constant 10 : index
358 %c19 = arith.constant 19 : index
359 %1 = fir.shape_shift %lb, %c10 : (index, index) -> !fir.shapeshift<1>
360 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
361 %2 = fir.embox %arg0(%1) [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
362 %3 = fir.array_coor %2 %idx : (!fir.box<!fir.array<10xi32>>, index) -> !fir.ref<i32>
363 return %3 : !fir.ref<i32>
366 // CHECK-LABEL: func.func @test9(
367 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
368 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
369 // CHECK: %[[VAL_2:.*]] = arith.constant 9 : index
370 // CHECK: %[[VAL_3:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
371 // CHECK: %[[VAL_4:.*]] = fir.array_coor %[[VAL_0]] {{\[}}%[[VAL_3]]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
372 // CHECK: return %[[VAL_4]] : !fir.ref<i32>
374 func.func @test9(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
375 %c1 = arith.constant 1 : index
376 %c10 = arith.constant 10 : index
377 %c9 = arith.constant 9 : index
378 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
379 %2 = fir.rebox %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi32>>
380 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
381 return %3 : !fir.ref<i32>
384 // CHECK-LABEL: func.func @test10(
385 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
386 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
387 // CHECK: %[[VAL_2:.*]] = arith.constant 9 : index
388 // CHECK: %[[VAL_3:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
389 // CHECK: %[[VAL_4:.*]] = fir.array_coor %[[VAL_0]] {{\[}}%[[VAL_3]]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
390 // CHECK: return %[[VAL_4]] : !fir.ref<i32>
392 func.func @test10(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
393 %c1 = arith.constant 1 : index
394 %c10 = arith.constant 10 : index
395 %c9 = arith.constant 9 : index
396 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
397 %2 = fir.rebox %arg0[%s] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>) -> !fir.box<!fir.array<?xi32>>
398 %3 = fir.array_coor %2 [%s] %c1 : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
399 return %3 : !fir.ref<i32>
402 // CHECK-LABEL: func.func @test11(
403 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
404 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
405 // CHECK: %[[VAL_2:.*]] = fir.array_coor %[[VAL_0]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
406 // CHECK: return %[[VAL_2]] : !fir.ref<i32>
408 func.func @test11(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
409 %c1 = arith.constant 1 : index
410 %2 = fir.rebox %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi32>>
411 %3 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
412 return %3 : !fir.ref<i32>
415 // CHECK-LABEL: func.func @test12(
416 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
417 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
418 // CHECK: %[[VAL_2:.*]] = arith.constant 9 : index
419 // CHECK: %[[VAL_3:.*]] = fir.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
420 // CHECK: %[[VAL_4:.*]] = fir.array_coor %[[VAL_0]] {{\[}}%[[VAL_3]]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>, index) -> !fir.ref<i32>
421 // CHECK: return %[[VAL_4]] : !fir.ref<i32>
423 func.func @test12(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
424 %c1 = arith.constant 1 : index
425 %c10 = arith.constant 10 : index
426 %c9 = arith.constant 9 : index
427 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
428 %2 = fir.rebox %arg0[%s] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>) -> !fir.box<!fir.array<?xi32>>
429 %3 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
430 return %3 : !fir.ref<i32>
433 // CHECK-LABEL: func.func @test13(
434 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
435 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
436 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
437 // CHECK: %[[VAL_3:.*]] = arith.constant 19 : index
438 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
439 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_2]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
440 // CHECK: %[[VAL_6:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
441 // CHECK: return %[[VAL_6]] : !fir.ref<i32>
443 func.func @test13(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
444 %c1 = arith.constant 1 : index
445 %c10 = arith.constant 10 : index
446 %c19 = arith.constant 19 : index
447 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
448 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
449 %2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<10xi32>>
450 %3 = fir.array_coor %2(%1) [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
451 return %3 : !fir.ref<i32>
454 // CHECK-LABEL: func.func @test14(
455 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
456 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
457 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
458 // CHECK: %[[VAL_3:.*]] = arith.constant 19 : index
459 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
460 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_2]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
461 // CHECK: %[[VAL_6:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
462 // CHECK: return %[[VAL_6]] : !fir.ref<i32>
464 func.func @test14(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
465 %c1 = arith.constant 1 : index
466 %c10 = arith.constant 10 : index
467 %c19 = arith.constant 19 : index
468 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
469 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
470 %2 = fir.embox %arg0(%1) [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
471 %3 = fir.array_coor %2(%1) [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
472 return %3 : !fir.ref<i32>
475 // CHECK-LABEL: func.func @test15(
476 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
477 // CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
478 // CHECK: %[[VAL_2:.*]] = fir.shape_shift %[[VAL_1]], %[[VAL_1]] : (index, index) -> !fir.shapeshift<1>
479 // CHECK: %[[VAL_3:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_2]]) %[[VAL_1]] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
480 // CHECK: return %[[VAL_3]] : !fir.ref<i32>
482 func.func @test15(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
483 %c10 = arith.constant 10 : index
484 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
485 %2 = fir.embox %arg0(%1) : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<10xi32>>
486 %3 = fir.array_coor %2(%1) %c10 : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
487 return %3 : !fir.ref<i32>
490 // CHECK-LABEL: func.func @test16(
491 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
492 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
493 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
494 // CHECK: %[[VAL_3:.*]] = arith.constant 19 : index
495 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
496 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_2]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
497 // CHECK: %[[VAL_6:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] %[[VAL_2]] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
498 // CHECK: return %[[VAL_6]] : !fir.ref<i32>
500 func.func @test16(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
501 %c1 = arith.constant 1 : index
502 %c10 = arith.constant 10 : index
503 %c19 = arith.constant 19 : index
504 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
505 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
506 %2 = fir.embox %arg0(%1) [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
507 %3 = fir.array_coor %2(%1) %c10 : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
508 return %3 : !fir.ref<i32>
511 // CHECK-LABEL: func.func @test17(
512 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
513 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
514 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
515 // CHECK: %[[VAL_3:.*]] = arith.constant 19 : index
516 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
517 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_2]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
518 // CHECK: %[[VAL_6:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
519 // CHECK: return %[[VAL_6]] : !fir.ref<i32>
521 func.func @test17(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
522 %c1 = arith.constant 1 : index
523 %c10 = arith.constant 10 : index
524 %c19 = arith.constant 19 : index
525 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
526 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
527 %2 = fir.rebox %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi32>>
528 %3 = fir.array_coor %2(%1) [%s] %c1 : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
529 return %3 : !fir.ref<i32>
532 // CHECK-LABEL: func.func @test18(
533 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
534 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
535 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
536 // CHECK: %[[VAL_3:.*]] = arith.constant 9 : index
537 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_1]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
538 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_1]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
539 // CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]] {{\[}}%[[VAL_5]]] : (!fir.ref<!fir.array<10xi32>>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
540 // CHECK: %[[VAL_7:.*]] = fir.array_coor %[[VAL_6]](%[[VAL_4]]) {{\[}}%[[VAL_5]]] %[[VAL_1]] : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
541 // CHECK: return %[[VAL_7]] : !fir.ref<i32>
543 func.func @test18(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
544 %c1 = arith.constant 1 : index
545 %c10 = arith.constant 10 : index
546 %c9 = arith.constant 9 : index
547 %1 = fir.shape_shift %c1, %c10 : (index, index) -> !fir.shapeshift<1>
548 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
549 %2 = fir.embox %arg0 [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
550 %3 = fir.array_coor %2(%1) [%s] %c1 : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, !fir.slice<1>, index) -> !fir.ref<i32>
551 return %3 : !fir.ref<i32>
554 // CHECK-LABEL: func.func @test19(
555 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
556 // CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
557 // CHECK: %[[VAL_2:.*]] = fir.shape_shift %[[VAL_1]], %[[VAL_1]] : (index, index) -> !fir.shapeshift<1>
558 // CHECK: %[[VAL_3:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_2]]) %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
559 // CHECK: return %[[VAL_3]] : !fir.ref<i32>
561 func.func @test19(%arg0: !fir.box<!fir.array<?xi32>>) -> !fir.ref<i32> {
562 %c1 = arith.constant 1 : index
563 %c10 = arith.constant 10 : index
564 %c19 = arith.constant 19 : index
565 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
566 %s = fir.slice %c10, %c19, %c1 : (index, index, index) -> !fir.slice<1>
567 %2 = fir.rebox %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi32>>
568 %3 = fir.array_coor %2(%1) %c10 : (!fir.box<!fir.array<?xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
569 return %3 : !fir.ref<i32>
572 // CHECK-LABEL: func.func @test20(
573 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
574 // CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
575 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
576 // CHECK: %[[VAL_3:.*]] = arith.constant 9 : index
577 // CHECK: %[[VAL_4:.*]] = fir.shape_shift %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shapeshift<1>
578 // CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_1]], %[[VAL_3]], %[[VAL_1]] : (index, index, index) -> !fir.slice<1>
579 // CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]] {{\[}}%[[VAL_5]]] : (!fir.ref<!fir.array<10xi32>>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
580 // CHECK: %[[VAL_7:.*]] = fir.array_coor %[[VAL_6]](%[[VAL_4]]) %[[VAL_2]] : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
581 // CHECK: return %[[VAL_7]] : !fir.ref<i32>
583 func.func @test20(%arg0: !fir.ref<!fir.array<10xi32>>) -> !fir.ref<i32> {
584 %c1 = arith.constant 1 : index
585 %c10 = arith.constant 10 : index
586 %c9 = arith.constant 9 : index
587 %1 = fir.shape_shift %c10, %c10 : (index, index) -> !fir.shapeshift<1>
588 %s = fir.slice %c1, %c9, %c1 : (index, index, index) -> !fir.slice<1>
589 %2 = fir.embox %arg0 [%s] : (!fir.ref<!fir.array<10xi32>>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
590 %3 = fir.array_coor %2(%1) %c10 : (!fir.box<!fir.array<10xi32>>, !fir.shapeshift<1>, index) -> !fir.ref<i32>
591 return %3 : !fir.ref<i32>