1! Test lowering of pointer assignments 2! RUN: bbc -emit-fir %s -o - | FileCheck %s 3 4 5! Note that p => NULL() are tested in pointer-disassociate.f90 6 7! ----------------------------------------------------------------------------- 8! Test simple pointer assignments to contiguous right-hand side 9! ----------------------------------------------------------------------------- 10 11! CHECK-LABEL: func @_QPtest_scalar( 12! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<f32>>>{{.*}}, %[[x:.*]]: !fir.ref<f32> {{{.*}}, fir.target}) 13subroutine test_scalar(p, x) 14 real, target :: x 15 real, pointer :: p 16 ! CHECK: %[[box:.*]] = fir.embox %[[x]] : (!fir.ref<f32>) -> !fir.box<!fir.ptr<f32>> 17 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<f32>>> 18 p => x 19end subroutine 20 21! CHECK-LABEL: func @_QPtest_scalar_char( 22! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>{{.*}}, %[[x:.*]]: !fir.boxchar<1> {{{.*}}, fir.target}) 23subroutine test_scalar_char(p, x) 24 character(*), target :: x 25 character(:), pointer :: p 26 ! CHECK: %[[c:.*]]:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) 27 ! CHECK: %[[box:.*]] = fir.embox %[[c]]#0 typeparams %[[c]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>> 28 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>> 29 p => x 30end subroutine 31 32! CHECK-LABEL: func @_QPtest_array( 33! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.ref<!fir.array<100xf32>> {{{.*}}, fir.target}) 34subroutine test_array(p, x) 35 real, target :: x(100) 36 real, pointer :: p(:) 37 ! CHECK: %[[shape:.*]] = fir.shape %c100{{.*}} 38 ! CHECK: %[[box:.*]] = fir.embox %[[x]](%[[shape]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 39 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 40 p => x 41end subroutine 42 43! CHECK-LABEL: func @_QPtest_array_char( 44! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>{{.*}}, %[[x:.*]]: !fir.boxchar<1> {{{.*}}, fir.target}) { 45subroutine test_array_char(p, x) 46 character(*), target :: x(100) 47 character(:), pointer :: p(:) 48 ! CHECK: %[[c:.*]]:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) 49 ! CHECK: %[[xaddr:.*]] = fir.convert %[[c]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>> 50 ! CHECK-DAG: %[[xaddr2:.*]] = fir.convert %[[xaddr]] : (!fir.ref<!fir.array<100x!fir.char<1,?>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>> 51 ! CHECK-DAG: %[[shape:.*]] = fir.shape %c100{{.*}} 52 ! CHECK: %[[box:.*]] = fir.embox %[[xaddr2]](%[[shape]]) typeparams %[[c]]#1 53 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>> 54 p => x 55end subroutine 56 57! Test 10.2.2.3 point 10: lower bounds requirements: 58! pointer takes lbounds from rhs if no bounds spec. 59! CHECK-LABEL: func @_QPtest_array_with_lbs( 60! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 61subroutine test_array_with_lbs(p, x) 62 real, target :: x(51:150) 63 real, pointer :: p(:) 64 ! CHECK: %[[shape:.*]] = fir.shape_shift %c51{{.*}}, %c100{{.*}} 65 ! CHECK: %[[box:.*]] = fir.embox %{{.*}}(%[[shape]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 66 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 67 p => x 68end subroutine 69 70! ----------------------------------------------------------------------------- 71! Test pointer assignments with bound specs to contiguous right-hand side 72! ----------------------------------------------------------------------------- 73 74! Test 10.2.2.3 point 10: lower bounds requirements: 75! pointer takes lbounds from bound spec if specified 76! CHECK-LABEL: func @_QPtest_array_with_new_lbs( 77! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 78subroutine test_array_with_new_lbs(p, x) 79 real, target :: x(51:150) 80 real, pointer :: p(:) 81 ! CHECK: %[[shape:.*]] = fir.shape_shift %c4{{.*}}, %c100{{.*}} 82 ! CHECK: %[[box:.*]] = fir.embox %{{.*}}(%[[shape]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 83 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 84 p(4:) => x 85end subroutine 86 87! Test F2018 10.2.2.3 point 9: bounds remapping 88! CHECK-LABEL: func @_QPtest_array_remap( 89! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>{{.*}}, %[[x:.*]]: !fir.ref<!fir.array<100xf32>> {{{.*}}, fir.target}) 90subroutine test_array_remap(p, x) 91 real, target :: x(100) 92 real, pointer :: p(:, :) 93 ! CHECK-DAG: %[[c2_idx:.*]] = fir.convert %c2{{.*}} : (i64) -> index 94 ! CHECK-DAG: %[[c11_idx:.*]] = fir.convert %c11{{.*}} : (i64) -> index 95 ! CHECK-DAG: %[[diff0:.*]] = arith.subi %[[c11_idx]], %[[c2_idx]] : index 96 ! CHECK-DAG: %[[ext0:.*]] = arith.addi %[[diff0:.*]], %c1{{.*}} : index 97 ! CHECK-DAG: %[[c3_idx:.*]] = fir.convert %c3{{.*}} : (i64) -> index 98 ! CHECK-DAG: %[[c12_idx:.*]] = fir.convert %c12{{.*}} : (i64) -> index 99 ! CHECK-DAG: %[[diff1:.*]] = arith.subi %[[c12_idx]], %[[c3_idx]] : index 100 ! CHECK-DAG: %[[ext1:.*]] = arith.addi %[[diff1]], %c1{{.*}} : index 101 ! CHECK-DAG: %[[addrCast:.*]] = fir.convert %[[x]] : (!fir.ref<!fir.array<100xf32>>) -> !fir.ref<!fir.array<?x?xf32>> 102 ! CHECK: %[[shape:.*]] = fir.shape_shift %c2{{.*}}, %[[ext0]], %c3{{.*}}, %[[ext1]] 103 ! CHECK: %[[box:.*]] = fir.embox %[[addrCast]](%[[shape]]) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>> 104 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>> 105 p(2:11, 3:12) => x 106end subroutine 107 108! CHECK-LABEL: func @_QPtest_array_char_remap( 109! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x!fir.char<1,?>>>>>{{.*}}, %[[x:.*]]: !fir.boxchar<1> {{{.*}}, fir.target}) 110subroutine test_array_char_remap(p, x) 111 ! CHECK: %[[unbox:.*]]:2 = fir.unboxchar %[[x]] 112 character(*), target :: x(100) 113 character(:), pointer :: p(:, :) 114 ! CHECK: subi 115 ! CHECK: %[[ext0:.*]] = arith.addi 116 ! CHECK: subi 117 ! CHECK: %[[ext1:.*]] = arith.addi 118 ! CHECK: %[[shape:.*]] = fir.shape_shift %c2{{.*}}, %[[ext0]], %c3{{.*}}, %[[ext1]] 119 ! CHECK: %[[box:.*]] = fir.embox %{{.*}}(%[[shape]]) typeparams %[[unbox]]#1 : (!fir.ref<!fir.array<?x?x!fir.char<1,?>>>, !fir.shapeshift<2>, index) -> !fir.box<!fir.ptr<!fir.array<?x?x!fir.char<1,?>>>> 120 ! CHECK: fir.store %[[box]] to %[[p]] 121 p(2:11, 3:12) => x 122end subroutine 123 124! ----------------------------------------------------------------------------- 125! Test simple pointer assignments to non contiguous right-hand side 126! ----------------------------------------------------------------------------- 127 128! CHECK-LABEL: func @_QPtest_array_non_contig_rhs( 129! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target}) 130subroutine test_array_non_contig_rhs(p, x) 131 real, target :: x(:) 132 real, pointer :: p(:) 133 ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 134 ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 135 p => x 136end subroutine 137 138! Test 10.2.2.3 point 10: lower bounds requirements: 139! pointer takes lbounds from rhs if no bounds spec. 140! CHECK-LABEL: func @_QPtest_array_non_contig_rhs_lbs( 141! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target}) 142subroutine test_array_non_contig_rhs_lbs(p, x) 143 real, target :: x(7:) 144 real, pointer :: p(:) 145 ! CHECK: %[[c7_idx:.*]] = fir.convert %c7{{.*}} : (i64) -> index 146 ! CHECK: %[[shift:.*]] = fir.shift %[[c7_idx]] : (index) -> !fir.shift<1> 147 ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]](%[[shift]]) : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 148 ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 149 p => x 150end subroutine 151 152! CHECK-LABEL: func @_QPtest_array_non_contig_rhs2( 153! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<200xf32>> {{{.*}}, fir.target}) { 154! CHECK: %[[VAL_2:.*]] = arith.constant 200 : index 155! CHECK: %[[VAL_3:.*]] = arith.constant 10 : i64 156! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i64) -> index 157! CHECK: %[[VAL_5:.*]] = arith.constant 3 : i64 158! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index 159! CHECK: %[[VAL_7:.*]] = arith.constant 160 : i64 160! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index 161! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> 162! CHECK: %[[VAL_10:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] : (index, index, index) -> !fir.slice<1> 163! CHECK: %[[VAL_11:.*]] = fir.embox %[[VAL_1]](%[[VAL_9]]) {{\[}}%[[VAL_10]]] : (!fir.ref<!fir.array<200xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<51xf32>> 164! CHECK: %[[VAL_12:.*]] = fir.rebox %[[VAL_11]] : (!fir.box<!fir.array<51xf32>>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 165! CHECK: fir.store %[[VAL_12]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 166! CHECK: return 167! CHECK: } 168 169subroutine test_array_non_contig_rhs2(p, x) 170 real, target :: x(200) 171 real, pointer :: p(:) 172 p => x(10:160:3) 173end subroutine 174 175! ----------------------------------------------------------------------------- 176! Test pointer assignments with bound specs to non contiguous right-hand side 177! ----------------------------------------------------------------------------- 178 179 180! Test 10.2.2.3 point 10: lower bounds requirements: 181! pointer takes lbounds from bound spec if specified 182! CHECK-LABEL: func @_QPtest_array_non_contig_rhs_new_lbs( 183! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target}) 184subroutine test_array_non_contig_rhs_new_lbs(p, x) 185 real, target :: x(7:) 186 real, pointer :: p(:) 187 ! CHECK: %[[shift:.*]] = fir.shift %c4{{.*}} 188 ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]](%[[shift]]) : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>> 189 190 ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> 191 p(4:) => x 192end subroutine 193 194! Test F2018 10.2.2.3 point 9: bounds remapping 195! CHECK-LABEL: func @_QPtest_array_non_contig_remap( 196! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target}) 197subroutine test_array_non_contig_remap(p, x) 198 real, target :: x(:) 199 real, pointer :: p(:, :) 200 ! CHECK: subi 201 ! CHECK: %[[ext0:.*]] = arith.addi 202 ! CHECK: subi 203 ! CHECK: %[[ext1:.*]] = arith.addi 204 ! CHECK: %[[shape:.*]] = fir.shape_shift %{{.*}}, %[[ext0]], %{{.*}}, %[[ext1]] 205 ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]](%[[shape]]) : (!fir.box<!fir.array<?xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>> 206 ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>> 207 p(2:11, 3:12) => x 208end subroutine 209 210! Test remapping a slice 211 212! CHECK-LABEL: func @_QPtest_array_non_contig_remap_slice( 213! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<400xf32>> {{{.*}}, fir.target}) { 214! CHECK: %[[VAL_2:.*]] = arith.constant 400 : index 215! CHECK: %[[VAL_3:.*]] = arith.constant 2 : i64 216! CHECK: %[[VAL_4:.*]] = arith.constant 11 : i64 217! CHECK: %[[VAL_5:.*]] = arith.constant 3 : i64 218! CHECK: %[[VAL_6:.*]] = arith.constant 12 : i64 219! CHECK: %[[VAL_7:.*]] = arith.constant 51 : i64 220! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index 221! CHECK: %[[VAL_9:.*]] = arith.constant 3 : i64 222! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> index 223! CHECK: %[[VAL_11:.*]] = arith.constant 350 : i64 224! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index 225! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> 226! CHECK: %[[VAL_14:.*]] = fir.slice %[[VAL_8]], %[[VAL_12]], %[[VAL_10]] : (index, index, index) -> !fir.slice<1> 227! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_1]](%[[VAL_13]]) {{\[}}%[[VAL_14]]] : (!fir.ref<!fir.array<400xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<100xf32>> 228! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index 229! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_3]] : (i64) -> index 230! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_4]] : (i64) -> index 231! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_18]], %[[VAL_17]] : index 232! CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_19]], %[[VAL_16]] : index 233! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_5]] : (i64) -> index 234! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_6]] : (i64) -> index 235! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_22]], %[[VAL_21]] : index 236! CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_23]], %[[VAL_16]] : index 237! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_3]] : (i64) -> index 238! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_5]] : (i64) -> index 239! CHECK: %[[VAL_27:.*]] = fir.shape_shift %[[VAL_25]], %[[VAL_20]], %[[VAL_26]], %[[VAL_24]] : (index, index, index, index) -> !fir.shapeshift<2> 240! CHECK: %[[VAL_28:.*]] = fir.rebox %[[VAL_15]](%[[VAL_27]]) : (!fir.box<!fir.array<100xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>> 241! CHECK: fir.store %[[VAL_28]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>> 242! CHECK: return 243! CHECK: } 244subroutine test_array_non_contig_remap_slice(p, x) 245 real, target :: x(400) 246 real, pointer :: p(:, :) 247 p(2:11, 3:12) => x(51:350:3) 248end subroutine 249 250! ----------------------------------------------------------------------------- 251! Test pointer assignments that involves LHS pointers lowered to local variables 252! instead of a fir.ref<fir.box>, and RHS that are fir.box 253! ----------------------------------------------------------------------------- 254 255! CHECK-LABEL: func @_QPissue857( 256! CHECK-SAME: %[[rhs:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>> 257subroutine issue857(rhs) 258 type t 259 integer :: i 260 end type 261 type(t), pointer :: rhs, lhs 262 ! CHECK: %[[lhs:.*]] = fir.alloca !fir.ptr<!fir.type<_QFissue857Tt{i:i32}>> 263 ! CHECK: %[[box_load:.*]] = fir.load %[[rhs]] : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>> 264 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>) -> !fir.ptr<!fir.type<_QFissue857Tt{i:i32}>> 265 ! CHECK: fir.store %[[addr]] to %[[lhs]] : !fir.ref<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>> 266 lhs => rhs 267end subroutine 268 269! CHECK-LABEL: func @_QPissue857_array( 270! CHECK-SAME: %[[rhs:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>> 271subroutine issue857_array(rhs) 272 type t 273 integer :: i 274 end type 275 type(t), contiguous, pointer :: rhs(:), lhs(:) 276 ! CHECK-DAG: %[[lhs_addr:.*]] = fir.alloca !fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>> {uniq_name = "_QFissue857_arrayElhs.addr"} 277 ! CHECK-DAG: %[[lhs_lb:.*]] = fir.alloca index {uniq_name = "_QFissue857_arrayElhs.lb0"} 278 ! CHECK-DAG: %[[lhs_ext:.*]] = fir.alloca index {uniq_name = "_QFissue857_arrayElhs.ext0"} 279 ! CHECK: %[[box:.*]] = fir.load %[[rhs]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>> 280 ! CHECK: %[[lb:.*]]:3 = fir.box_dims %[[box]], %c{{.*}} : (!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>, index) -> (index, index, index) 281 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>) -> !fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>> 282 ! CHECK: %[[ext:.*]]:3 = fir.box_dims %[[box]], %c0{{.*}} : (!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>, index) -> (index, index, index) 283 ! CHECK-DAG: fir.store %[[addr]] to %[[lhs_addr]] : !fir.ref<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>> 284 ! CHECK-DAG: fir.store %[[ext]]#1 to %[[lhs_ext]] : !fir.ref<index> 285 ! CHECK-DAG: fir.store %[[lb]]#0 to %[[lhs_lb]] : !fir.ref<index> 286 lhs => rhs 287end subroutine 288 289! CHECK-LABEL: func @_QPissue857_array_shift( 290subroutine issue857_array_shift(rhs) 291 ! Test lower bounds is the one from the shift 292 type t 293 integer :: i 294 end type 295 type(t), contiguous, pointer :: rhs(:), lhs(:) 296 ! CHECK: %[[lhs_lb:.*]] = fir.alloca index {uniq_name = "_QFissue857_array_shiftElhs.lb0"} 297 ! CHECK: %[[c42:.*]] = fir.convert %c42{{.*}} : (i64) -> index 298 ! CHECK: fir.store %[[c42]] to %[[lhs_lb]] : !fir.ref<index> 299 lhs(42:) => rhs 300end subroutine 301 302! CHECK-LABEL: func @_QPissue857_array_remap 303subroutine issue857_array_remap(rhs) 304 ! Test lower bounds is the one from the shift 305 type t 306 integer :: i 307 end type 308 type(t), contiguous, pointer :: rhs(:, :), lhs(:) 309 ! CHECK-DAG: %[[lhs_addr:.*]] = fir.alloca !fir.ptr<!fir.array<?x!fir.type<_QFissue857_array_remapTt{i:i32}>>> {uniq_name = "_QFissue857_array_remapElhs.addr"} 310 ! CHECK-DAG: %[[lhs_lb:.*]] = fir.alloca index {uniq_name = "_QFissue857_array_remapElhs.lb0"} 311 ! CHECK-DAG: %[[lhs_ext:.*]] = fir.alloca index {uniq_name = "_QFissue857_array_remapElhs.ext0"} 312 313 ! CHECK: %[[c101:.*]] = fir.convert %c101_i64 : (i64) -> index 314 ! CHECK: %[[c200:.*]] = fir.convert %c200_i64 : (i64) -> index 315 ! CHECK: %[[sub:.*]] = arith.subi %[[c200]], %[[c101]] : index 316 ! CHECK: %[[extent:.*]] = arith.addi %[[sub]], %c1{{.*}} : index 317 ! CHECK: %[[addr:.*]] = fir.box_addr %{{.*}} : (!fir.box<!fir.ptr<!fir.array<?x?x!fir.type<_QFissue857_array_remapTt{i:i32}>>>>) -> !fir.ptr<!fir.array<?x?x!fir.type<_QFissue857_array_remapTt{i:i32}>>> 318 ! CHECK: %[[addr_cast:.*]] = fir.convert %[[addr]] : (!fir.ptr<!fir.array<?x?x!fir.type<_QFissue857_array_remapTt{i:i32}>>>) -> !fir.ptr<!fir.array<?x!fir.type<_QFissue857_array_remapTt{i:i32}>>> 319 ! CHECK: fir.store %[[addr_cast]] to %[[lhs_addr]] : !fir.ref<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_array_remapTt{i:i32}>>>> 320 ! CHECK: fir.store %[[extent]] to %[[lhs_ext]] : !fir.ref<index> 321 ! CHECK: %[[c101_2:.*]] = fir.convert %c101{{.*}} : (i64) -> index 322 ! CHECK: fir.store %[[c101_2]] to %[[lhs_lb]] : !fir.ref<index> 323 lhs(101:200) => rhs 324end subroutine 325 326! CHECK-LABEL: func @_QPissue857_char 327subroutine issue857_char(rhs) 328 ! Only check that the length is taken from the fir.box created for the slice. 329 ! CHECK-DAG: %[[lhs1_len:.*]] = fir.alloca index {uniq_name = "_QFissue857_charElhs1.len"} 330 ! CHECK-DAG: %[[lhs2_len:.*]] = fir.alloca index {uniq_name = "_QFissue857_charElhs2.len"} 331 character(:), contiguous, pointer :: lhs1(:), lhs2(:, :) 332 character(*), target :: rhs(100) 333 ! CHECK: %[[len:.*]] = fir.box_elesize %{{.*}} : (!fir.box<!fir.array<50x!fir.char<1,?>>>) -> index 334 ! CHECK: fir.store %[[len]] to %[[lhs1_len]] : !fir.ref<index> 335 lhs1 => rhs(1:50:1) 336 ! CHECK: %[[len2:.*]] = fir.box_elesize %{{.*}} : (!fir.box<!fir.array<50x!fir.char<1,?>>>) -> index 337 ! CHECK: fir.store %[[len2]] to %[[lhs2_len]] : !fir.ref<index> 338 lhs2(1:2, 1:25) => rhs(1:50:1) 339end subroutine 340 341! CHECK-LABEL: func @_QPissue1180( 342! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {{{.*}}, fir.target}) { 343subroutine issue1180(x) 344 integer, target :: x 345 integer, pointer :: p 346 common /some_common/ p 347 ! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QBsome_common) : !fir.ref<!fir.array<24xi8>> 348 ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.array<24xi8>>) -> !fir.ref<!fir.array<?xi8>> 349 ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index 350 ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8> 351 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<i8>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> 352 ! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]] : (!fir.ref<i32>) -> !fir.box<!fir.ptr<i32>> 353 ! CHECK: fir.store %[[VAL_6]] to %[[VAL_5]] : !fir.ref<!fir.box<!fir.ptr<i32>>> 354 p => x 355end subroutine 356