1 // Test code generation to FIR of hlfir.designate operations
2 // with component reference.
3 // RUN: fir-opt %s -convert-hlfir-to-fir | FileCheck %s
5 func.func @test_scalar(%arg0: !fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>) {
6 %0:2 = hlfir.declare %arg0 {uniq_name = "a"} : (!fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>) -> (!fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>, !fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>)
7 %1 = hlfir.designate %0#0{"scalar_x"} : (!fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>) -> !fir.ref<f32>
10 // CHECK-LABEL: func.func @test_scalar(
11 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>) {
12 // CHECK: %[[VAL_1:.*]] = fir.declare %[[VAL_0]] {uniq_name = "a"}
13 // CHECK: %[[VAL_2:.*]] = fir.field_index scalar_x, !fir.type<t1{scalar_i:i32,scalar_x:f32}>
14 // CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.type<t1{scalar_i:i32,scalar_x:f32}>>, !fir.field) -> !fir.ref<f32>
16 func.func @test_array_char_comp_1(%arg0: !fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>) {
17 %0:2 = hlfir.declare %arg0 {uniq_name = "a"} : (!fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>) -> (!fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>, !fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>)
18 %c10 = arith.constant 10 : index
19 %c20 = arith.constant 20 : index
20 %1 = fir.shape %c10, %c20 : (index, index) -> !fir.shape<2>
21 %c5 = arith.constant 5 : index
22 %2 = hlfir.designate %0#0{"array_char_comp"} shape %1 typeparams %c5 : (!fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>, !fir.shape<2>, index) -> !fir.ref<!fir.array<10x20x!fir.char<1,5>>>
25 // CHECK-LABEL: func.func @test_array_char_comp_1(
26 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>) {
27 // CHECK: %[[VAL_1:.*]] = fir.declare %[[VAL_0]] {uniq_name = "a"}
28 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
29 // CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
30 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
31 // CHECK: %[[VAL_5:.*]] = arith.constant 5 : index
32 // CHECK: %[[VAL_6:.*]] = fir.field_index array_char_comp, !fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>
33 // CHECK: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_6]] : (!fir.ref<!fir.type<t_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>, !fir.field) -> !fir.ref<!fir.array<10x20x!fir.char<1,5>>>
35 func.func @test_array(%arg0: !fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>) {
36 %0:2 = hlfir.declare %arg0 {uniq_name = "a"} : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>) -> (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>, !fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>)
37 %c0 = arith.constant 0 : index
38 %4:3 = fir.box_dims %0#0, %c0 : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>, index) -> (index, index, index)
39 %5 = fir.shape %4#1 : (index) -> !fir.shape<1>
40 %6 = hlfir.designate %0#0{"scalar_x"} shape %5 : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<?xf32>>
43 // CHECK-LABEL: func.func @test_array(
44 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>) {
45 // CHECK: %[[VAL_1:.*]] = fir.declare %[[VAL_0]] {uniq_name = "a"}
46 // CHECK: %[[VAL_2:.*]] = fir.rebox %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>) -> !fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>
47 // CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
48 // CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_3]] : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>, index) -> (index, index, index)
49 // CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]]#1 : (index) -> !fir.shape<1>
50 // CHECK: %[[VAL_6:.*]] = fir.field_index scalar_x, !fir.type<t1{scalar_i:i32,scalar_x:f32}>
51 // CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
52 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
53 // CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
54 // CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_9]] : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>, index) -> (index, index, index)
55 // CHECK: %[[VAL_11:.*]] = fir.slice %[[VAL_8]], %[[VAL_10]]#1, %[[VAL_7]] path %[[VAL_6]] : (index, index, index, !fir.field) -> !fir.slice<1>
56 // CHECK: %[[VAL_12:.*]] = fir.rebox %[[VAL_2]] {{\[}}%[[VAL_11]]] : (!fir.box<!fir.array<?x!fir.type<t1{scalar_i:i32,scalar_x:f32}>>>, !fir.slice<1>) -> !fir.box<!fir.array<?xf32>>
58 func.func @test_array_char(%arg0: !fir.ref<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, %n : index) {
59 %5 = fir.shape %n : (index) -> !fir.shape<1>
60 %6:2 = hlfir.declare %arg0(%5) {uniq_name = "a"} : (!fir.ref<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>) -> (!fir.box<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.ref<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>)
61 %c5 = arith.constant 5 : index
62 %10 = hlfir.designate %6#0{"scalar_char"} shape %5 typeparams %c5 : (!fir.box<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>, index) -> !fir.box<!fir.array<?x!fir.char<1,5>>>
65 // CHECK-LABEL: func.func @test_array_char(
66 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>,
67 // CHECK-SAME: %[[VAL_1:.*]]: index) {
68 // CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
69 // CHECK: %[[VAL_9:.*]] = fir.declare %[[VAL_0]](%[[VAL_8]]) {uniq_name = "a"}
70 // CHECK: %[[VAL_10:.*]] = fir.embox %[[VAL_9]](%[[VAL_8]]) : (!fir.ref<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>) -> !fir.box<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>
71 // CHECK: %[[VAL_11:.*]] = arith.constant 5 : index
72 // CHECK: %[[VAL_12:.*]] = fir.field_index scalar_char, !fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>
73 // CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
74 // CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
75 // CHECK: %[[VAL_15:.*]] = fir.slice %[[VAL_14]], %[[VAL_1]], %[[VAL_13]] path %[[VAL_12]] : (index, index, index, !fir.field) -> !fir.slice<1>
76 // CHECK: %[[VAL_16:.*]] = fir.embox %[[VAL_9]](%[[VAL_8]]) {{\[}}%[[VAL_15]]] : (!fir.ref<!fir.array<?x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<?x!fir.char<1,5>>>
78 func.func @test_array_char_substring(%arg0: !fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>) {
79 %c100 = arith.constant 100 : index
80 %0 = fir.shape %c100 : (index) -> !fir.shape<1>
81 %1:2 = hlfir.declare %arg0(%0) {uniq_name = "a"} : (!fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>)
82 %c3 = arith.constant 3 : index
83 %c5 = arith.constant 5 : index
84 %c3_0 = arith.constant 3 : index
85 %5 = hlfir.designate %1#0{"scalar_char"} substr %c3, %c5 shape %0 typeparams %c3_0 : (!fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<100x!fir.char<1,3>>>
88 // CHECK-LABEL: func.func @test_array_char_substring(
89 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>) {
90 // CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
91 // CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
92 // CHECK: %[[VAL_3:.*]] = fir.declare %[[VAL_0]](%[[VAL_2]]) {uniq_name = "a"}
93 // CHECK: %[[VAL_4:.*]] = arith.constant 3 : index
94 // CHECK: %[[VAL_5:.*]] = arith.constant 5 : index
95 // CHECK: %[[VAL_6:.*]] = arith.constant 3 : index
96 // CHECK: %[[VAL_7:.*]] = fir.field_index scalar_char, !fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>
97 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
98 // CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
99 // CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
100 // CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_4]], %[[VAL_10]] : index
101 // CHECK: %[[VAL_12:.*]] = fir.slice %[[VAL_9]], %[[VAL_1]], %[[VAL_8]] path %[[VAL_7]] substr %[[VAL_11]], %[[VAL_6]] : (index, index, index, !fir.field, index, index) -> !fir.slice<1>
102 // CHECK: %[[VAL_13:.*]] = fir.embox %[[VAL_3]](%[[VAL_2]]) {{\[}}%[[VAL_12]]] : (!fir.ref<!fir.array<100x!fir.type<t_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<100x!fir.char<1,3>>>
104 func.func @test_array_array_comp_1(%arg0: !fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>) {
105 %c100 = arith.constant 100 : index
106 %0 = fir.shape %c100 : (index) -> !fir.shape<1>
107 %1:2 = hlfir.declare %arg0(%0) {uniq_name = "a"} : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>)
108 %c10 = arith.constant 10 : index
109 %c20 = arith.constant 20 : index
110 %5 = fir.shape %c10, %c20 : (index, index) -> !fir.shape<2>
111 %c4 = arith.constant 4 : index
112 %c5 = arith.constant 5 : index
113 %6 = hlfir.designate %1#0{"array_comp"} <%5> (%c4, %c5) shape %0 : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<2>, index, index, !fir.shape<1>) -> !fir.box<!fir.array<100xf32>>
116 // CHECK-LABEL: func.func @test_array_array_comp_1(
117 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>) {
118 // CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
119 // CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
120 // CHECK: %[[VAL_3:.*]] = fir.declare %[[VAL_0]](%[[VAL_2]]) {uniq_name = "a"}
121 // CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
122 // CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
123 // CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
124 // CHECK: %[[VAL_7:.*]] = arith.constant 4 : index
125 // CHECK: %[[VAL_8:.*]] = arith.constant 5 : index
126 // CHECK: %[[VAL_9:.*]] = fir.field_index array_comp, !fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>
127 // CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
128 // CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
129 // CHECK: %[[ANOTHER_ONE:.*]] = arith.constant 1 : index
130 // CHECK: %[[VAL_7B:.*]] = arith.subi %[[VAL_7]], %[[ANOTHER_ONE]] : index
131 // CHECK: %[[VAL_8B:.*]] = arith.subi %[[VAL_8]], %[[ANOTHER_ONE]] : index
132 // CHECK: %[[VAL_12:.*]] = fir.slice %[[VAL_11]], %[[VAL_1]], %[[VAL_10]] path %[[VAL_9]], %[[VAL_7B]], %[[VAL_8B]] : (index, index, index, !fir.field, index, index) -> !fir.slice<1>
133 // CHECK: %[[VAL_13:.*]] = fir.embox %[[VAL_3]](%[[VAL_2]]) {{\[}}%[[VAL_12]]] : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<100xf32>>
136 func.func @test_array_array_comp_1_with_lbs(%arg0: !fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>) {
137 %c100 = arith.constant 100 : index
138 %0 = fir.shape %c100 : (index) -> !fir.shape<1>
139 %1:2 = hlfir.declare %arg0(%0) {uniq_name = "a"} : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<1>) -> (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>)
140 %c10 = arith.constant 10 : index
141 %c20 = arith.constant 20 : index
142 %c42 = arith.constant 42 : index
143 %c43 = arith.constant 43 : index
144 %5 = fir.shape_shift %c42, %c10, %c43, %c20 : (index, index, index, index) -> !fir.shapeshift<2>
145 %c45 = arith.constant 45 : index
146 %c47 = arith.constant 47 : index
147 %6 = hlfir.designate %1#0{"array_comp"} <%5> (%c45, %c47) shape %0 : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shapeshift<2>, index, index, !fir.shape<1>) -> !fir.box<!fir.array<100xf32>>
150 // CHECK-LABEL: func.func @test_array_array_comp_1_with_lbs(
151 // CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
152 // CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
153 // CHECK: %[[VAL_3:.*]] = fir.declare %{{.*}}(%[[VAL_2]]) {uniq_name = "a"} : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<1>) -> !fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>
154 // CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
155 // CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
156 // CHECK: %[[VAL_6:.*]] = arith.constant 42 : index
157 // CHECK: %[[VAL_7:.*]] = arith.constant 43 : index
158 // CHECK: %[[VAL_8:.*]] = fir.shape_shift %[[VAL_6]], %[[VAL_4]], %[[VAL_7]], %[[VAL_5]] : (index, index, index, index) -> !fir.shapeshift<2>
159 // CHECK: %[[VAL_9:.*]] = arith.constant 45 : index
160 // CHECK: %[[VAL_10:.*]] = arith.constant 47 : index
161 // CHECK: %[[VAL_11:.*]] = fir.field_index array_comp, !fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>
162 // CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
163 // CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
164 // CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_9]], %[[VAL_6]] : index
165 // CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_10]], %[[VAL_7]] : index
166 // CHECK: %[[VAL_16:.*]] = fir.slice %[[VAL_13]], %[[VAL_1]], %[[VAL_12]] path %[[VAL_11]], %[[VAL_14]], %[[VAL_15]] : (index, index, index, !fir.field, index, index) -> !fir.slice<1>
167 // CHECK: %[[VAL_17:.*]] = fir.embox %[[VAL_3]](%[[VAL_2]]) {{\[}}%[[VAL_16]]] : (!fir.ref<!fir.array<100x!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<100xf32>>
170 func.func @test_array_comp_slice(%arg0: !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) {
171 %0:2 = hlfir.declare %arg0 {uniq_name = "ga"} : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) -> (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>)
172 %c10 = arith.constant 10 : index
173 %c20 = arith.constant 20 : index
174 %1 = fir.shape %c10, %c20 : (index, index) -> !fir.shape<2>
175 %c1 = arith.constant 1 : index
176 %c4 = arith.constant 4 : index
177 %c17 = arith.constant 17 : index
178 %2 = fir.shape %c10, %c17 : (index, index) -> !fir.shape<2>
179 %3 = hlfir.designate %0#0{"array_comp"} <%1> (%c1:%c10:%c1, %c4:%c20:%c1) shape %2 : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.shape<2>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.ref<!fir.array<10x17xf32>>
182 // CHECK-LABEL: func.func @test_array_comp_slice(
183 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) {
184 // CHECK: %[[VAL_1:.*]] = fir.declare %[[VAL_0]] {uniq_name = "ga"} : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) -> !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>
185 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
186 // CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
187 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
188 // CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
189 // CHECK: %[[VAL_6:.*]] = arith.constant 4 : index
190 // CHECK: %[[VAL_7:.*]] = arith.constant 17 : index
191 // CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_2]], %[[VAL_7]] : (index, index) -> !fir.shape<2>
192 // CHECK: %[[VAL_9:.*]] = fir.field_index array_comp, !fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>
193 // CHECK: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_9]] : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.field) -> !fir.ref<!fir.array<10x20xf32>>
194 // CHECK: %[[VAL_11:.*]] = fir.array_coor %[[VAL_10]](%[[VAL_4]]) %[[VAL_5]], %[[VAL_6]] : (!fir.ref<!fir.array<10x20xf32>>, !fir.shape<2>, index, index) -> !fir.ref<f32>
195 // CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref<f32>) -> !fir.ref<!fir.array<10x17xf32>>
198 func.func @test_array_comp_non_contiguous_slice(%arg0: !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) {
199 %0:2 = hlfir.declare %arg0 {uniq_name = "ga"} : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) -> (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>)
200 %c10 = arith.constant 10 : index
201 %c20 = arith.constant 20 : index
202 %4 = fir.shape %c10, %c20 : (index, index) -> !fir.shape<2>
203 %c1 = arith.constant 1 : index
204 %c6 = arith.constant 6 : index
205 %c4 = arith.constant 4 : index
206 %c17 = arith.constant 17 : index
207 %5 = fir.shape %c6, %c17 : (index, index) -> !fir.shape<2>
208 %6 = hlfir.designate %0#0{"array_comp"} <%4> (%c1:%c6:%c1, %c4:%c20:%c1) shape %5 : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.shape<2>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.box<!fir.array<6x17xf32>>
211 // CHECK-LABEL: func.func @test_array_comp_non_contiguous_slice(
212 // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) {
213 // CHECK: %[[VAL_1:.*]] = fir.declare %[[VAL_0]] {uniq_name = "ga"} : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>) -> !fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>
214 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
215 // CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
216 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
217 // CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
218 // CHECK: %[[VAL_6:.*]] = arith.constant 6 : index
219 // CHECK: %[[VAL_7:.*]] = arith.constant 4 : index
220 // CHECK: %[[VAL_8:.*]] = arith.constant 17 : index
221 // CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_6]], %[[VAL_8]] : (index, index) -> !fir.shape<2>
222 // CHECK: %[[VAL_10:.*]] = fir.field_index array_comp, !fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>
223 // CHECK: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_10]] : (!fir.ref<!fir.type<t_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.field) -> !fir.ref<!fir.array<10x20xf32>>
224 // CHECK: %[[VAL_12:.*]] = fir.undefined index
225 // CHECK: %[[VAL_13:.*]] = fir.slice %[[VAL_5]], %[[VAL_6]], %[[VAL_5]], %[[VAL_7]], %[[VAL_3]], %[[VAL_5]] : (index, index, index, index, index, index) -> !fir.slice<2>
226 // CHECK: %[[VAL_14:.*]] = fir.embox %[[VAL_11]](%[[VAL_4]]) {{\[}}%[[VAL_13]]] : (!fir.ref<!fir.array<10x20xf32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.box<!fir.array<6x17xf32>>