diff --git a/flang/test/Lower/Intrinsics/exit-2.f90 b/flang/test/Lower/Intrinsics/exit-2.f90 index 458d2a83cf76b..24a834649974e 100644 --- a/flang/test/Lower/Intrinsics/exit-2.f90 +++ b/flang/test/Lower/Intrinsics/exit-2.f90 @@ -1,20 +1,21 @@ ! Test EXIT with dynamically optional arguments. -! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s +! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s ! CHECK-LABEL: func @_QPexit_opt_dummy( ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref {fir.bindc_name = "status", fir.optional}) { subroutine exit_opt_dummy(status) integer, optional :: status call exit(status) -! CHECK: %[[VAL_1:.*]] = fir.is_present %[[VAL_0]] : (!fir.ref) -> i1 +! CHECK: %[[VAL_D:.*]]:2 = hlfir.declare %[[VAL_0]] +! CHECK: %[[VAL_1:.*]] = fir.is_present %[[VAL_D]]#0 : (!fir.ref) -> i1 ! CHECK: %[[VAL_2:.*]] = fir.if %[[VAL_1]] -> (i32) { -! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref +! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_D]]#0 : !fir.ref ! CHECK: fir.result %[[VAL_3]] : i32 ! CHECK: } else { ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i32 ! CHECK: fir.result %[[VAL_4]] : i32 ! CHECK: } -! CHECK: fir.call @_FortranAExit(%[[VAL_6:.*]]) {{.*}}: (i32) -> () +! CHECK: fir.call @_FortranAExit(%[[VAL_2]]) {{.*}}: (i32) -> () end subroutine ! CHECK-LABEL: func @_QPexit_pointer( @@ -22,13 +23,14 @@ subroutine exit_opt_dummy(status) subroutine exit_pointer(status) integer, pointer :: status call exit(status) -! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref>> +! CHECK: %[[VAL_D:.*]]:2 = hlfir.declare %[[VAL_0]] +! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_D]]#0 : !fir.ref>> ! CHECK: %[[VAL_2:.*]] = fir.box_addr %[[VAL_1]] : (!fir.box>) -> !fir.ptr ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ptr) -> i64 ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i64 ! CHECK: %[[VAL_5:.*]] = arith.cmpi ne, %[[VAL_3]], %[[VAL_4]] : i64 ! CHECK: %[[VAL_6:.*]] = fir.if %[[VAL_5]] -> (i32) { -! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_0]] : !fir.ref>> +! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_D]]#0 : !fir.ref>> ! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box>) -> !fir.ptr ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_8]] : !fir.ptr ! CHECK: fir.result %[[VAL_9]] : i32 @@ -36,5 +38,5 @@ subroutine exit_pointer(status) ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : i32 ! CHECK: fir.result %[[VAL_10]] : i32 ! CHECK: } -! CHECK: fir.call @_FortranAExit(%[[VAL_12:.*]]) {{.*}}: (i32) -> () +! CHECK: fir.call @_FortranAExit(%[[VAL_6]]) {{.*}}: (i32) -> () end subroutine diff --git a/flang/test/Lower/Intrinsics/exit.f90 b/flang/test/Lower/Intrinsics/exit.f90 index b28673db0d31c..0a8862d09889a 100644 --- a/flang/test/Lower/Intrinsics/exit.f90 +++ b/flang/test/Lower/Intrinsics/exit.f90 @@ -1,6 +1,5 @@ -! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck --check-prefixes=CHECK,CHECK-32 -DDEFAULT_INTEGER_SIZE=32 %s -! bbc doesn't have a way to set the default kinds so we use flang driver -! RUN: %flang_fc1 -fdefault-integer-8 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-64 -DDEFAULT_INTEGER_SIZE=64 %s +! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-32 -DDEFAULT_INTEGER_SIZE=32 %s +! RUN: %flang_fc1 -fdefault-integer-8 -emit-hlfir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-64 -DDEFAULT_INTEGER_SIZE=64 %s ! CHECK-LABEL: func @_QPexit_test1() { subroutine exit_test1 @@ -16,15 +15,19 @@ end subroutine exit_test1 subroutine exit_test2(status) integer :: status call exit(status) - ! CHECK: %[[status:.*]] = fir.load %[[statusArg]] : !fir.ref + ! CHECK: %[[DSTATUS:.*]]:2 = hlfir.declare %[[statusArg]] + ! CHECK: %[[status:.*]] = fir.load %[[DSTATUS]]#0 : !fir.ref ! CHECK-64: %[[statusConv:.*]] = fir.convert %[[status]] : (i64) -> i32 ! CHECK-32: fir.call @_FortranAExit(%[[status]]) {{.*}}: (i32) -> () ! CHECK-64: fir.call @_FortranAExit(%[[statusConv]]) {{.*}}: (i32) -> () end subroutine exit_test2 -subroutine exit_test3(status) + ! CHECK-LABEL: func @_QPexit_test3( + ! CHECK-SAME: %[[statusArg:.*]]: !fir.ref{{.*}}) { + subroutine exit_test3(status) integer(kind=4) :: status - ! CHECK: %[[status:.*]] = fir.load %[[statusArg]] : !fir.ref + ! CHECK: %[[DSTATUS:.*]]:2 = hlfir.declare %[[statusArg]] + ! CHECK: %[[status:.*]] = fir.load %[[DSTATUS]]#0 : !fir.ref ! CHECK-32: fir.call @_FortranAExit(%[[status]]) {{.*}}: (i32) -> () ! CHECK-64: fir.call @_FortranAExit(%[[status]]) {{.*}}: (i32) -> () call exit(status) diff --git a/flang/test/Lower/Intrinsics/exp.f90 b/flang/test/Lower/Intrinsics/exp.f90 index 9822a4feba662..bf44e46a4f2b6 100644 --- a/flang/test/Lower/Intrinsics/exp.f90 +++ b/flang/test/Lower/Intrinsics/exp.f90 @@ -1,18 +1,17 @@ -! RUN: bbc -emit-fir -hlfir=false -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CHECK,CMPLX,CMPLX-PRECISE" -! RUN: bbc -emit-fir -hlfir=false --math-runtime=precise -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-PRECISE" -! RUN: bbc -emit-fir -hlfir=false --force-mlir-complex -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR" -! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CHECK,CMPLX,CMPLX-PRECISE" -! RUN: %flang_fc1 -fapprox-func -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-APPROX" -! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --math-runtime=precise %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-PRECISE" -! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -mllvm -outline-intrinsics -mllvm --force-mlir-complex %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR" +! RUN: %flang_fc1 -emit-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CHECK,CMPLX,CMPLX-PRECISE" +! RUN: %flang_fc1 -emit-hlfir -mllvm -outline-intrinsics -mllvm --math-runtime=precise %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-PRECISE" +! RUN: %flang_fc1 -emit-hlfir -mllvm -outline-intrinsics -mllvm --force-mlir-complex %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-FAST,CMPLX-MLIR" +! RUN: %flang_fc1 -fapprox-func -emit-hlfir -mllvm -outline-intrinsics %s -o - | FileCheck %s --check-prefixes="CMPLX,CMPLX-APPROX" ! CHECK-LABEL: exp_testr ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref {{.*}}, %[[BREF:.*]]: !fir.ref {{.*}}) subroutine exp_testr(a, b) real :: a, b -! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref +! CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %[[AREF]] +! CHECK-DAG: %[[B_DECL:.*]]:2 = hlfir.declare %[[BREF]] +! CHECK: %[[A:.*]] = fir.load %[[A_DECL]]#0 : !fir.ref ! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.f32.f32(%[[A]]) {{.*}}: (f32) -> f32 -! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref +! CHECK: hlfir.assign %[[RES]] to %[[B_DECL]]#0 : f32, !fir.ref b = exp(a) end subroutine @@ -20,9 +19,11 @@ subroutine exp_testr(a, b) ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref {{.*}}, %[[BREF:.*]]: !fir.ref {{.*}}) subroutine exp_testd(a, b) real(kind=8) :: a, b -! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref +! CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %[[AREF]] +! CHECK-DAG: %[[B_DECL:.*]]:2 = hlfir.declare %[[BREF]] +! CHECK: %[[A:.*]] = fir.load %[[A_DECL]]#0 : !fir.ref ! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.f64.f64(%[[A]]) {{.*}}: (f64) -> f64 -! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref +! CHECK: hlfir.assign %[[RES]] to %[[B_DECL]]#0 : f64, !fir.ref b = exp(a) end subroutine @@ -30,9 +31,11 @@ subroutine exp_testd(a, b) ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref> {{.*}}, %[[BREF:.*]]: !fir.ref> {{.*}}) subroutine exp_testc(a, b) complex :: a, b -! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref> +! CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %[[AREF]] +! CHECK-DAG: %[[B_DECL:.*]]:2 = hlfir.declare %[[BREF]] +! CHECK: %[[A:.*]] = fir.load %[[A_DECL]]#0 : !fir.ref> ! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.z32.z32(%[[A]]) {{.*}}: (complex) -> complex -! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref> +! CHECK: hlfir.assign %[[RES]] to %[[B_DECL]]#0 : complex, !fir.ref> b = exp(a) end subroutine @@ -40,9 +43,11 @@ subroutine exp_testc(a, b) ! CHECK-SAME: (%[[AREF:.*]]: !fir.ref> {{.*}}, %[[BREF:.*]]: !fir.ref> {{.*}}) subroutine exp_testcd(a, b) complex(kind=8) :: a, b -! CHECK: %[[A:.*]] = fir.load %[[AREF:.*]] : !fir.ref> +! CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %[[AREF]] +! CHECK-DAG: %[[B_DECL:.*]]:2 = hlfir.declare %[[BREF]] +! CHECK: %[[A:.*]] = fir.load %[[A_DECL]]#0 : !fir.ref> ! CHECK: %[[RES:.*]] = fir.call @fir.exp.contract.z64.z64(%[[A]]) {{.*}}: (complex) -> complex -! CHECK: fir.store %[[RES]] to %[[BREF]] : !fir.ref> +! CHECK: hlfir.assign %[[RES]] to %[[B_DECL]]#0 : complex, !fir.ref> b = exp(a) end subroutine diff --git a/flang/test/Lower/Intrinsics/extends_type_of.f90 b/flang/test/Lower/Intrinsics/extends_type_of.f90 index d69e35ff934d9..b651ce5b13f2b 100644 --- a/flang/test/Lower/Intrinsics/extends_type_of.f90 +++ b/flang/test/Lower/Intrinsics/extends_type_of.f90 @@ -1,4 +1,4 @@ -! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s +! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s module extends_type_of_mod @@ -28,8 +28,10 @@ subroutine is_extended_type(a, b) ! CHECK-LABEL: func.func @_QMextends_type_of_modPis_extended_type( ! CHECK-SAME: %[[ARG0:.*]]: !fir.class {fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.class {fir.bindc_name = "b"}) { -! CHECK: %[[BOX0:.*]] = fir.convert %[[ARG0]] : (!fir.class) -> !fir.box -! CHECK: %[[BOX1:.*]] = fir.convert %[[ARG1]] : (!fir.class) -> !fir.box +! CHECK-DAG: %[[D0:.*]]:2 = hlfir.declare %[[ARG0]] +! CHECK-DAG: %[[D1:.*]]:2 = hlfir.declare %[[ARG1]] +! CHECK: %[[BOX0:.*]] = fir.convert %[[D0]]#1 : (!fir.class) -> !fir.box +! CHECK: %[[BOX1:.*]] = fir.convert %[[D1]]#1 : (!fir.class) -> !fir.box ! CHECK: %{{.*}} = fir.call @_FortranAExtendsTypeOf(%[[BOX0]], %[[BOX1]]) {{.*}} : (!fir.box, !fir.box) -> i1 end module diff --git a/flang/test/Lower/Intrinsics/findloc.f90 b/flang/test/Lower/Intrinsics/findloc.f90 index a82a5277753ac..f3c556f137521 100644 --- a/flang/test/Lower/Intrinsics/findloc.f90 +++ b/flang/test/Lower/Intrinsics/findloc.f90 @@ -1,5 +1,4 @@ -! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s -! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s +! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s ! CHECK-LABEL: func @_QPfindloc_test_1d( ! CHECK-SAME: %[[arg0:.*]]: !fir.box>{{.*}}, %[[arg1:.*]]: !fir.ref{{.*}}) -> !fir.array<1xi32> @@ -7,21 +6,28 @@ function findloc_test_1d(a, v) integer :: a(:) integer :: v integer, dimension(1) :: findloc_test_1d - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[res_alloca:.*]] = fir.alloca !fir.array<1xi32> + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[res_alloca]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 findloc_test_1d = findloc(a, v) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.ref> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end function findloc_test_1d ! CHECK-LABEL: func @_QPfindloc_test_2d( @@ -30,21 +36,28 @@ function findloc_test_2d(a, v) integer :: a(:,:) integer :: v integer, dimension(2) :: findloc_test_2d - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[res_alloca:.*]] = fir.alloca !fir.array<2xi32> + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[res_alloca]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 findloc_test_2d = findloc(a, v) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.ref> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end function findloc_test_2d ! CHECK-LABEL: func @_QPfindloc_test_byval( @@ -53,23 +66,30 @@ function findloc_test_byval(a, v) integer :: a(:,:) integer, value :: v integer, dimension(2) :: findloc_test_byval - ! CHECK-DAG: %[[a1:.*]] = fir.alloca i32 - ! CHECK-DAG: fir.store %[[arg1]] to %[[a1]] : !fir.ref - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[a1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[v_alloca:.*]] = fir.alloca i32 + ! CHECK-DAG: fir.store %[[arg1]] to %[[v_alloca]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[v_alloca]] + ! CHECK-DAG: %[[res_alloca:.*]] = fir.alloca !fir.array<2xi32> + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[res_alloca]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 findloc_test_byval = findloc(a, v) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.ref> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end function findloc_test_byval ! CHECK-LABEL: func @_QPfindloc_test_back_true( @@ -78,21 +98,28 @@ function findloc_test_back_true(a, v) integer :: a(:,:) integer :: v integer, dimension(2) :: findloc_test_back_true - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[res_alloca:.*]] = fir.alloca !fir.array<2xi32> + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[res_alloca]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[true:.*]] = arith.constant true - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 findloc_test_back_true = findloc(a, v, back=.true.) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %true) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[true]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.ref> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end function findloc_test_back_true ! CHECK-LABEL: func @_QPfindloc_test_back( @@ -102,22 +129,30 @@ function findloc_test_back(a, v, back) integer :: v logical :: back integer, dimension(2) :: findloc_test_back - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box - ! CHECK-DAG: %[[b:.*]] = fir.load %[[arg2]] : !fir.ref> + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[back_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[res_alloca:.*]] = fir.alloca !fir.array<2xi32> + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[res_alloca]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box + ! CHECK-DAG: %[[b:.*]] = fir.load %[[back_decl]]#0 : !fir.ref> ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 - ! CHECK-DAG: %[[back:.*]] = fir.convert %[[b]] : (!fir.logical<4>) -> i1 + ! CHECK-DAG: %[[back_i1:.*]] = fir.convert %[[b]] : (!fir.logical<4>) -> i1 findloc_test_back = findloc(a, v, back=back) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %[[back]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[back_i1]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.ref> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end function findloc_test_back ! CHECK-LABEL: func @_QPfindloc_test_dim( @@ -126,22 +161,28 @@ subroutine findloc_test_dim(a, v, res) integer :: a(:,:) integer :: v integer :: res(:) - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box - ! CHECK-DAG: %[[c1:.*]] = arith.constant 1 : i32 + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[c1_i32:.*]] = arith.constant 1 : i32 + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 res = findloc(a, v, dim=1) - ! CHECK: fir.call @_FortranAFindlocDim(%[[res]], %[[arr]], %[[val]], %[[kind]], %[[c1]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindlocDim(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %[[c1_i32]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.box> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end subroutine findloc_test_dim ! CHECK-LABEL: func @_QPfindloc_test_dim_unknown( @@ -151,22 +192,29 @@ subroutine findloc_test_dim_unknown(a, v, dim, res) integer :: v integer :: dim integer :: res(:) - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box - ! CHECK-DAG: %[[dim:.*]] = fir.load %[[arg2]] : !fir.ref + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[dim_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[arg3]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[dim_val:.*]] = fir.load %[[dim_decl]]#0 : !fir.ref + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 res = findloc(a, v, dim=dim) - ! CHECK: fir.call @_FortranAFindlocDim(%[[res]], %[[arr]], %[[val]], %[[kind]], %[[dim]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindlocDim(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %[[dim_val]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.box> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end subroutine findloc_test_dim_unknown ! CHECK-LABEL: func @_QPfindloc_test_kind( @@ -175,20 +223,26 @@ subroutine findloc_test_kind(a, v, res) integer :: a(:,:) integer :: v integer(8) :: res(:) - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask:.*]] = fir.absent !fir.box ! CHECK-DAG: %[[kind:.*]] = arith.constant 8 : i32 ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask]] : (!fir.box) -> !fir.box res = findloc(a, v, kind=8) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.box> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end subroutine findloc_test_kind ! CHECK-LABEL: func @_QPfindloc_test_non_scalar_mask( @@ -198,20 +252,27 @@ subroutine findloc_test_non_scalar_mask(a, v, mask, res) integer :: v logical :: mask(:,:) integer :: res(:) - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[mask_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %{{.*}} + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[arg2]] : (!fir.box>>) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask_decl]]#1 : (!fir.box>>) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 res = findloc(a, v, mask=mask) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.box> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end subroutine findloc_test_non_scalar_mask ! CHECK-LABEL: func @_QPfindloc_test_scalar_mask( @@ -221,21 +282,28 @@ subroutine findloc_test_scalar_mask(a, v, mask, res) integer :: v logical :: mask integer :: res(:) - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[m:.*]] = fir.embox %[[arg2]] : (!fir.ref>) -> !fir.box> + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[mask_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[arg3]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[mask_box:.*]] = fir.embox %[[mask_decl]]#0 : (!fir.ref>) -> !fir.box> ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index ! CHECK-DAG: %[[false:.*]] = arith.constant false - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask_box]] : (!fir.box>) -> !fir.box ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32 res = findloc(a, v, mask=mask) - ! CHECK: fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindloc(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[false]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.box> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end subroutine findloc_test_scalar_mask ! CHECK-LABEL: func @_QPfindloc_test_all( @@ -247,19 +315,28 @@ subroutine findloc_test_all(a, v, dim, mask, back, res) logical :: mask(:,:) logical :: back integer(8) :: res(:) - ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box>> - ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref) -> !fir.box - ! CHECK-DAG: %[[b:.*]] = fir.load %[[arg4]] : !fir.ref> + ! CHECK-DAG: %[[a_decl:.*]]:2 = hlfir.declare %[[arg0]] + ! CHECK-DAG: %[[back_decl:.*]]:2 = hlfir.declare %[[arg4]] + ! CHECK-DAG: %[[dim_decl:.*]]:2 = hlfir.declare %[[arg2]] + ! CHECK-DAG: %[[mask_decl:.*]]:2 = hlfir.declare %[[arg3]] + ! CHECK-DAG: %[[res_decl:.*]]:2 = hlfir.declare %[[arg5]] + ! CHECK-DAG: %[[v_decl:.*]]:2 = hlfir.declare %[[arg1]] + ! CHECK-DAG: %[[box_alloc:.*]] = fir.alloca !fir.box>> ! CHECK-DAG: %[[kind:.*]] = arith.constant 8 : i32 - ! CHECK-DAG: %[[dim:.*]] = fir.load %[[arg2]] : !fir.ref - ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref>>>) -> !fir.ref> - ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box>) -> !fir.box - ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box) -> !fir.box - ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[arg3]] : (!fir.box>>) -> !fir.box - ! CHECK-DAG: %[[back:.*]] = fir.convert %[[b]] : (!fir.logical<4>) -> i1 + ! CHECK-DAG: %[[dim_val:.*]] = fir.load %[[dim_decl]]#0 : !fir.ref + ! CHECK-DAG: %[[back_val:.*]] = fir.load %[[back_decl]]#0 : !fir.ref> + ! CHECK-DAG: %[[v_box:.*]] = fir.embox %[[v_decl]]#0 : (!fir.ref) -> !fir.box + ! CHECK-DAG: %[[box_none:.*]] = fir.convert %[[box_alloc]] : (!fir.ref>>>) -> !fir.ref> + ! CHECK-DAG: %[[a_none:.*]] = fir.convert %[[a_decl]]#1 : (!fir.box>) -> !fir.box + ! CHECK-DAG: %[[v_none:.*]] = fir.convert %[[v_box]] : (!fir.box) -> !fir.box + ! CHECK-DAG: %[[mask_none:.*]] = fir.convert %[[mask_decl]]#1 : (!fir.box>>) -> !fir.box + ! CHECK-DAG: %[[back_i1:.*]] = fir.convert %[[back_val]] : (!fir.logical<4>) -> i1 res = findloc(a, v, dim=dim, mask=mask, kind=8, back=back) - ! CHECK: fir.call @_FortranAFindlocDim(%[[res]], %[[arr]], %[[val]], %[[kind]], %[[dim]], %{{.*}}, %{{.*}}, %[[mask]], %[[back]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, i32, !fir.ref, i32, !fir.box, i1) -> () - ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref>>> - ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box>>) -> !fir.heap> - ! CHECK: fir.freemem %[[addr]] : !fir.heap> + ! CHECK: fir.call @_FortranAFindlocDim(%[[box_none]], %[[a_none]], %[[v_none]], %[[kind]], %[[dim_val]], %{{.*}}, %{{.*}}, %[[mask_none]], %[[back_i1]]) fastmath : (!fir.ref>, !fir.box, !fir.box, i32, i32, !fir.ref, i32, !fir.box, i1) -> () + ! CHECK: %[[box_load:.*]] = fir.load %[[box_alloc]] : !fir.ref>>> + ! CHECK: %[[box_addr:.*]] = fir.box_addr %[[box_load]] : (!fir.box>>) -> !fir.heap> + ! CHECK: %[[tmp_decl:.*]]:2 = hlfir.declare %[[box_addr]] + ! CHECK: %[[expr:.*]] = hlfir.as_expr %[[tmp_decl]]#0 move %{{.*}} : (!fir.box>, i1) -> !hlfir.expr + ! CHECK: hlfir.assign %[[expr]] to %[[res_decl]]#0 : !hlfir.expr, !fir.box> + ! CHECK: hlfir.destroy %[[expr]] : !hlfir.expr end subroutine findloc_test_all