brintos

brintos / llvm-project-archived public Read only

0
0
Text · 22.3 KiB · 98fd61d Raw
385 lines · plain
1! Test lowering of pointer assignments2! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s3 4 5! Note that p => NULL() are tested in pointer-disassociate.f906 7! -----------------------------------------------------------------------------8!     Test simple pointer assignments to contiguous right-hand side9! -----------------------------------------------------------------------------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 :: x15  real, pointer :: p16  ! 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 => x19end subroutine20 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 :: x25  character(:), pointer :: p26  ! 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 => x30end subroutine31 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 => x41end subroutine42 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]]#153  ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.char<1,?>>>>>54  p => x55end subroutine56 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 => x68end subroutine69 70! Test that the lhs takes the bounds from rhs.71! CHECK-LABEL: func @_QPtest_pointer_component(72! CHECK-SAME: %[[temp:.*]]: !fir.ref<!fir.type<_QFtest_pointer_componentTmytype{ptr:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>> {fir.bindc_name = "temp"}, %[[temp_ptr:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> {fir.bindc_name = "temp_ptr"}) {73subroutine test_pointer_component(temp, temp_ptr)74  type mytype75    real, pointer :: ptr(:)76  end type mytype77  type(mytype) :: temp78  real, pointer :: temp_ptr(:)79  ! CHECK: %[[ptr_addr:.*]] = fir.coordinate_of %[[temp]], ptr : (!fir.ref<!fir.type<_QFtest_pointer_componentTmytype{ptr:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>80  ! CHECK: %[[ptr:.*]] = fir.load %[[ptr_addr]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>81  ! CHECK: %[[dims:.*]]:3 = fir.box_dims %[[ptr]], %{{.*}} : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, index) -> (index, index, index)82  ! CHECK: %[[shift:.*]] = fir.shift %[[dims]]#0 : (index) -> !fir.shift<1>83  ! CHECK: %[[arr_box:.*]] = fir.rebox %[[ptr]](%[[shift]]) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, !fir.shift<1>) -> !fir.box<!fir.array<?xf32>>84  ! CHECK: %[[shift2:.*]] = fir.shift %[[dims]]#0 : (index) -> !fir.shift<1>85  ! CHECK: %[[final_box:.*]] = fir.rebox %[[arr_box]](%[[shift2]]) : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>86  ! CHECK: fir.store %[[final_box]] to %[[temp_ptr]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>87  temp_ptr => temp%ptr88end subroutine89 90! -----------------------------------------------------------------------------91!    Test pointer assignments with bound specs to contiguous right-hand side92! -----------------------------------------------------------------------------93 94! Test 10.2.2.3 point 10: lower bounds requirements:95! pointer takes lbounds from bound spec if specified96! CHECK-LABEL: func @_QPtest_array_with_new_lbs(97! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>98subroutine test_array_with_new_lbs(p, x)99  real, target :: x(51:150)100  real, pointer :: p(:)101  ! CHECK: %[[shape:.*]] = fir.shape_shift %c4{{.*}}, %c100{{.*}}102  ! CHECK: %[[box:.*]] = fir.embox %{{.*}}(%[[shape]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>103  ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>104  p(4:) => x105end subroutine106 107! Test F2018 10.2.2.3 point 9: bounds remapping108! CHECK-LABEL: func @_QPtest_array_remap(109! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>{{.*}}, %[[x:.*]]: !fir.ref<!fir.array<100xf32>> {{{.*}}, fir.target})110subroutine test_array_remap(p, x)111  real, target :: x(100)112  real, pointer :: p(:, :)113  ! CHECK-DAG: %[[c2_idx:.*]] = fir.convert %c2{{.*}} : (i64) -> index114  ! CHECK-DAG: %[[c11_idx:.*]] = fir.convert %c11{{.*}} : (i64) -> index115  ! CHECK-DAG: %[[diff0:.*]] = arith.subi %[[c11_idx]], %[[c2_idx]] : index116  ! CHECK-DAG: %[[raw_ext0:.*]] = arith.addi %[[diff0:.*]], %c1{{.*}} : index117  ! CHECK-DAG: %[[cmp0:.*]] = arith.cmpi sgt, %[[raw_ext0]], %c0{{.*}} : index118  ! CHECK-DAG: %[[ext0:.*]] = arith.select %[[cmp0]], %[[raw_ext0]], %c0{{.*}} : index119  ! CHECK-DAG: %[[c3_idx:.*]] = fir.convert %c3{{.*}} : (i64) -> index120  ! CHECK-DAG: %[[c12_idx:.*]] = fir.convert %c12{{.*}} : (i64) -> index121  ! CHECK-DAG: %[[diff1:.*]] = arith.subi %[[c12_idx]], %[[c3_idx]] : index122  ! CHECK-DAG: %[[raw_ext1:.*]] = arith.addi %[[diff1]], %c1{{.*}} : index123  ! CHECK-DAG: %[[cmp1:.*]] = arith.cmpi sgt, %[[raw_ext1]], %c0{{.*}} : index124  ! CHECK-DAG: %[[ext1:.*]] = arith.select %[[cmp1]], %[[raw_ext1]], %c0{{.*}} : index125  ! CHECK-DAG: %[[addrCast:.*]] = fir.convert %[[x]] : (!fir.ref<!fir.array<100xf32>>) -> !fir.ref<!fir.array<?x?xf32>>126  ! CHECK: %[[shape:.*]] = fir.shape_shift %c2{{.*}}, %[[ext0]], %c3{{.*}}, %[[ext1]]127  ! CHECK: %[[box:.*]] = fir.embox %[[addrCast]](%[[shape]]) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>128  ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>129  p(2:11, 3:12) => x130end subroutine131 132! CHECK-LABEL: func @_QPtest_array_char_remap(133! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x!fir.char<1,?>>>>>{{.*}}, %[[x:.*]]: !fir.boxchar<1> {{{.*}}, fir.target})134subroutine test_array_char_remap(p, x)135  ! CHECK: %[[unbox:.*]]:2 = fir.unboxchar %[[x]]136  character(*), target :: x(100)137  character(:), pointer :: p(:, :)138  ! CHECK: subi139  ! CHECK: %[[ext0:.*]] = arith.select140  ! CHECK: subi141  ! CHECK: %[[ext1:.*]] = arith.select142  ! CHECK: %[[shape:.*]] = fir.shape_shift %c2{{.*}}, %[[ext0]], %c3{{.*}}, %[[ext1]]143  ! 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,?>>>>144  ! CHECK: fir.store %[[box]] to %[[p]]145  p(2:11, 3:12) => x146end subroutine147 148! -----------------------------------------------------------------------------149!  Test simple pointer assignments to non contiguous right-hand side150! -----------------------------------------------------------------------------151 152! CHECK-LABEL: func @_QPtest_array_non_contig_rhs(153! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target})154subroutine test_array_non_contig_rhs(p, x)155  real, target :: x(:)156  real, pointer :: p(:)157  ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>158  ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>159  p => x160end subroutine161 162! Test 10.2.2.3 point 10: lower bounds requirements:163! pointer takes lbounds from rhs if no bounds spec.164! CHECK-LABEL: func @_QPtest_array_non_contig_rhs_lbs(165! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target})166subroutine test_array_non_contig_rhs_lbs(p, x)167  real, target :: x(7:)168  real, pointer :: p(:)169  ! CHECK: %[[c7_idx:.*]] = fir.convert %c7{{.*}} : (i64) -> index170  ! CHECK: %[[shift:.*]] = fir.shift %[[c7_idx]] : (index) -> !fir.shift<1>171  ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]](%[[shift]]) : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>172  ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>173  p => x174end subroutine175 176! CHECK-LABEL: func @_QPtest_array_non_contig_rhs2(177! CHECK-SAME:                                      %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<200xf32>> {{{.*}}, fir.target}) {178! CHECK:         %[[VAL_2:.*]] = arith.constant 200 : index179! CHECK:         %[[VAL_3:.*]] = arith.constant 10 : i64180! CHECK:         %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i64) -> index181! CHECK:         %[[VAL_5:.*]] = arith.constant 3 : i64182! CHECK:         %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index183! CHECK:         %[[VAL_7:.*]] = arith.constant 160 : i64184! CHECK:         %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index185! CHECK:         %[[VAL_9:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>186! CHECK:         %[[VAL_10:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] : (index, index, index) -> !fir.slice<1>187! 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>>188! CHECK:         %[[VAL_12:.*]] = fir.rebox %[[VAL_11]] : (!fir.box<!fir.array<51xf32>>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>189! CHECK:         fir.store %[[VAL_12]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>190! CHECK:         return191! CHECK:       }192 193subroutine test_array_non_contig_rhs2(p, x)194  real, target :: x(200)195  real, pointer :: p(:)196  p => x(10:160:3)197end subroutine198 199! -----------------------------------------------------------------------------200!  Test pointer assignments with bound specs to non contiguous right-hand side201! -----------------------------------------------------------------------------202 203 204! Test 10.2.2.3 point 10: lower bounds requirements:205! pointer takes lbounds from bound spec if specified206! CHECK-LABEL: func @_QPtest_array_non_contig_rhs_new_lbs(207! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target})208subroutine test_array_non_contig_rhs_new_lbs(p, x)209  real, target :: x(7:)210  real, pointer :: p(:)211  ! CHECK: %[[shift:.*]] = fir.shift %c4{{.*}}212  ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]](%[[shift]]) : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>213 214  ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>215  p(4:) => x216end subroutine217 218! Test F2018 10.2.2.3 point 9: bounds remapping219! CHECK-LABEL: func @_QPtest_array_non_contig_remap(220! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>{{.*}}, %[[x:.*]]: !fir.box<!fir.array<?xf32>> {{{.*}}, fir.target})221subroutine test_array_non_contig_remap(p, x)222  real, target :: x(:)223  real, pointer :: p(:, :)224  ! CHECK: subi225  ! CHECK: %[[ext0:.*]] = arith.select226  ! CHECK: subi227  ! CHECK: %[[ext1:.*]] = arith.select228  ! CHECK: %[[shape:.*]] = fir.shape_shift %{{.*}}, %[[ext0]], %{{.*}}, %[[ext1]]229  ! CHECK: %[[rebox:.*]] = fir.rebox %[[x]](%[[shape]]) : (!fir.box<!fir.array<?xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>230  ! CHECK: fir.store %[[rebox]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>231  p(2:11, 3:12) => x232end subroutine233 234! Test remapping a slice235 236! CHECK-LABEL: func @_QPtest_array_non_contig_remap_slice(237! CHECK-SAME:                                             %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<400xf32>> {{{.*}}, fir.target}) {238! CHECK:         %[[VAL_2:.*]] = arith.constant 400 : index239! CHECK:         %[[VAL_3:.*]] = arith.constant 2 : i64240! CHECK:         %[[VAL_4:.*]] = arith.constant 11 : i64241! CHECK:         %[[VAL_5:.*]] = arith.constant 3 : i64242! CHECK:         %[[VAL_6:.*]] = arith.constant 12 : i64243! CHECK:         %[[VAL_7:.*]] = arith.constant 51 : i64244! CHECK:         %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index245! CHECK:         %[[VAL_9:.*]] = arith.constant 3 : i64246! CHECK:         %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> index247! CHECK:         %[[VAL_11:.*]] = arith.constant 350 : i64248! CHECK:         %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index249! CHECK:         %[[VAL_13:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>250! CHECK:         %[[VAL_14:.*]] = fir.slice %[[VAL_8]], %[[VAL_12]], %[[VAL_10]] : (index, index, index) -> !fir.slice<1>251! 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>>252! CHECK:         %[[VAL_16:.*]] = arith.constant 1 : index253! CHECK:         %[[VAL_17:.*]] = fir.convert %[[VAL_3]] : (i64) -> index254! CHECK:         %[[VAL_18:.*]] = fir.convert %[[VAL_4]] : (i64) -> index255! CHECK:         %[[VAL_19:.*]] = arith.subi %[[VAL_18]], %[[VAL_17]] : index256! CHECK:         %[[VAL_20:.*]] = arith.addi %[[VAL_19]], %[[VAL_16]] : index257! CHECK:         %[[cmp0:.*]] = arith.cmpi sgt, %[[VAL_20]], %c0{{.*}} : index258! CHECK:         %[[ext0:.*]] = arith.select %[[cmp0]], %[[VAL_20]], %c0{{.*}} : index259! CHECK:         %[[VAL_21:.*]] = fir.convert %[[VAL_5]] : (i64) -> index260! CHECK:         %[[VAL_22:.*]] = fir.convert %[[VAL_6]] : (i64) -> index261! CHECK:         %[[VAL_23:.*]] = arith.subi %[[VAL_22]], %[[VAL_21]] : index262! CHECK:         %[[VAL_24:.*]] = arith.addi %[[VAL_23]], %[[VAL_16]] : index263! CHECK:         %[[cmp1:.*]] = arith.cmpi sgt, %[[VAL_24]], %c0{{.*}} : index264! CHECK:         %[[ext1:.*]] = arith.select %[[cmp1]], %[[VAL_24]], %c0{{.*}} : index265! CHECK:         %[[VAL_25:.*]] = fir.convert %[[VAL_3]] : (i64) -> index266! CHECK:         %[[VAL_26:.*]] = fir.convert %[[VAL_5]] : (i64) -> index267! CHECK:         %[[VAL_27:.*]] = fir.shape_shift %[[VAL_25]], %[[ext0]], %[[VAL_26]], %[[ext1]] : (index, index, index, index) -> !fir.shapeshift<2>268! 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>>>269! CHECK:         fir.store %[[VAL_28]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>270! CHECK:         return271! CHECK:       }272subroutine test_array_non_contig_remap_slice(p, x)273  real, target :: x(400)274  real, pointer :: p(:, :)275  p(2:11, 3:12) => x(51:350:3)276end subroutine277 278! -----------------------------------------------------------------------------279!  Test pointer assignments that involves LHS pointers lowered to local variables280!  instead of a fir.ref<fir.box>, and RHS that are fir.box281! -----------------------------------------------------------------------------282 283! CHECK-LABEL: func @_QPissue857(284! CHECK-SAME: %[[rhs:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>>285subroutine issue857(rhs)286  type t287    integer :: i288  end type289  type(t), pointer :: rhs, lhs290  ! CHECK: %[[lhs:.*]] = fir.alloca !fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>291  ! CHECK: %[[box_load:.*]] = fir.load %[[rhs]] : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>>292  ! CHECK: %[[addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>) -> !fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>293  ! CHECK: fir.store %[[addr]] to %[[lhs]] : !fir.ref<!fir.ptr<!fir.type<_QFissue857Tt{i:i32}>>>294  lhs => rhs295end subroutine296 297! CHECK-LABEL: func @_QPissue857_array(298! CHECK-SAME: %[[rhs:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>>299subroutine issue857_array(rhs)300  type t301    integer :: i302  end type303  type(t), contiguous,  pointer :: rhs(:), lhs(:)304  ! CHECK-DAG: %[[lhs_addr:.*]] = fir.alloca !fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>> {uniq_name = "_QFissue857_arrayElhs.addr"}305  ! CHECK-DAG: %[[lhs_lb:.*]] = fir.alloca index {uniq_name = "_QFissue857_arrayElhs.lb0"}306  ! CHECK-DAG: %[[lhs_ext:.*]] = fir.alloca index {uniq_name = "_QFissue857_arrayElhs.ext0"}307  ! CHECK: %[[box:.*]] = fir.load %[[rhs]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>>308  ! 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)309  ! 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}>>>310  ! 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)311  ! CHECK-DAG: fir.store %[[addr]] to %[[lhs_addr]] : !fir.ref<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_arrayTt{i:i32}>>>>312  ! CHECK-DAG: fir.store %[[ext]]#1 to %[[lhs_ext]] : !fir.ref<index>313  ! CHECK-DAG: fir.store %[[lb]]#0 to %[[lhs_lb]] : !fir.ref<index>314  lhs => rhs315end subroutine316 317! CHECK-LABEL: func @_QPissue857_array_shift(318subroutine issue857_array_shift(rhs)319  ! Test lower bounds is the one from the shift320  type t321    integer :: i322  end type323  type(t), contiguous,  pointer :: rhs(:), lhs(:)324  ! CHECK: %[[lhs_lb:.*]] = fir.alloca index {uniq_name = "_QFissue857_array_shiftElhs.lb0"}325  ! CHECK: %[[c42:.*]] = fir.convert %c42{{.*}} : (i64) -> index326  ! CHECK: fir.store %[[c42]] to %[[lhs_lb]] : !fir.ref<index>327  lhs(42:) => rhs328end subroutine329 330! CHECK-LABEL: func @_QPissue857_array_remap331subroutine issue857_array_remap(rhs)332  ! Test lower bounds is the one from the shift333  type t334    integer :: i335  end type336  type(t), contiguous,  pointer :: rhs(:, :), lhs(:)337  ! CHECK-DAG: %[[lhs_addr:.*]] = fir.alloca !fir.ptr<!fir.array<?x!fir.type<_QFissue857_array_remapTt{i:i32}>>> {uniq_name = "_QFissue857_array_remapElhs.addr"}338  ! CHECK-DAG: %[[lhs_lb:.*]] = fir.alloca index {uniq_name = "_QFissue857_array_remapElhs.lb0"}339  ! CHECK-DAG: %[[lhs_ext:.*]] = fir.alloca index {uniq_name = "_QFissue857_array_remapElhs.ext0"}340 341  ! CHECK: %[[c101:.*]] = fir.convert %c101_i64 : (i64) -> index342  ! CHECK: %[[c200:.*]] = fir.convert %c200_i64 : (i64) -> index343  ! CHECK: %[[sub:.*]] = arith.subi %[[c200]], %[[c101]] : index344  ! CHECK: %[[raw_extent:.*]] = arith.addi %[[sub]], %c1{{.*}} : index345  ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[raw_extent]], %c0{{.*}} : index346  ! CHECK: %[[extent:.*]] = arith.select %[[cmp]], %[[raw_extent]], %c0{{.*}} : index347  ! 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}>>>348  ! 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}>>>349  ! CHECK: fir.store %[[addr_cast]] to %[[lhs_addr]] : !fir.ref<!fir.ptr<!fir.array<?x!fir.type<_QFissue857_array_remapTt{i:i32}>>>>350  ! CHECK: fir.store %[[extent]] to %[[lhs_ext]] : !fir.ref<index>351  ! CHECK: %[[c101_2:.*]] = fir.convert %c101{{.*}} : (i64) -> index352  ! CHECK: fir.store %[[c101_2]] to %[[lhs_lb]] : !fir.ref<index>353  lhs(101:200) => rhs354end subroutine355 356! CHECK-LABEL: func @_QPissue857_char357subroutine issue857_char(rhs)358  ! Only check that the length is taken from the fir.box created for the slice.359  ! CHECK-DAG: %[[lhs1_len:.*]] = fir.alloca index {uniq_name = "_QFissue857_charElhs1.len"}360  ! CHECK-DAG: %[[lhs2_len:.*]] = fir.alloca index {uniq_name = "_QFissue857_charElhs2.len"}361  character(:), contiguous,  pointer ::  lhs1(:), lhs2(:, :)362  character(*), target ::  rhs(100)363  ! CHECK: %[[len:.*]] = fir.box_elesize %{{.*}} : (!fir.box<!fir.array<50x!fir.char<1,?>>>) -> index364  ! CHECK: fir.store %[[len]] to %[[lhs1_len]] : !fir.ref<index>365  lhs1 => rhs(1:50:1)366  ! CHECK: %[[len2:.*]] = fir.box_elesize %{{.*}} : (!fir.box<!fir.array<50x!fir.char<1,?>>>) -> index367  ! CHECK: fir.store %[[len2]] to %[[lhs2_len]] : !fir.ref<index>368  lhs2(1:2, 1:25) => rhs(1:50:1)369end subroutine370 371! CHECK-LABEL: func @_QPissue1180(372! CHECK-SAME:  %[[VAL_0:.*]]: !fir.ref<i32> {{{.*}}, fir.target}) {373subroutine issue1180(x)374  integer, target :: x375  integer, pointer :: p376  common /some_common/ p377  ! CHECK: %[[VAL_1:.*]] = fir.address_of(@some_common_) : !fir.ref<!fir.array<24xi8>>378  ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index379  ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_3]] : (!fir.ref<!fir.array<24xi8>>, index) -> !fir.ref<i8>380  ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<i8>) -> !fir.ref<!fir.box<!fir.ptr<i32>>>381  ! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_0]] : (!fir.ref<i32>) -> !fir.box<!fir.ptr<i32>>382  ! CHECK: fir.store %[[VAL_6]] to %[[VAL_5]] : !fir.ref<!fir.box<!fir.ptr<i32>>>383  p => x384end subroutine385