// Test that the redundant fir.[un]pack_array operations // are optimized away, when the source is statically known // to be contiguous. // RUN: fir-opt --optimize-array-repacking %s | FileCheck %s // FIR is produced by compiling the sources with -mllvm -inline-all. // module inner // contains // subroutine inner_repack1(x) // real :: x(:) // end subroutine inner_repack1 // subroutine inner_repack2(x) // real :: x(:,:) // end subroutine inner_repack2 // end module inner // subroutine test_explicit_shape_cst(x) // real :: x(100) // call repack(x(1:50)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine test_explicit_shape_cst // // CHECK-LABEL: func.func @_QPtest_explicit_shape_cst( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_explicit_shape_cst(%arg0: !fir.ref> {fir.bindc_name = "x"}) { %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %c100 = arith.constant 100 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.shape %c100 : (index) -> !fir.shape<1> %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_cstEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %3 = fir.shape %c50 : (index) -> !fir.shape<1> %4 = fir.array_coor %2(%1) %c1 : (!fir.ref>, !fir.shape<1>, index) -> !fir.ref %5 = fir.convert %4 : (!fir.ref) -> !fir.ref> %6 = fir.embox %5(%3) : (!fir.ref>, !fir.shape<1>) -> !fir.box> %7 = fir.convert %6 : (!fir.box>) -> !fir.box> %8 = fir.dummy_scope : !fir.dscope %9 = fir.pack_array %7 heap whole : (!fir.box>) -> !fir.box> %10 = fir.declare %9 dummy_scope %8 {uniq_name = "_QFtest_explicit_shape_cstFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %9 to %7 heap : !fir.box> return } // subroutine test_explicit_shape_var(x, n, l, u) // integer :: n, l, u // real :: x(n) // call repack(x(l:u)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine test_explicit_shape_var // // CHECK-LABEL: func.func @_QPtest_explicit_shape_var( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_explicit_shape_var(%arg0: !fir.ref> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "n"}, %arg2: !fir.ref {fir.bindc_name = "l"}, %arg3: !fir.ref {fir.bindc_name = "u"}) { %c1 = arith.constant 1 : index %c0 = arith.constant 0 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg2 dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_varEl"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_varEn"} : (!fir.ref, !fir.dscope) -> !fir.ref %3 = fir.declare %arg3 dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_varEu"} : (!fir.ref, !fir.dscope) -> !fir.ref %4 = fir.load %2 : !fir.ref %5 = fir.convert %4 : (i32) -> index %6 = arith.cmpi sgt, %5, %c0 : index %7 = arith.select %6, %5, %c0 : index %8 = fir.shape %7 : (index) -> !fir.shape<1> %9 = fir.declare %arg0(%8) dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_varEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %10 = fir.load %1 : !fir.ref %11 = fir.load %3 : !fir.ref %12 = fir.convert %10 : (i32) -> index %13 = fir.convert %11 : (i32) -> index %14 = fir.slice %12, %13, %c1 : (index, index, index) -> !fir.slice<1> %15 = fir.embox %9(%8) [%14] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> %16 = fir.dummy_scope : !fir.dscope %17 = fir.pack_array %15 heap whole : (!fir.box>) -> !fir.box> %18 = fir.declare %17 dummy_scope %16 {uniq_name = "_QFtest_explicit_shape_varFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %17 to %15 heap : !fir.box> return } // subroutine test_assumed_size_cst(x) // real :: x(*) // call repack(x(1:50)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine test_assumed_size_cst // // CHECK-LABEL: func.func @_QPtest_assumed_size_cst( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_assumed_size_cst(%arg0: !fir.ref> {fir.bindc_name = "x"}) { %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %c-1 = arith.constant -1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.shape %c-1 : (index) -> !fir.shape<1> %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest_assumed_size_cstEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %3 = fir.shape %c50 : (index) -> !fir.shape<1> %4 = fir.array_coor %2(%1) %c1 : (!fir.ref>, !fir.shape<1>, index) -> !fir.ref %5 = fir.convert %4 : (!fir.ref) -> !fir.ref> %6 = fir.embox %5(%3) : (!fir.ref>, !fir.shape<1>) -> !fir.box> %7 = fir.convert %6 : (!fir.box>) -> !fir.box> %8 = fir.dummy_scope : !fir.dscope %9 = fir.pack_array %7 heap whole : (!fir.box>) -> !fir.box> %10 = fir.declare %9 dummy_scope %8 {uniq_name = "_QFtest_assumed_size_cstFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %9 to %7 heap : !fir.box> return } // subroutine test_assumed_size_var(x, l, u) // integer :: l, u // real :: x(*) // call repack(x(l:u)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine test_assumed_size_var // // CHECK-LABEL: func.func @_QPtest_assumed_size_var( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_assumed_size_var(%arg0: !fir.ref> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "l"}, %arg2: !fir.ref {fir.bindc_name = "u"}) { %c1 = arith.constant 1 : index %c-1 = arith.constant -1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFtest_assumed_size_varEl"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.declare %arg2 dummy_scope %0 {uniq_name = "_QFtest_assumed_size_varEu"} : (!fir.ref, !fir.dscope) -> !fir.ref %3 = fir.shape %c-1 : (index) -> !fir.shape<1> %4 = fir.declare %arg0(%3) dummy_scope %0 {uniq_name = "_QFtest_assumed_size_varEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %5 = fir.load %1 : !fir.ref %6 = fir.load %2 : !fir.ref %7 = fir.convert %5 : (i32) -> index %8 = fir.convert %6 : (i32) -> index %9 = fir.slice %7, %8, %c1 : (index, index, index) -> !fir.slice<1> %10 = fir.embox %4(%3) [%9] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> %11 = fir.dummy_scope : !fir.dscope %12 = fir.pack_array %10 heap whole : (!fir.box>) -> !fir.box> %13 = fir.declare %12 dummy_scope %11 {uniq_name = "_QFtest_assumed_size_varFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %12 to %10 heap : !fir.box> return } // subroutine test_allocatable_cst(x) // real, allocatable :: x(:) // call repack(x(10:50)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine test_allocatable_cst // // CHECK-LABEL: func.func @_QPtest_allocatable_cst( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_allocatable_cst(%arg0: !fir.ref>>> {fir.bindc_name = "x"}) { %c0 = arith.constant 0 : index %c41 = arith.constant 41 : index %c10 = arith.constant 10 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest_allocatable_cstEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %2 = fir.load %1 : !fir.ref>>> %3 = fir.shape %c41 : (index) -> !fir.shape<1> %4 = fir.box_addr %2 : (!fir.box>>) -> !fir.heap> %5:3 = fir.box_dims %2, %c0 : (!fir.box>>, index) -> (index, index, index) %6 = fir.shape_shift %5#0, %5#1 : (index, index) -> !fir.shapeshift<1> %7 = fir.array_coor %4(%6) %c10 : (!fir.heap>, !fir.shapeshift<1>, index) -> !fir.ref %8 = fir.convert %7 : (!fir.ref) -> !fir.ref> %9 = fir.embox %8(%3) : (!fir.ref>, !fir.shape<1>) -> !fir.box> %10 = fir.convert %9 : (!fir.box>) -> !fir.box> %11 = fir.dummy_scope : !fir.dscope %12 = fir.pack_array %10 heap whole : (!fir.box>) -> !fir.box> %13 = fir.declare %12 dummy_scope %11 {uniq_name = "_QFtest_allocatable_cstFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %12 to %10 heap : !fir.box> return } // subroutine test_allocatable_var(x, l, u) // integer :: l, u // real, allocatable :: x(:) // call repack(x(l:u)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine test_allocatable_var // // CHECK-LABEL: func.func @_QPtest_allocatable_var( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_allocatable_var(%arg0: !fir.ref>>> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "l"}, %arg2: !fir.ref {fir.bindc_name = "u"}) { %c0 = arith.constant 0 : index %c1 = arith.constant 1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFtest_allocatable_varEl"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.declare %arg2 dummy_scope %0 {uniq_name = "_QFtest_allocatable_varEu"} : (!fir.ref, !fir.dscope) -> !fir.ref %3 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest_allocatable_varEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %4 = fir.load %3 : !fir.ref>>> %5 = fir.load %1 : !fir.ref %6 = fir.load %2 : !fir.ref %7 = fir.convert %5 : (i32) -> index %8 = fir.convert %6 : (i32) -> index %9 = fir.box_addr %4 : (!fir.box>>) -> !fir.heap> %10:3 = fir.box_dims %4, %c0 : (!fir.box>>, index) -> (index, index, index) %11 = fir.shape_shift %10#0, %10#1 : (index, index) -> !fir.shapeshift<1> %12 = fir.slice %7, %8, %c1 : (index, index, index) -> !fir.slice<1> %13 = fir.embox %9(%11) [%12] : (!fir.heap>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box> %14 = fir.dummy_scope : !fir.dscope %15 = fir.pack_array %13 heap whole : (!fir.box>) -> !fir.box> %16 = fir.declare %15 dummy_scope %14 {uniq_name = "_QFtest_allocatable_varFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %15 to %13 heap : !fir.box> return } // subroutine test_allocatable_full(x) // real, allocatable :: x(:,:) // call repack(x(:,:)) // contains // subroutine repack(x) // real :: x(:,:) // end subroutine repack // end subroutine test_allocatable_full // // CHECK-LABEL: func.func @_QPtest_allocatable_full( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_allocatable_full(%arg0: !fir.ref>>> {fir.bindc_name = "x"}) { %c1 = arith.constant 1 : index %c0 = arith.constant 0 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest_allocatable_fullEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %2 = fir.load %1 : !fir.ref>>> %3:3 = fir.box_dims %2, %c0 : (!fir.box>>, index) -> (index, index, index) %4:3 = fir.box_dims %2, %c1 : (!fir.box>>, index) -> (index, index, index) %5 = arith.addi %3#0, %3#1 : index %6 = arith.subi %5, %c1 : index %7 = arith.addi %4#0, %4#1 : index %8 = arith.subi %7, %c1 : index %9 = fir.box_addr %2 : (!fir.box>>) -> !fir.heap> %10 = fir.shape_shift %3#0, %3#1, %4#0, %4#1 : (index, index, index, index) -> !fir.shapeshift<2> %11 = fir.slice %3#0, %6, %c1, %4#0, %8, %c1 : (index, index, index, index, index, index) -> !fir.slice<2> %12 = fir.embox %9(%10) [%11] : (!fir.heap>, !fir.shapeshift<2>, !fir.slice<2>) -> !fir.box> %13 = fir.dummy_scope : !fir.dscope %14 = fir.pack_array %12 heap innermost : (!fir.box>) -> !fir.box> %15 = fir.declare %14 dummy_scope %13 {uniq_name = "_QFtest_allocatable_fullFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %14 to %12 heap : !fir.box> return } // subroutine test_explicit_shape_cst_chain(x) // real :: x(100) // call repack(x(1:50)) // contains // subroutine repack(x) // use inner // real :: x(:) // call inner_repack1(x) // end subroutine repack // end subroutine test_explicit_shape_cst_chain // // CHECK-LABEL: func.func @_QPtest_explicit_shape_cst_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_explicit_shape_cst_chain(%arg0: !fir.ref> {fir.bindc_name = "x"}) { %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %c100 = arith.constant 100 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.shape %c100 : (index) -> !fir.shape<1> %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_cst_chainEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %3 = fir.shape %c50 : (index) -> !fir.shape<1> %4 = fir.array_coor %2(%1) %c1 : (!fir.ref>, !fir.shape<1>, index) -> !fir.ref %5 = fir.convert %4 : (!fir.ref) -> !fir.ref> %6 = fir.embox %5(%3) : (!fir.ref>, !fir.shape<1>) -> !fir.box> %7 = fir.convert %6 : (!fir.box>) -> !fir.box> %8 = fir.dummy_scope : !fir.dscope %9 = fir.pack_array %7 heap whole : (!fir.box>) -> !fir.box> %10 = fir.declare %9 dummy_scope %8 {uniq_name = "_QFtest_explicit_shape_cst_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %11 = fir.rebox %10 : (!fir.box>) -> !fir.box> %12 = fir.dummy_scope : !fir.dscope %13 = fir.pack_array %11 heap whole : (!fir.box>) -> !fir.box> %14 = fir.declare %13 dummy_scope %12 {uniq_name = "_QMinnerFinner_repack1Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %13 to %11 heap : !fir.box> fir.unpack_array %9 to %7 heap : !fir.box> return } // subroutine test_explicit_shape_var_chain(x, n, l, u) // integer :: n, l, u // real :: x(n) // call repack(x(l:u)) // contains // subroutine repack(x) // use inner // real :: x(:) // call inner_repack1(x) // end subroutine repack // end subroutine test_explicit_shape_var_chain // // CHECK-LABEL: func.func @_QPtest_explicit_shape_var_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_explicit_shape_var_chain(%arg0: !fir.ref> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "n"}, %arg2: !fir.ref {fir.bindc_name = "l"}, %arg3: !fir.ref {fir.bindc_name = "u"}) { %c1 = arith.constant 1 : index %c0 = arith.constant 0 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg2 dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_var_chainEl"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_var_chainEn"} : (!fir.ref, !fir.dscope) -> !fir.ref %3 = fir.declare %arg3 dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_var_chainEu"} : (!fir.ref, !fir.dscope) -> !fir.ref %4 = fir.load %2 : !fir.ref %5 = fir.convert %4 : (i32) -> index %6 = arith.cmpi sgt, %5, %c0 : index %7 = arith.select %6, %5, %c0 : index %8 = fir.shape %7 : (index) -> !fir.shape<1> %9 = fir.declare %arg0(%8) dummy_scope %0 {uniq_name = "_QFtest_explicit_shape_var_chainEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %10 = fir.load %1 : !fir.ref %11 = fir.load %3 : !fir.ref %12 = fir.convert %10 : (i32) -> index %13 = fir.convert %11 : (i32) -> index %14 = fir.slice %12, %13, %c1 : (index, index, index) -> !fir.slice<1> %15 = fir.embox %9(%8) [%14] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> %16 = fir.dummy_scope : !fir.dscope %17 = fir.pack_array %15 heap whole : (!fir.box>) -> !fir.box> %18 = fir.declare %17 dummy_scope %16 {uniq_name = "_QFtest_explicit_shape_var_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %19 = fir.rebox %18 : (!fir.box>) -> !fir.box> %20 = fir.dummy_scope : !fir.dscope %21 = fir.pack_array %19 heap whole : (!fir.box>) -> !fir.box> %22 = fir.declare %21 dummy_scope %20 {uniq_name = "_QMinnerFinner_repack1Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %21 to %19 heap : !fir.box> fir.unpack_array %17 to %15 heap : !fir.box> return } // subroutine test_assumed_size_cst_chain(x) // real :: x(*) // call repack(x(1:50)) // contains // subroutine repack(x) // use inner // real :: x(:) // call inner_repack1(x) // end subroutine repack // end subroutine test_assumed_size_cst_chain // // CHECK-LABEL: func.func @_QPtest_assumed_size_cst_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_assumed_size_cst_chain(%arg0: !fir.ref> {fir.bindc_name = "x"}) { %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %c-1 = arith.constant -1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.shape %c-1 : (index) -> !fir.shape<1> %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFtest_assumed_size_cst_chainEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %3 = fir.shape %c50 : (index) -> !fir.shape<1> %4 = fir.array_coor %2(%1) %c1 : (!fir.ref>, !fir.shape<1>, index) -> !fir.ref %5 = fir.convert %4 : (!fir.ref) -> !fir.ref> %6 = fir.embox %5(%3) : (!fir.ref>, !fir.shape<1>) -> !fir.box> %7 = fir.convert %6 : (!fir.box>) -> !fir.box> %8 = fir.dummy_scope : !fir.dscope %9 = fir.pack_array %7 heap whole : (!fir.box>) -> !fir.box> %10 = fir.declare %9 dummy_scope %8 {uniq_name = "_QFtest_assumed_size_cst_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %11 = fir.rebox %10 : (!fir.box>) -> !fir.box> %12 = fir.dummy_scope : !fir.dscope %13 = fir.pack_array %11 heap whole : (!fir.box>) -> !fir.box> %14 = fir.declare %13 dummy_scope %12 {uniq_name = "_QMinnerFinner_repack1Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %13 to %11 heap : !fir.box> fir.unpack_array %9 to %7 heap : !fir.box> return } // subroutine test_assumed_size_var_chain(x, l, u) // integer :: l, u // real :: x(*) // call repack(x(l:u)) // contains // subroutine repack(x) // use inner // real :: x(:) // call inner_repack1(x) // end subroutine repack // end subroutine test_assumed_size_var_chain // // CHECK-LABEL: func.func @_QPtest_assumed_size_var_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_assumed_size_var_chain(%arg0: !fir.ref> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "l"}, %arg2: !fir.ref {fir.bindc_name = "u"}) { %c1 = arith.constant 1 : index %c-1 = arith.constant -1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFtest_assumed_size_var_chainEl"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.declare %arg2 dummy_scope %0 {uniq_name = "_QFtest_assumed_size_var_chainEu"} : (!fir.ref, !fir.dscope) -> !fir.ref %3 = fir.shape %c-1 : (index) -> !fir.shape<1> %4 = fir.declare %arg0(%3) dummy_scope %0 {uniq_name = "_QFtest_assumed_size_var_chainEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %5 = fir.load %1 : !fir.ref %6 = fir.load %2 : !fir.ref %7 = fir.convert %5 : (i32) -> index %8 = fir.convert %6 : (i32) -> index %9 = fir.slice %7, %8, %c1 : (index, index, index) -> !fir.slice<1> %10 = fir.embox %4(%3) [%9] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> %11 = fir.dummy_scope : !fir.dscope %12 = fir.pack_array %10 heap whole : (!fir.box>) -> !fir.box> %13 = fir.declare %12 dummy_scope %11 {uniq_name = "_QFtest_assumed_size_var_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %14 = fir.rebox %13 : (!fir.box>) -> !fir.box> %15 = fir.dummy_scope : !fir.dscope %16 = fir.pack_array %14 heap whole : (!fir.box>) -> !fir.box> %17 = fir.declare %16 dummy_scope %15 {uniq_name = "_QMinnerFinner_repack1Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %16 to %14 heap : !fir.box> fir.unpack_array %12 to %10 heap : !fir.box> return } // subroutine test_allocatable_cst_chain(x) // real, allocatable :: x(:) // call repack(x(10:50)) // contains // subroutine repack(x) // use inner // real :: x(:) // call inner_repack1(x) // end subroutine repack // end subroutine test_allocatable_cst_chain // // CHECK-LABEL: func.func @_QPtest_allocatable_cst_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_allocatable_cst_chain(%arg0: !fir.ref>>> {fir.bindc_name = "x"}) { %c0 = arith.constant 0 : index %c41 = arith.constant 41 : index %c10 = arith.constant 10 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest_allocatable_cst_chainEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %2 = fir.load %1 : !fir.ref>>> %3 = fir.shape %c41 : (index) -> !fir.shape<1> %4 = fir.box_addr %2 : (!fir.box>>) -> !fir.heap> %5:3 = fir.box_dims %2, %c0 : (!fir.box>>, index) -> (index, index, index) %6 = fir.shape_shift %5#0, %5#1 : (index, index) -> !fir.shapeshift<1> %7 = fir.array_coor %4(%6) %c10 : (!fir.heap>, !fir.shapeshift<1>, index) -> !fir.ref %8 = fir.convert %7 : (!fir.ref) -> !fir.ref> %9 = fir.embox %8(%3) : (!fir.ref>, !fir.shape<1>) -> !fir.box> %10 = fir.convert %9 : (!fir.box>) -> !fir.box> %11 = fir.dummy_scope : !fir.dscope %12 = fir.pack_array %10 heap whole : (!fir.box>) -> !fir.box> %13 = fir.declare %12 dummy_scope %11 {uniq_name = "_QFtest_allocatable_cst_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %14 = fir.rebox %13 : (!fir.box>) -> !fir.box> %15 = fir.dummy_scope : !fir.dscope %16 = fir.pack_array %14 heap whole : (!fir.box>) -> !fir.box> %17 = fir.declare %16 dummy_scope %15 {uniq_name = "_QMinnerFinner_repack1Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %16 to %14 heap : !fir.box> fir.unpack_array %12 to %10 heap : !fir.box> return } // subroutine test_allocatable_var_chain(x, l, u) // integer :: l, u // real, allocatable :: x(:) // call repack(x(l:u)) // contains // subroutine repack(x) // use inner // real :: x(:) // call inner_repack1(x) // end subroutine repack // end subroutine test_allocatable_var_chain // // CHECK-LABEL: func.func @_QPtest_allocatable_var_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_allocatable_var_chain(%arg0: !fir.ref>>> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "l"}, %arg2: !fir.ref {fir.bindc_name = "u"}) { %c0 = arith.constant 0 : index %c1 = arith.constant 1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFtest_allocatable_var_chainEl"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.declare %arg2 dummy_scope %0 {uniq_name = "_QFtest_allocatable_var_chainEu"} : (!fir.ref, !fir.dscope) -> !fir.ref %3 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest_allocatable_var_chainEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %4 = fir.load %3 : !fir.ref>>> %5 = fir.load %1 : !fir.ref %6 = fir.load %2 : !fir.ref %7 = fir.convert %5 : (i32) -> index %8 = fir.convert %6 : (i32) -> index %9 = fir.box_addr %4 : (!fir.box>>) -> !fir.heap> %10:3 = fir.box_dims %4, %c0 : (!fir.box>>, index) -> (index, index, index) %11 = fir.shape_shift %10#0, %10#1 : (index, index) -> !fir.shapeshift<1> %12 = fir.slice %7, %8, %c1 : (index, index, index) -> !fir.slice<1> %13 = fir.embox %9(%11) [%12] : (!fir.heap>, !fir.shapeshift<1>, !fir.slice<1>) -> !fir.box> %14 = fir.dummy_scope : !fir.dscope %15 = fir.pack_array %13 heap whole : (!fir.box>) -> !fir.box> %16 = fir.declare %15 dummy_scope %14 {uniq_name = "_QFtest_allocatable_var_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %17 = fir.rebox %16 : (!fir.box>) -> !fir.box> %18 = fir.dummy_scope : !fir.dscope %19 = fir.pack_array %17 heap whole : (!fir.box>) -> !fir.box> %20 = fir.declare %19 dummy_scope %18 {uniq_name = "_QMinnerFinner_repack1Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %19 to %17 heap : !fir.box> fir.unpack_array %15 to %13 heap : !fir.box> return } // subroutine test_allocatable_full_chain(x) // real, allocatable :: x(:,:) // call repack(x(:,:)) // contains // subroutine repack(x) // use inner // real :: x(:,:) // call inner_repack2(x) // end subroutine repack // end subroutine test_allocatable_full_chain // // CHECK-LABEL: func.func @_QPtest_allocatable_full_chain( // CHECK-NOT: fir.{{.*}}pack_array func.func @_QPtest_allocatable_full_chain(%arg0: !fir.ref>>> {fir.bindc_name = "x"}) { %c1 = arith.constant 1 : index %c0 = arith.constant 0 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest_allocatable_full_chainEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %2 = fir.load %1 : !fir.ref>>> %3:3 = fir.box_dims %2, %c0 : (!fir.box>>, index) -> (index, index, index) %4:3 = fir.box_dims %2, %c1 : (!fir.box>>, index) -> (index, index, index) %5 = arith.addi %3#0, %3#1 : index %6 = arith.subi %5, %c1 : index %7 = arith.addi %4#0, %4#1 : index %8 = arith.subi %7, %c1 : index %9 = fir.box_addr %2 : (!fir.box>>) -> !fir.heap> %10 = fir.shape_shift %3#0, %3#1, %4#0, %4#1 : (index, index, index, index) -> !fir.shapeshift<2> %11 = fir.slice %3#0, %6, %c1, %4#0, %8, %c1 : (index, index, index, index, index, index) -> !fir.slice<2> %12 = fir.embox %9(%10) [%11] : (!fir.heap>, !fir.shapeshift<2>, !fir.slice<2>) -> !fir.box> %13 = fir.dummy_scope : !fir.dscope %14 = fir.pack_array %12 heap innermost : (!fir.box>) -> !fir.box> %15 = fir.declare %14 dummy_scope %13 {uniq_name = "_QFtest_allocatable_full_chainFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %16 = fir.rebox %15 : (!fir.box>) -> !fir.box> %17 = fir.dummy_scope : !fir.dscope %18 = fir.pack_array %16 heap innermost : (!fir.box>) -> !fir.box> %19 = fir.declare %18 dummy_scope %17 {uniq_name = "_QMinnerFinner_repack2Ex"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %18 to %16 heap : !fir.box> fir.unpack_array %14 to %12 heap : !fir.box> return } // TODO: if both fir.pack_array have the same property, // then the second one is redundant, because the first // repack makes 'x' contiguous. // subroutine neg_test_assumed_shape(x) // real :: x(:) // call repack(x(1:50)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine neg_test_assumed_shape // // CHECK-LABEL: func.func @_QPneg_test_assumed_shape( // CHECK: fir.pack_array // CHECK: fir.pack_array // CHECK: fir.unpack_array // CHECK: fir.unpack_array func.func @_QPneg_test_assumed_shape(%arg0: !fir.box> {fir.bindc_name = "x"}) { %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.pack_array %arg0 heap whole : (!fir.box>) -> !fir.box> %2 = fir.declare %1 dummy_scope %0 {uniq_name = "_QFneg_test_assumed_shapeEx"} : (!fir.box>, !fir.dscope) -> !fir.box> %3 = fir.rebox %2 : (!fir.box>) -> !fir.box> %4 = fir.slice %c1, %c50, %c1 : (index, index, index) -> !fir.slice<1> %5 = fir.rebox %3 [%4] : (!fir.box>, !fir.slice<1>) -> !fir.box> %6 = fir.convert %5 : (!fir.box>) -> !fir.box> %7 = fir.dummy_scope : !fir.dscope %8 = fir.pack_array %6 heap whole : (!fir.box>) -> !fir.box> %9 = fir.declare %8 dummy_scope %7 {uniq_name = "_QFneg_test_assumed_shapeFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %8 to %6 heap : !fir.box> fir.unpack_array %1 to %arg0 heap : !fir.box> return } // subroutine neg_test_non_contig_slice_cst(x) // real :: x(100) // call repack(x(1:50:2)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine neg_test_non_contig_slice_cst // // CHECK-LABEL: func.func @_QPneg_test_non_contig_slice_cst( // CHECK: fir.pack_array // CHECK: fir.unpack_array func.func @_QPneg_test_non_contig_slice_cst(%arg0: !fir.ref> {fir.bindc_name = "x"}) { %c2 = arith.constant 2 : index %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %c100 = arith.constant 100 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.shape %c100 : (index) -> !fir.shape<1> %2 = fir.declare %arg0(%1) dummy_scope %0 {uniq_name = "_QFneg_test_non_contig_slice_cstEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %3 = fir.slice %c1, %c50, %c2 : (index, index, index) -> !fir.slice<1> %4 = fir.embox %2(%1) [%3] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> %5 = fir.convert %4 : (!fir.box>) -> !fir.box> %6 = fir.dummy_scope : !fir.dscope %7 = fir.pack_array %5 heap whole : (!fir.box>) -> !fir.box> %8 = fir.declare %7 dummy_scope %6 {uniq_name = "_QFneg_test_non_contig_slice_cstFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %7 to %5 heap : !fir.box> return } // subroutine neg_test_non_contig_slice_var(x, s) // integer :: s // real :: x(100) // call repack(x(1:50:s)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine neg_test_non_contig_slice_var // // CHECK-LABEL: func.func @_QPneg_test_non_contig_slice_var( // CHECK: fir.pack_array // CHECK: fir.unpack_array func.func @_QPneg_test_non_contig_slice_var(%arg0: !fir.ref> {fir.bindc_name = "x"}, %arg1: !fir.ref {fir.bindc_name = "s"}) { %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %c100 = arith.constant 100 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg1 dummy_scope %0 {uniq_name = "_QFneg_test_non_contig_slice_varEs"} : (!fir.ref, !fir.dscope) -> !fir.ref %2 = fir.shape %c100 : (index) -> !fir.shape<1> %3 = fir.declare %arg0(%2) dummy_scope %0 {uniq_name = "_QFneg_test_non_contig_slice_varEx"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> !fir.ref> %4 = fir.load %1 : !fir.ref %5 = fir.convert %4 : (i32) -> index %6 = fir.slice %c1, %c50, %5 : (index, index, index) -> !fir.slice<1> %7 = fir.embox %3(%2) [%6] : (!fir.ref>, !fir.shape<1>, !fir.slice<1>) -> !fir.box> %8 = fir.dummy_scope : !fir.dscope %9 = fir.pack_array %7 heap whole : (!fir.box>) -> !fir.box> %10 = fir.declare %9 dummy_scope %8 {uniq_name = "_QFneg_test_non_contig_slice_varFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %9 to %7 heap : !fir.box> return } // subroutine neg_test_pointer(x) // real, pointer :: x(:) // call repack(x(1:50)) // contains // subroutine repack(x) // real :: x(:) // end subroutine repack // end subroutine neg_test_pointer // // CHECK-LABEL: func.func @_QPneg_test_pointer( // CHECK: fir.pack_array // CHECK: fir.unpack_array func.func @_QPneg_test_pointer(%arg0: !fir.ref>>> {fir.bindc_name = "x"}) { %c0 = arith.constant 0 : index %c50 = arith.constant 50 : index %c1 = arith.constant 1 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.declare %arg0 dummy_scope %0 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFneg_test_pointerEx"} : (!fir.ref>>>, !fir.dscope) -> !fir.ref>>> %2 = fir.load %1 : !fir.ref>>> %3:3 = fir.box_dims %2, %c0 : (!fir.box>>, index) -> (index, index, index) %4 = fir.shift %3#0 : (index) -> !fir.shift<1> %5 = fir.slice %c1, %c50, %c1 : (index, index, index) -> !fir.slice<1> %6 = fir.rebox %2(%4) [%5] : (!fir.box>>, !fir.shift<1>, !fir.slice<1>) -> !fir.box> %7 = fir.convert %6 : (!fir.box>) -> !fir.box> %8 = fir.dummy_scope : !fir.dscope %9 = fir.pack_array %7 heap whole : (!fir.box>) -> !fir.box> %10 = fir.declare %9 dummy_scope %8 {uniq_name = "_QFneg_test_pointerFrepackEx"} : (!fir.box>, !fir.dscope) -> !fir.box> fir.unpack_array %9 to %7 heap : !fir.box> return } // Test a long chain of fir.pack_array operations. // The rewriter used to use a down-top traversal that optimized // fir.pack_array operations starting from the innermost one. // The rewriter did not converge in 10 (default) iterations // causing the pass to report a failure. // A top-down traversal should fix this an allow optimizing // all the repackings. // CHECK-LABEL: func.func @test_long_chain( // CHECK-NOT: fir.pack_array // CHECK-NOT: fir.unpack_array func.func @test_long_chain(%pred: i1) { %c10 = arith.constant 10 : index %3 = fir.dummy_scope : !fir.dscope %4 = fir.address_of(@aaa) : !fir.ref> %5 = fir.shape %c10, %c10 : (index, index) -> !fir.shape<2> %6 = fir.declare %4(%5) {uniq_name = "aaa"} : (!fir.ref>, !fir.shape<2>) -> !fir.ref> %9 = fir.embox %6(%5) : (!fir.ref>, !fir.shape<2>) -> !fir.box> %10 = fir.convert %9 : (!fir.box>) -> !fir.box> %11 = fir.dummy_scope : !fir.dscope %12 = fir.pack_array %10 heap innermost : (!fir.box>) -> !fir.box> %13 = fir.declare %12 dummy_scope %11 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %14 = fir.rebox %13 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb17, ^bb1 ^bb1: // pred: ^bb0 %20 = fir.dummy_scope : !fir.dscope %21 = fir.pack_array %14 heap innermost : (!fir.box>) -> !fir.box> %22 = fir.declare %21 dummy_scope %20 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %23 = fir.rebox %22 : (!fir.box>) -> !fir.box> %28 = fir.dummy_scope : !fir.dscope %29 = fir.pack_array %23 heap innermost : (!fir.box>) -> !fir.box> %30 = fir.declare %29 dummy_scope %28 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %31 = fir.rebox %30 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb16, ^bb2 ^bb2: // pred: ^bb1 %37 = fir.dummy_scope : !fir.dscope %38 = fir.pack_array %31 heap innermost : (!fir.box>) -> !fir.box> %39 = fir.declare %38 dummy_scope %37 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %40 = fir.rebox %39 : (!fir.box>) -> !fir.box> %45 = fir.dummy_scope : !fir.dscope %46 = fir.pack_array %40 heap innermost : (!fir.box>) -> !fir.box> %47 = fir.declare %46 dummy_scope %45 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %48 = fir.rebox %47 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb15, ^bb3 ^bb3: // pred: ^bb2 %54 = fir.dummy_scope : !fir.dscope %55 = fir.pack_array %48 heap innermost : (!fir.box>) -> !fir.box> %56 = fir.declare %55 dummy_scope %54 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %57 = fir.rebox %56 : (!fir.box>) -> !fir.box> %62 = fir.dummy_scope : !fir.dscope %63 = fir.pack_array %57 heap innermost : (!fir.box>) -> !fir.box> %64 = fir.declare %63 dummy_scope %62 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %65 = fir.rebox %64 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb14, ^bb4 ^bb4: // pred: ^bb3 %71 = fir.dummy_scope : !fir.dscope %72 = fir.pack_array %65 heap innermost : (!fir.box>) -> !fir.box> %73 = fir.declare %72 dummy_scope %71 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %74 = fir.rebox %73 : (!fir.box>) -> !fir.box> %79 = fir.dummy_scope : !fir.dscope %80 = fir.pack_array %74 heap innermost : (!fir.box>) -> !fir.box> %81 = fir.declare %80 dummy_scope %79 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %82 = fir.rebox %81 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb13, ^bb5 ^bb5: // pred: ^bb4 %88 = fir.dummy_scope : !fir.dscope %89 = fir.pack_array %82 heap innermost : (!fir.box>) -> !fir.box> %90 = fir.declare %89 dummy_scope %88 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %91 = fir.rebox %90 : (!fir.box>) -> !fir.box> %96 = fir.dummy_scope : !fir.dscope %97 = fir.pack_array %91 heap innermost : (!fir.box>) -> !fir.box> %98 = fir.declare %97 dummy_scope %96 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %99 = fir.rebox %98 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb12, ^bb6 ^bb6: // pred: ^bb5 %105 = fir.dummy_scope : !fir.dscope %106 = fir.pack_array %99 heap innermost : (!fir.box>) -> !fir.box> %107 = fir.declare %106 dummy_scope %105 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %108 = fir.rebox %107 : (!fir.box>) -> !fir.box> %113 = fir.dummy_scope : !fir.dscope %114 = fir.pack_array %108 heap innermost : (!fir.box>) -> !fir.box> %115 = fir.declare %114 dummy_scope %113 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %116 = fir.rebox %115 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb11, ^bb7 ^bb7: // pred: ^bb6 %122 = fir.dummy_scope : !fir.dscope %123 = fir.pack_array %116 heap innermost : (!fir.box>) -> !fir.box> %124 = fir.declare %123 dummy_scope %122 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %125 = fir.rebox %124 : (!fir.box>) -> !fir.box> %130 = fir.dummy_scope : !fir.dscope %131 = fir.pack_array %125 heap innermost : (!fir.box>) -> !fir.box> %132 = fir.declare %131 dummy_scope %130 {uniq_name = "aaa"} : (!fir.box>, !fir.dscope) -> !fir.box> %133 = fir.rebox %132 : (!fir.box>) -> !fir.box> cf.cond_br %pred, ^bb9, ^bb8 ^bb8: // pred: ^bb7 %139 = fir.dummy_scope : !fir.dscope %140 = fir.pack_array %133 heap innermost : (!fir.box>) -> !fir.box> fir.unpack_array %140 to %133 heap : !fir.box> cf.br ^bb9 ^bb9: // 2 preds: ^bb7, ^bb8 fir.unpack_array %131 to %125 heap : !fir.box> cf.br ^bb10 ^bb10: // pred: ^bb9 fir.unpack_array %123 to %116 heap : !fir.box> cf.br ^bb11 ^bb11: // 2 preds: ^bb6, ^bb10 fir.unpack_array %114 to %108 heap : !fir.box> fir.unpack_array %106 to %99 heap : !fir.box> cf.br ^bb12 ^bb12: // 2 preds: ^bb5, ^bb11 fir.unpack_array %97 to %91 heap : !fir.box> fir.unpack_array %89 to %82 heap : !fir.box> cf.br ^bb13 ^bb13: // 2 preds: ^bb4, ^bb12 fir.unpack_array %80 to %74 heap : !fir.box> fir.unpack_array %72 to %65 heap : !fir.box> cf.br ^bb14 ^bb14: // 2 preds: ^bb3, ^bb13 fir.unpack_array %63 to %57 heap : !fir.box> fir.unpack_array %55 to %48 heap : !fir.box> cf.br ^bb15 ^bb15: // 2 preds: ^bb2, ^bb14 fir.unpack_array %46 to %40 heap : !fir.box> fir.unpack_array %38 to %31 heap : !fir.box> cf.br ^bb16 ^bb16: // 2 preds: ^bb1, ^bb15 fir.unpack_array %29 to %23 heap : !fir.box> fir.unpack_array %21 to %14 heap : !fir.box> cf.br ^bb17 ^bb17: // 2 preds: ^bb0, ^bb16 fir.unpack_array %12 to %10 heap : !fir.box> return }