[flang-commits] [flang] [flang][NFC] update some old tests to HLFIR lowering (PR #127230)
via flang-commits
flang-commits at lists.llvm.org
Fri Feb 14 09:26:01 PST 2025
https://github.com/jeanPerier created https://github.com/llvm/llvm-project/pull/127230
Update some LIT tests that are using the legacy lowering to use HLFIR.
This makes testing more modular and is a step towards getting rid of the legacy lowering (that is only kept because of the tests).
There are many more.
I deleted a couple file that were very specific to the legacy lowering (e.g. array-copy).
>From 9fa6ab17f783deeab2c3c8355808ce1ea3de5492 Mon Sep 17 00:00:00 2001
From: Jean Perier <jperier at nvidia.com>
Date: Thu, 13 Feb 2025 09:45:29 -0800
Subject: [PATCH] [flang][NFC] update some old tests to HLFIR lowering
---
flang/test/Lower/allocatable-assignment.f90 | 1276 +++--------------
flang/test/Lower/array-character.f90 | 241 ++--
flang/test/Lower/array-copy.f90 | 144 --
.../test/Lower/array-derived-assignments.f90 | 104 --
.../array-elemental-calls-char-byval.f90 | 316 ++--
.../test/Lower/array-elemental-calls-char.f90 | 408 +++---
flang/test/Lower/array-expression.f90 | 1265 ----------------
flang/test/Lower/call-by-value-attr.f90 | 131 +-
flang/test/Lower/call-parenthesized-arg.f90 | 193 +--
flang/test/Lower/character-assignment.f90 | 117 +-
flang/test/Lower/character-concatenation.f90 | 42 -
flang/test/Lower/character-substrings.f90 | 503 ++-----
flang/test/Lower/components.f90 | 410 +++---
flang/test/Lower/derived-assignments.f90 | 258 ++--
flang/test/Lower/entry-statement.f90 | 521 ++++---
flang/test/Lower/forall/scalar-substring.f90 | 112 +-
16 files changed, 1525 insertions(+), 4516 deletions(-)
delete mode 100644 flang/test/Lower/array-copy.f90
delete mode 100644 flang/test/Lower/array-derived-assignments.f90
delete mode 100644 flang/test/Lower/array-expression.f90
delete mode 100644 flang/test/Lower/character-concatenation.f90
diff --git a/flang/test/Lower/allocatable-assignment.f90 b/flang/test/Lower/allocatable-assignment.f90
index 7fe7aa4ebae34..71385aa7761b0 100644
--- a/flang/test/Lower/allocatable-assignment.f90
+++ b/flang/test/Lower/allocatable-assignment.f90
@@ -1,5 +1,5 @@
! Test allocatable assignments
-! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
module alloc_assign
type t
@@ -11,557 +11,146 @@ module alloc_assign
! Test simple scalar RHS
! -----------------------------------------------------------------------------
-! CHECK-LABEL: func @_QMalloc_assignPtest_simple_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<f32>>>{{.*}}) {
subroutine test_simple_scalar(x)
real, allocatable :: x
-! CHECK: %[[VAL_1:.*]] = arith.constant 4.200000e+01 : f32
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<f32>>>
-! CHECK: %[[VAL_3:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
-! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.heap<f32>) -> i64
-! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_6:.*]] = arith.cmpi ne, %[[VAL_4]], %[[VAL_5]] : i64
-! CHECK: %[[VAL_7:.*]]:2 = fir.if %[[VAL_6]] -> (i1, !fir.heap<f32>) {
-! CHECK: %[[VAL_8:.*]] = arith.constant false
-! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_8]] -> (!fir.heap<f32>) {
-! CHECK: %[[VAL_10:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_10]] : !fir.heap<f32>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_3]] : !fir.heap<f32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_8]], %[[VAL_11:.*]] : i1, !fir.heap<f32>
-! CHECK: } else {
-! CHECK: %[[VAL_12:.*]] = arith.constant true
-! CHECK: %[[VAL_13:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_12]], %[[VAL_13]] : i1, !fir.heap<f32>
-! CHECK: }
-! CHECK: fir.store %[[VAL_1]] to %[[VAL_14:.*]]#1 : !fir.heap<f32>
-! CHECK: fir.if %[[VAL_14]]#0 {
-! CHECK: fir.if %[[VAL_6]] {
-! CHECK: fir.freemem %[[VAL_3]]
-! CHECK: }
-! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_14]]#1 : (!fir.heap<f32>) -> !fir.box<!fir.heap<f32>>
-! CHECK: fir.store %[[VAL_15]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<f32>>>
-! CHECK: }
x = 42.
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_simple_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<f32>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_simple_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 4.200000e+01 : f32
+! CHECK: hlfir.assign %[[VAL_3]] to %[[VAL_2]]#0 realloc : f32, !fir.ref<!fir.box<!fir.heap<f32>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_simple_local_scalar() {
subroutine test_simple_local_scalar()
real, allocatable :: x
-! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.heap<f32> {uniq_name = "_QMalloc_assignFtest_simple_local_scalarEx.addr"}
-! CHECK: %[[VAL_2:.*]] = fir.zero_bits !fir.heap<f32>
-! CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<!fir.heap<f32>>
-! CHECK: %[[VAL_3:.*]] = arith.constant 4.200000e+01 : f32
-! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.heap<f32>>
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.heap<f32>) -> i64
-! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_5]], %[[VAL_6]] : i64
-! CHECK: %[[VAL_8:.*]]:2 = fir.if %[[VAL_7]] -> (i1, !fir.heap<f32>) {
-! CHECK: %[[VAL_9:.*]] = arith.constant false
-! CHECK: %[[VAL_10:.*]] = fir.if %[[VAL_9]] -> (!fir.heap<f32>) {
-! CHECK: %[[VAL_11:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_11]] : !fir.heap<f32>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_4]] : !fir.heap<f32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_9]], %[[VAL_12:.*]] : i1, !fir.heap<f32>
-! CHECK: } else {
-! CHECK: %[[VAL_13:.*]] = arith.constant true
-! CHECK: %[[VAL_14:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_13]], %[[VAL_14]] : i1, !fir.heap<f32>
-! CHECK: }
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_15:.*]]#1 : !fir.heap<f32>
-! CHECK: fir.if %[[VAL_15]]#0 {
-! CHECK: fir.if %[[VAL_7]] {
-! CHECK: fir.freemem %[[VAL_4]]
-! CHECK: }
-! CHECK: fir.store %[[VAL_15]]#1 to %[[VAL_1]] : !fir.ref<!fir.heap<f32>>
-! CHECK: }
x = 42.
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_simple_local_scalar() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {bindc_name = "x", uniq_name = "_QMalloc_assignFtest_simple_local_scalarEx"}
+! CHECK: %[[VAL_1:.*]] = fir.zero_bits !fir.heap<f32>
+! CHECK: %[[VAL_2:.*]] = fir.embox %[[VAL_1]] : (!fir.heap<f32>) -> !fir.box<!fir.heap<f32>>
+! CHECK: fir.store %[[VAL_2]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<f32>>>
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_simple_local_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
+! CHECK: %[[VAL_4:.*]] = arith.constant 4.200000e+01 : f32
+! CHECK: hlfir.assign %[[VAL_4]] to %[[VAL_3]]#0 realloc : f32, !fir.ref<!fir.box<!fir.heap<f32>>>
! -----------------------------------------------------------------------------
! Test character scalar RHS
! -----------------------------------------------------------------------------
-! CHECK-LABEL: func @_QMalloc_assignPtest_deferred_char_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>{{.*}}) {
subroutine test_deferred_char_scalar(x)
character(:), allocatable :: x
-! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.char<1,12>>
-! CHECK: %[[VAL_2:.*]] = arith.constant 12 : index
-! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
-! CHECK: %[[VAL_4:.*]] = fir.box_addr %[[VAL_3]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.heap<!fir.char<1,?>>) -> i64
-! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_5]], %[[VAL_6]] : i64
-! CHECK: %[[VAL_8:.*]]:2 = fir.if %[[VAL_7]] -> (i1, !fir.heap<!fir.char<1,?>>) {
-! CHECK: %[[VAL_9:.*]] = arith.constant false
-! CHECK: %[[VAL_10:.*]] = fir.box_elesize %[[VAL_3]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> index
-! CHECK: %[[VAL_11:.*]] = arith.cmpi ne, %[[VAL_10]], %[[VAL_2]] : index
-! CHECK: %[[VAL_12:.*]] = arith.select %[[VAL_11]], %[[VAL_11]], %[[VAL_9]] : i1
-! CHECK: %[[VAL_13:.*]] = fir.if %[[VAL_12]] -> (!fir.heap<!fir.char<1,?>>) {
-! CHECK: %[[VAL_14:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_2]] : index) {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_14]] : !fir.heap<!fir.char<1,?>>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_4]] : !fir.heap<!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_12]], %[[VAL_15:.*]] : i1, !fir.heap<!fir.char<1,?>>
-! CHECK: } else {
-! CHECK: %[[VAL_16:.*]] = arith.constant true
-! CHECK: %[[VAL_17:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_2]] : index) {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_16]], %[[VAL_17]] : i1, !fir.heap<!fir.char<1,?>>
-! CHECK: }
-! character assignment ...
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_8]]#1 : (!fir.heap<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_24]], %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! character assignment ...
-
-! CHECK: fir.if %[[VAL_8]]#0 {
-! CHECK: fir.if %[[VAL_7]] {
-! CHECK: fir.freemem %[[VAL_4]]
-! CHECK: }
-! CHECK: %[[VAL_36:.*]] = fir.embox %[[VAL_8]]#1 typeparams %[[VAL_2]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
-! CHECK: fir.store %[[VAL_36]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
-! CHECK: }
x = "Hello world!"
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_deferred_char_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_deferred_char_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
+! CHECK: %[[VAL_3:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
+! CHECK: %[[VAL_4:.*]] = arith.constant 12 : index
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_3]] typeparams %[[VAL_4]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX48656C6C6F20776F726C6421"} : (!fir.ref<!fir.char<1,12>>, index) -> (!fir.ref<!fir.char<1,12>>, !fir.ref<!fir.char<1,12>>)
+! CHECK: hlfir.assign %[[VAL_5]]#0 to %[[VAL_2]]#0 realloc : !fir.ref<!fir.char<1,12>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_cst_char_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>{{.*}}) {
subroutine test_cst_char_scalar(x)
character(10), allocatable :: x
-! CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.char<1,12>>
-! CHECK: %[[VAL_3:.*]] = arith.constant 12 : index
-! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
-! CHECK: %[[VAL_5:.*]] = fir.box_addr %[[VAL_4]] : (!fir.box<!fir.heap<!fir.char<1,10>>>) -> !fir.heap<!fir.char<1,10>>
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.heap<!fir.char<1,10>>) -> i64
-! CHECK: %[[VAL_7:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_8:.*]] = arith.cmpi ne, %[[VAL_6]], %[[VAL_7]] : i64
-! CHECK: %[[VAL_9:.*]]:2 = fir.if %[[VAL_8]] -> (i1, !fir.heap<!fir.char<1,10>>) {
-! CHECK: %[[VAL_10:.*]] = arith.constant false
-! CHECK: %[[VAL_11:.*]] = fir.if %[[VAL_10]] -> (!fir.heap<!fir.char<1,10>>) {
-! CHECK: %[[VAL_12:.*]] = fir.allocmem !fir.char<1,10> {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_12]] : !fir.heap<!fir.char<1,10>>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_5]] : !fir.heap<!fir.char<1,10>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_10]], %[[VAL_13:.*]] : i1, !fir.heap<!fir.char<1,10>>
-! CHECK: } else {
-! CHECK: %[[VAL_14:.*]] = arith.constant true
-! CHECK: %[[VAL_15:.*]] = fir.allocmem !fir.char<1,10> {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_14]], %[[VAL_15]] : i1, !fir.heap<!fir.char<1,10>>
-! CHECK: }
-
-! character assignment ...
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_9]]#1 : (!fir.heap<!fir.char<1,10>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_24]], %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! character assignment ...
-
-! CHECK: fir.if %[[VAL_9]]#0 {
-! CHECK: fir.if %[[VAL_8]] {
-! CHECK: fir.freemem %[[VAL_5]]
-! CHECK: }
-! CHECK: %[[VAL_34:.*]] = fir.embox %[[VAL_9]]#1 : (!fir.heap<!fir.char<1,10>>) -> !fir.box<!fir.heap<!fir.char<1,10>>>
-! CHECK: fir.store %[[VAL_34]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
-! CHECK: }
x = "Hello world!"
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_cst_char_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_2]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_cst_char_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>, index, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>)
+! CHECK: %[[VAL_4:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 12 : index
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_4]] typeparams %[[VAL_5]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX48656C6C6F20776F726C6421"} : (!fir.ref<!fir.char<1,12>>, index) -> (!fir.ref<!fir.char<1,12>>, !fir.ref<!fir.char<1,12>>)
+! CHECK: hlfir.assign %[[VAL_6]]#0 to %[[VAL_3]]#0 realloc keep_lhs_len : !fir.ref<!fir.char<1,12>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_dyn_char_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>{{.*}},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}) {
subroutine test_dyn_char_scalar(x, n)
integer :: n
character(n), allocatable :: x
-! CHECK: %[[VAL_2A:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_2B:.*]] = arith.cmpi sgt, %[[VAL_2A]], %[[c0_i32]] : i32
-! CHECK: %[[VAL_2:.*]] = arith.select %[[VAL_2B]], %[[VAL_2A]], %[[c0_i32]] : i32
-! CHECK: %[[VAL_3:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 12 : index
-! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
-! CHECK: %[[VAL_6:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.heap<!fir.char<1,?>>) -> i64
-! CHECK: %[[VAL_8:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_9:.*]] = arith.cmpi ne, %[[VAL_7]], %[[VAL_8]] : i64
-! CHECK: %[[VAL_10:.*]]:2 = fir.if %[[VAL_9]] -> (i1, !fir.heap<!fir.char<1,?>>) {
-! CHECK: %[[VAL_11:.*]] = arith.constant false
-! CHECK: %[[VAL_12:.*]] = fir.if %[[VAL_11]] -> (!fir.heap<!fir.char<1,?>>) {
-! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
-! CHECK: %[[VAL_14:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_13]] : index) {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_14]] : !fir.heap<!fir.char<1,?>>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_6]] : !fir.heap<!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_11]], %[[VAL_15:.*]] : i1, !fir.heap<!fir.char<1,?>>
-! CHECK: } else {
-! CHECK: %[[VAL_16:.*]] = arith.constant true
-! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
-! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_17]] : index) {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_16]], %[[VAL_18]] : i1, !fir.heap<!fir.char<1,?>>
-! CHECK: }
-
-! character assignment ...
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_10]]#1 : (!fir.heap<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_24]], %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! character assignment ...
-
-! CHECK: fir.if %[[VAL_10]]#0 {
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
-! CHECK: fir.if %[[VAL_9]] {
-! CHECK: fir.freemem %[[VAL_6]]
-! CHECK: }
-! CHECK: %[[VAL_40:.*]] = fir.embox %[[VAL_10]]#1 typeparams %[[VAL_39]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
-! CHECK: fir.store %[[VAL_40]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
-! CHECK: }
x = "Hello world!"
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_dyn_char_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "n"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_dyn_char_scalarEn"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32
+! CHECK: %[[VAL_6:.*]] = arith.cmpi sgt, %[[VAL_4]], %[[VAL_5]] : i32
+! CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_4]], %[[VAL_5]] : i32
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_7]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_dyn_char_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, i32, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
+! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
+! CHECK: %[[VAL_10:.*]] = arith.constant 12 : index
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_9]] typeparams %[[VAL_10]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX48656C6C6F20776F726C6421"} : (!fir.ref<!fir.char<1,12>>, index) -> (!fir.ref<!fir.char<1,12>>, !fir.ref<!fir.char<1,12>>)
+! CHECK: hlfir.assign %[[VAL_11]]#0 to %[[VAL_8]]#0 realloc keep_lhs_len : !fir.ref<!fir.char<1,12>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_derived_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>{{.*}},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>{{.*}}) {
subroutine test_derived_scalar(x, s)
type(t), allocatable :: x
type(t) :: s
x = s
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>
-! CHECK: %[[VAL_3:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>) -> !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
-! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) -> i64
-! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_6:.*]] = arith.cmpi ne, %[[VAL_4]], %[[VAL_5]] : i64
-! CHECK: %[[VAL_7:.*]]:2 = fir.if %[[VAL_6]] -> (i1, !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) {
-! CHECK: %[[VAL_8:.*]] = arith.constant false
-! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_8]] -> (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) {
-! CHECK: %[[VAL_10:.*]] = fir.allocmem !fir.type<_QMalloc_assignTt{i:i32}> {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_10]] : !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_3]] : !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_8]], %[[VAL_11:.*]] : i1, !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
-! CHECK: } else {
-! CHECK: %[[VAL_12:.*]] = arith.constant true
-! CHECK: %[[VAL_13:.*]] = fir.allocmem !fir.type<_QMalloc_assignTt{i:i32}> {uniq_name = ".auto.alloc"}
-! CHECK: fir.result %[[VAL_12]], %[[VAL_13]] : i1, !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
-! CHECK: }
-! CHECK: %[[VAL_14:.*]] = fir.field_index i, !fir.type<_QMalloc_assignTt{i:i32}>
-! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_14]] : (!fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.field) -> !fir.ref<i32>
-! CHECK: %[[VAL_14b:.*]] = fir.field_index i, !fir.type<_QMalloc_assignTt{i:i32}>
-! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_7]]#1, %[[VAL_14b]] : (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.field) -> !fir.ref<i32>
-! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_15]] : !fir.ref<i32>
-! CHECK: fir.store %[[VAL_17]] to %[[VAL_16]] : !fir.ref<i32
-! CHECK: fir.if %[[VAL_7]]#0 {
-! CHECK: fir.if %[[VAL_6]] {
-! CHECK: fir.freemem %[[VAL_3]]
-! CHECK: }
-! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_7]]#1 : (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) -> !fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>
-! CHECK: fir.store %[[VAL_19]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>
-! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_derived_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>> {fir.bindc_name = "s"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_derived_scalarEs"} : (!fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.dscope) -> (!fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>)
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_derived_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>, !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>)
+! CHECK: hlfir.assign %[[VAL_3]]#0 to %[[VAL_4]]#0 realloc : !fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>
! -----------------------------------------------------------------------------
! Test numeric/logical array RHS
! -----------------------------------------------------------------------------
-! CHECK-LABEL: func @_QMalloc_assignPtest_from_cst_shape_array(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<2x3xf32>>{{.*}}) {
subroutine test_from_cst_shape_array(x, y)
real, allocatable :: x(:, :)
real :: y(2, 3)
-! CHECK: %[[VAL_2:.*]] = arith.constant 2 : index
-! CHECK: %[[VAL_3:.*]] = arith.constant 3 : index
-! CHECK: %[[VAL_4:.*]] = arith.constant 2 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index
-! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_7:.*]] = fir.array_load %[[VAL_1]](%[[VAL_6]]) : (!fir.ref<!fir.array<2x3xf32>>, !fir.shape<2>) -> !fir.array<2x3xf32>
-! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_9:.*]] = fir.box_addr %[[VAL_8]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
-! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
-! CHECK: %[[VAL_11:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_12:.*]] = arith.cmpi ne, %[[VAL_10]], %[[VAL_11]] : i64
-! CHECK: %[[VAL_13:.*]]:2 = fir.if %[[VAL_12]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_14:.*]] = arith.constant false
-! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_16:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_15]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_18:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_17]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_19:.*]] = arith.cmpi ne, %[[VAL_16]]#1, %[[VAL_4]] : index
-! CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_19]], %[[VAL_19]], %[[VAL_14]] : i1
-! CHECK: %[[VAL_21:.*]] = arith.cmpi ne, %[[VAL_18]]#1, %[[VAL_5]] : index
-! CHECK: %[[VAL_22:.*]] = arith.select %[[VAL_21]], %[[VAL_21]], %[[VAL_20]] : i1
-! CHECK: %[[VAL_23:.*]] = fir.if %[[VAL_22]] -> (!fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_24:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_4]], %[[VAL_5]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_24]](%[[VAL_25]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_4]], %[[VAL_27]] : index
-! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_5]], %[[VAL_27]] : index
-! CHECK: %[[VAL_31:.*]] = fir.do_loop %[[VAL_32:.*]] = %[[VAL_28]] to %[[VAL_30]] step %[[VAL_27]] unordered iter_args(%[[VAL_33:.*]] = %[[VAL_26]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_34:.*]] = fir.do_loop %[[VAL_35:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_36:.*]] = %[[VAL_33]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_37:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_35]], %[[VAL_32]] : (!fir.array<2x3xf32>, index, index) -> f32
-! CHECK: %[[VAL_38:.*]] = fir.array_update %[[VAL_36]], %[[VAL_37]], %[[VAL_35]], %[[VAL_32]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_38]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_39:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_26]], %[[VAL_40:.*]] to %[[VAL_24]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_24]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_41:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_42:.*]] = fir.array_load %[[VAL_9]](%[[VAL_41]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_43:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_44:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_4]], %[[VAL_43]] : index
-! CHECK: %[[VAL_46:.*]] = arith.subi %[[VAL_5]], %[[VAL_43]] : index
-! CHECK: %[[VAL_47:.*]] = fir.do_loop %[[VAL_48:.*]] = %[[VAL_44]] to %[[VAL_46]] step %[[VAL_43]] unordered iter_args(%[[VAL_49:.*]] = %[[VAL_42]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_50:.*]] = fir.do_loop %[[VAL_51:.*]] = %[[VAL_44]] to %[[VAL_45]] step %[[VAL_43]] unordered iter_args(%[[VAL_52:.*]] = %[[VAL_49]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_53:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_51]], %[[VAL_48]] : (!fir.array<2x3xf32>, index, index) -> f32
-! CHECK: %[[VAL_54:.*]] = fir.array_update %[[VAL_52]], %[[VAL_53]], %[[VAL_51]], %[[VAL_48]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_54]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_55:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_42]], %[[VAL_56:.*]] to %[[VAL_9]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_9]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_22]], %[[VAL_57:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_58:.*]] = arith.constant true
-! CHECK: %[[VAL_59:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_4]], %[[VAL_5]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_60:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_61:.*]] = fir.array_load %[[VAL_59]](%[[VAL_60]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_62:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_63:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_64:.*]] = arith.subi %[[VAL_4]], %[[VAL_62]] : index
-! CHECK: %[[VAL_65:.*]] = arith.subi %[[VAL_5]], %[[VAL_62]] : index
-! CHECK: %[[VAL_66:.*]] = fir.do_loop %[[VAL_67:.*]] = %[[VAL_63]] to %[[VAL_65]] step %[[VAL_62]] unordered iter_args(%[[VAL_68:.*]] = %[[VAL_61]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_69:.*]] = fir.do_loop %[[VAL_70:.*]] = %[[VAL_63]] to %[[VAL_64]] step %[[VAL_62]] unordered iter_args(%[[VAL_71:.*]] = %[[VAL_68]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_72:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_70]], %[[VAL_67]] : (!fir.array<2x3xf32>, index, index) -> f32
-! CHECK: %[[VAL_73:.*]] = fir.array_update %[[VAL_71]], %[[VAL_72]], %[[VAL_70]], %[[VAL_67]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_73]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_74:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_61]], %[[VAL_75:.*]] to %[[VAL_59]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_58]], %[[VAL_59]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_76:.*]]#0 {
-! CHECK: fir.if %[[VAL_12]] {
-! CHECK: fir.freemem %[[VAL_9]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: %[[VAL_77:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_78:.*]] = fir.embox %[[VAL_76]]#1(%[[VAL_77]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
-! CHECK: fir.store %[[VAL_78]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
x = y
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_from_cst_shape_array(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<2x3xf32>> {fir.bindc_name = "y"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_from_cst_shape_arrayEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>)
+! CHECK: %[[VAL_4:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_6]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_from_cst_shape_arrayEy"} : (!fir.ref<!fir.array<2x3xf32>>, !fir.shape<2>, !fir.dscope) -> (!fir.ref<!fir.array<2x3xf32>>, !fir.ref<!fir.array<2x3xf32>>)
+! CHECK: hlfir.assign %[[VAL_7]]#0 to %[[VAL_3]]#0 realloc : !fir.ref<!fir.array<2x3xf32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_from_dyn_shape_array(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
subroutine test_from_dyn_shape_array(x, y)
real, allocatable :: x(:, :)
real :: y(:, :)
x = y
-! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_2]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_4]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
-! CHECK: %[[VAL_10:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_11:.*]] = arith.cmpi ne, %[[VAL_9]], %[[VAL_10]] : i64
-! CHECK: %[[VAL_12:.*]]:2 = fir.if %[[VAL_11]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_13:.*]] = arith.constant false
-! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_15:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_14]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_17:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_16]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_15]]#1, %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_18]], %[[VAL_13]] : i1
-! CHECK: %[[VAL_20:.*]] = arith.cmpi ne, %[[VAL_17]]#1, %[[VAL_5]]#1 : index
-! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_20]], %[[VAL_19]] : i1
-! CHECK: %[[VAL_22:.*]] = fir.if %[[VAL_21]] -> (!fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_23:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_3]]#1, %[[VAL_5]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_25:.*]] = fir.array_load %[[VAL_23]](%[[VAL_24]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_26]] : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_5]]#1, %[[VAL_26]] : index
-! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_27]] to %[[VAL_29]] step %[[VAL_26]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_25]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_33:.*]] = fir.do_loop %[[VAL_34:.*]] = %[[VAL_27]] to %[[VAL_28]] step %[[VAL_26]] unordered iter_args(%[[VAL_35:.*]] = %[[VAL_32]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_36:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_34]], %[[VAL_31]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_37:.*]] = fir.array_update %[[VAL_35]], %[[VAL_36]], %[[VAL_34]], %[[VAL_31]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_37]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_38:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_25]], %[[VAL_39:.*]] to %[[VAL_23]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_23]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_41:.*]] = fir.array_load %[[VAL_8]](%[[VAL_40]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_43:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_42]] : index
-! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_5]]#1, %[[VAL_42]] : index
-! CHECK: %[[VAL_46:.*]] = fir.do_loop %[[VAL_47:.*]] = %[[VAL_43]] to %[[VAL_45]] step %[[VAL_42]] unordered iter_args(%[[VAL_48:.*]] = %[[VAL_41]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_43]] to %[[VAL_44]] step %[[VAL_42]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_48]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_50]], %[[VAL_47]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_53:.*]] = fir.array_update %[[VAL_51]], %[[VAL_52]], %[[VAL_50]], %[[VAL_47]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_53]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_54:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_41]], %[[VAL_55:.*]] to %[[VAL_8]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_8]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_21]], %[[VAL_56:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_57:.*]] = arith.constant true
-! CHECK: %[[VAL_58:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_3]]#1, %[[VAL_5]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_59:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_60:.*]] = fir.array_load %[[VAL_58]](%[[VAL_59]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_61:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_62:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_63:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_61]] : index
-! CHECK: %[[VAL_64:.*]] = arith.subi %[[VAL_5]]#1, %[[VAL_61]] : index
-! CHECK: %[[VAL_65:.*]] = fir.do_loop %[[VAL_66:.*]] = %[[VAL_62]] to %[[VAL_64]] step %[[VAL_61]] unordered iter_args(%[[VAL_67:.*]] = %[[VAL_60]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_68:.*]] = fir.do_loop %[[VAL_69:.*]] = %[[VAL_62]] to %[[VAL_63]] step %[[VAL_61]] unordered iter_args(%[[VAL_70:.*]] = %[[VAL_67]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_71:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_69]], %[[VAL_66]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_72:.*]] = fir.array_update %[[VAL_70]], %[[VAL_71]], %[[VAL_69]], %[[VAL_66]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_72]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_73:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_60]], %[[VAL_74:.*]] to %[[VAL_58]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_57]], %[[VAL_58]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_75:.*]]#0 {
-! CHECK: fir.if %[[VAL_11]] {
-! CHECK: fir.freemem %[[VAL_8]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: %[[VAL_76:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_77:.*]] = fir.embox %[[VAL_75]]#1(%[[VAL_76]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
-! CHECK: fir.store %[[VAL_77]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_from_dyn_shape_array(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "y"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_from_dyn_shape_arrayEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>)
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_from_dyn_shape_arrayEy"} : (!fir.box<!fir.array<?x?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?x?xf32>>, !fir.box<!fir.array<?x?xf32>>)
+! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_3]]#0 realloc : !fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_with_lbounds(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
subroutine test_with_lbounds(x, y)
real, allocatable :: x(:, :)
real :: y(10:, 20:)
-! CHECK: %[[VAL_2:.*]] = arith.constant 10 : i64
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i64) -> index
-! CHECK: %[[VAL_4:.*]] = arith.constant 20 : i64
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
-! CHECK: %[[VAL_6:.*]] = fir.shift %[[VAL_3]], %[[VAL_5]] : (index, index) -> !fir.shift<2>
-! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_8:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_7]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_9]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]](%[[VAL_6]]) : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_13:.*]] = fir.box_addr %[[VAL_12]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
-! CHECK: %[[VAL_15:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_16:.*]] = arith.cmpi ne, %[[VAL_14]], %[[VAL_15]] : i64
-! CHECK: %[[VAL_17:.*]]:2 = fir.if %[[VAL_16]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_18:.*]] = arith.constant false
-! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_20:.*]]:3 = fir.box_dims %[[VAL_12]], %[[VAL_19]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_12]], %[[VAL_21]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_23:.*]] = arith.cmpi ne, %[[VAL_20]]#1, %[[VAL_8]]#1 : index
-! CHECK: %[[VAL_24:.*]] = arith.select %[[VAL_23]], %[[VAL_23]], %[[VAL_18]] : i1
-! CHECK: %[[VAL_25:.*]] = arith.cmpi ne, %[[VAL_22]]#1, %[[VAL_10]]#1 : index
-! CHECK: %[[VAL_26:.*]] = arith.select %[[VAL_25]], %[[VAL_25]], %[[VAL_24]] : i1
-! CHECK: %[[VAL_27:.*]] = fir.if %[[VAL_26]] -> (!fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_28:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_8]]#1, %[[VAL_10]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_29:.*]] = fir.shape %[[VAL_8]]#1, %[[VAL_10]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_30:.*]] = fir.array_load %[[VAL_28]](%[[VAL_29]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_32:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_8]]#1, %[[VAL_31]] : index
-! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_31]] : index
-! CHECK: %[[VAL_35:.*]] = fir.do_loop %[[VAL_36:.*]] = %[[VAL_32]] to %[[VAL_34]] step %[[VAL_31]] unordered iter_args(%[[VAL_37:.*]] = %[[VAL_30]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_38:.*]] = fir.do_loop %[[VAL_39:.*]] = %[[VAL_32]] to %[[VAL_33]] step %[[VAL_31]] unordered iter_args(%[[VAL_40:.*]] = %[[VAL_37]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_41:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_39]], %[[VAL_36]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_42:.*]] = fir.array_update %[[VAL_40]], %[[VAL_41]], %[[VAL_39]], %[[VAL_36]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_42]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_43:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_30]], %[[VAL_44:.*]] to %[[VAL_28]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_28]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_45:.*]] = fir.shape %[[VAL_8]]#1, %[[VAL_10]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_46:.*]] = fir.array_load %[[VAL_13]](%[[VAL_45]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_48:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_8]]#1, %[[VAL_47]] : index
-! CHECK: %[[VAL_50:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_47]] : index
-! CHECK: %[[VAL_51:.*]] = fir.do_loop %[[VAL_52:.*]] = %[[VAL_48]] to %[[VAL_50]] step %[[VAL_47]] unordered iter_args(%[[VAL_53:.*]] = %[[VAL_46]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_54:.*]] = fir.do_loop %[[VAL_55:.*]] = %[[VAL_48]] to %[[VAL_49]] step %[[VAL_47]] unordered iter_args(%[[VAL_56:.*]] = %[[VAL_53]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_57:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_55]], %[[VAL_52]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_58:.*]] = fir.array_update %[[VAL_56]], %[[VAL_57]], %[[VAL_55]], %[[VAL_52]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_58]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_59:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_46]], %[[VAL_60:.*]] to %[[VAL_13]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_13]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_26]], %[[VAL_61:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_62:.*]] = arith.constant true
-! CHECK: %[[VAL_63:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_8]]#1, %[[VAL_10]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_64:.*]] = fir.shape %[[VAL_8]]#1, %[[VAL_10]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_65:.*]] = fir.array_load %[[VAL_63]](%[[VAL_64]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_66:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_67:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_68:.*]] = arith.subi %[[VAL_8]]#1, %[[VAL_66]] : index
-! CHECK: %[[VAL_69:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_66]] : index
-! CHECK: %[[VAL_70:.*]] = fir.do_loop %[[VAL_71:.*]] = %[[VAL_67]] to %[[VAL_69]] step %[[VAL_66]] unordered iter_args(%[[VAL_72:.*]] = %[[VAL_65]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_73:.*]] = fir.do_loop %[[VAL_74:.*]] = %[[VAL_67]] to %[[VAL_68]] step %[[VAL_66]] unordered iter_args(%[[VAL_75:.*]] = %[[VAL_72]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_76:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_74]], %[[VAL_71]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_77:.*]] = fir.array_update %[[VAL_75]], %[[VAL_76]], %[[VAL_74]], %[[VAL_71]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_77]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_78:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_65]], %[[VAL_79:.*]] to %[[VAL_63]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_62]], %[[VAL_63]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_80:.*]]#0 {
-! CHECK: fir.if %[[VAL_16]] {
-! CHECK: fir.freemem %[[VAL_13]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: %[[VAL_81:.*]] = fir.shape_shift %[[VAL_3]], %[[VAL_8]]#1, %[[VAL_5]], %[[VAL_10]]#1 : (index, index, index, index) -> !fir.shapeshift<2>
-! CHECK: %[[VAL_82:.*]] = fir.embox %[[VAL_80]]#1(%[[VAL_81]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
-! CHECK: fir.store %[[VAL_82]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
x = y
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_with_lbounds(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "y"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_with_lboundsEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>)
+! CHECK: %[[VAL_4:.*]] = arith.constant 10 : i64
+! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
+! CHECK: %[[VAL_6:.*]] = arith.constant 20 : i64
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
+! CHECK: %[[VAL_8:.*]] = fir.shift %[[VAL_5]], %[[VAL_7]] : (index, index) -> !fir.shift<2>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_8]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_with_lboundsEy"} : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<2>, !fir.dscope) -> (!fir.box<!fir.array<?x?xf32>>, !fir.box<!fir.array<?x?xf32>>)
+! CHECK: hlfir.assign %[[VAL_9]]#0 to %[[VAL_3]]#0 realloc : !fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_runtime_shape(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}}) {
subroutine test_runtime_shape(x)
real, allocatable :: x(:, :)
interface
@@ -569,120 +158,32 @@ function return_pointer()
real, pointer :: return_pointer(:, :)
end function
end interface
-! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xf32>>> {bindc_name = ".result"}
-! CHECK: %[[VAL_2:.*]] = fir.call @_QPreturn_pointer() {{.*}}: () -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
-! CHECK: fir.save_result %[[VAL_2]] to %[[VAL_1]] : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_4]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_6]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_8:.*]] = fir.shift %[[VAL_5]]#0, %[[VAL_7]]#0 : (index, index) -> !fir.shift<2>
-! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_9]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_12:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_11]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, !fir.shift<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_15:.*]] = fir.box_addr %[[VAL_14]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
-! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
-! CHECK: %[[VAL_17:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_16]], %[[VAL_17]] : i64
-! CHECK: %[[VAL_19:.*]]:2 = fir.if %[[VAL_18]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_20:.*]] = arith.constant false
-! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_14]], %[[VAL_21]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_24:.*]]:3 = fir.box_dims %[[VAL_14]], %[[VAL_23]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_25:.*]] = arith.cmpi ne, %[[VAL_22]]#1, %[[VAL_10]]#1 : index
-! CHECK: %[[VAL_26:.*]] = arith.select %[[VAL_25]], %[[VAL_25]], %[[VAL_20]] : i1
-! CHECK: %[[VAL_27:.*]] = arith.cmpi ne, %[[VAL_24]]#1, %[[VAL_12]]#1 : index
-! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_27]], %[[VAL_26]] : i1
-! CHECK: %[[VAL_29:.*]] = fir.if %[[VAL_28]] -> (!fir.heap<!fir.array<?x?xf32>>) {
-! CHECK: %[[VAL_30:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_10]]#1, %[[VAL_12]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_31:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_32:.*]] = fir.array_load %[[VAL_30]](%[[VAL_31]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_33:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_34:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_33]] : index
-! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_12]]#1, %[[VAL_33]] : index
-! CHECK: %[[VAL_37:.*]] = fir.do_loop %[[VAL_38:.*]] = %[[VAL_34]] to %[[VAL_36]] step %[[VAL_33]] unordered iter_args(%[[VAL_39:.*]] = %[[VAL_32]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_40:.*]] = fir.do_loop %[[VAL_41:.*]] = %[[VAL_34]] to %[[VAL_35]] step %[[VAL_33]] unordered iter_args(%[[VAL_42:.*]] = %[[VAL_39]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_43:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_41]], %[[VAL_38]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_44:.*]] = fir.array_update %[[VAL_42]], %[[VAL_43]], %[[VAL_41]], %[[VAL_38]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_44]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_45:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_32]], %[[VAL_46:.*]] to %[[VAL_30]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_30]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_47:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_48:.*]] = fir.array_load %[[VAL_15]](%[[VAL_47]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_49:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_51:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_49]] : index
-! CHECK: %[[VAL_52:.*]] = arith.subi %[[VAL_12]]#1, %[[VAL_49]] : index
-! CHECK: %[[VAL_53:.*]] = fir.do_loop %[[VAL_54:.*]] = %[[VAL_50]] to %[[VAL_52]] step %[[VAL_49]] unordered iter_args(%[[VAL_55:.*]] = %[[VAL_48]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_56:.*]] = fir.do_loop %[[VAL_57:.*]] = %[[VAL_50]] to %[[VAL_51]] step %[[VAL_49]] unordered iter_args(%[[VAL_58:.*]] = %[[VAL_55]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_59:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_57]], %[[VAL_54]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_60:.*]] = fir.array_update %[[VAL_58]], %[[VAL_59]], %[[VAL_57]], %[[VAL_54]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_60]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_61:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_48]], %[[VAL_62:.*]] to %[[VAL_15]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_15]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_28]], %[[VAL_63:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_64:.*]] = arith.constant true
-! CHECK: %[[VAL_65:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_10]]#1, %[[VAL_12]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_66:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_67:.*]] = fir.array_load %[[VAL_65]](%[[VAL_66]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
-! CHECK: %[[VAL_68:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_69:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_70:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_68]] : index
-! CHECK: %[[VAL_71:.*]] = arith.subi %[[VAL_12]]#1, %[[VAL_68]] : index
-! CHECK: %[[VAL_72:.*]] = fir.do_loop %[[VAL_73:.*]] = %[[VAL_69]] to %[[VAL_71]] step %[[VAL_68]] unordered iter_args(%[[VAL_74:.*]] = %[[VAL_67]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_75:.*]] = fir.do_loop %[[VAL_76:.*]] = %[[VAL_69]] to %[[VAL_70]] step %[[VAL_68]] unordered iter_args(%[[VAL_77:.*]] = %[[VAL_74]]) -> (!fir.array<?x?xf32>) {
-! CHECK: %[[VAL_78:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_76]], %[[VAL_73]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK: %[[VAL_79:.*]] = fir.array_update %[[VAL_77]], %[[VAL_78]], %[[VAL_76]], %[[VAL_73]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK: fir.result %[[VAL_79]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_80:.*]] : !fir.array<?x?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_67]], %[[VAL_81:.*]] to %[[VAL_65]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: fir.result %[[VAL_64]], %[[VAL_65]] : i1, !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_82:.*]]#0 {
-! CHECK: fir.if %[[VAL_18]] {
-! CHECK: fir.freemem %[[VAL_15]] : !fir.heap<!fir.array<?x?xf32>>
-! CHECK: }
-! CHECK: %[[VAL_83:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_84:.*]] = fir.embox %[[VAL_82]]#1(%[[VAL_83]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
-! CHECK: fir.store %[[VAL_84]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
x = return_pointer()
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_runtime_shape(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xf32>>> {bindc_name = ".result"}
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_runtime_shapeEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>)
+! CHECK: %[[VAL_4:.*]] = fir.call @_QPreturn_pointer() fastmath<contract> : () -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
+! CHECK: fir.save_result %[[VAL_4]] to %[[VAL_1]] : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_1]] {uniq_name = ".tmp.func_result"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>)
+! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
+! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_3]]#0 realloc : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_scalar_rhs(
subroutine test_scalar_rhs(x, y)
real, allocatable :: x(:)
real :: y
- ! CHECK: fir.if %{{.*}} -> {{.*}} {
- ! CHECK: fir.if %false -> {{.*}} {
- ! CHECK: }
- ! CHECK: } else {
- ! CHECK: %[[error_msg_addr:.*]] = fir.address_of(@[[error_message:.*]]) : !fir.ref<!fir.char<1,76>>
- ! CHECK: %[[msg_addr_cast:.*]] = fir.convert %[[error_msg_addr]] : (!fir.ref<!fir.char<1,76>>) -> !fir.ref<i8>
- ! CHECK: fir.call @_FortranAReportFatalUserError(%[[msg_addr_cast]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i32) -> ()
- ! CHECK-NOT: allocmem
- ! CHECK: }
x = y
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_scalar_rhs(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f32> {fir.bindc_name = "y"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_scalar_rhsEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>)
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_scalar_rhsEy"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<f32>
+! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_3]]#0 realloc : f32, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
! -----------------------------------------------------------------------------
! Test character array RHS
@@ -695,32 +196,41 @@ subroutine test_scalar_rhs(x, y)
! x = "Hello world!"
!end subroutine
-! CHECK: func @_QMalloc_assignPtest_cst_char_rhs_scalar(
subroutine test_cst_char_rhs_scalar(x)
character(10), allocatable :: x(:)
x = "Hello world!"
- ! CHECK: fir.if %{{.*}} -> {{.*}} {
- ! CHECK: fir.if %false -> {{.*}} {
- ! CHECK: }
- ! CHECK: } else {
! TODO: runtime error if unallocated
- ! CHECK-NOT: allocmem
- ! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_cst_char_rhs_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_2]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_cst_char_rhs_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>, index, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>)
+! CHECK: %[[VAL_4:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 12 : index
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_4]] typeparams %[[VAL_5]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX48656C6C6F20776F726C6421"} : (!fir.ref<!fir.char<1,12>>, index) -> (!fir.ref<!fir.char<1,12>>, !fir.ref<!fir.char<1,12>>)
+! CHECK: hlfir.assign %[[VAL_6]]#0 to %[[VAL_3]]#0 realloc keep_lhs_len : !fir.ref<!fir.char<1,12>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
-! CHECK: func @_QMalloc_assignPtest_dyn_char_rhs_scalar(
subroutine test_dyn_char_rhs_scalar(x, n)
integer :: n
character(n), allocatable :: x(:)
x = "Hello world!"
- ! CHECK: fir.if %{{.*}} -> {{.*}} {
- ! CHECK: fir.if %false -> {{.*}} {
- ! CHECK: }
- ! CHECK: } else {
! TODO: runtime error if unallocated
- ! CHECK-NOT: allocmem
- ! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_dyn_char_rhs_scalar(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "n"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_dyn_char_rhs_scalarEn"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32
+! CHECK: %[[VAL_6:.*]] = arith.cmpi sgt, %[[VAL_4]], %[[VAL_5]] : i32
+! CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_4]], %[[VAL_5]] : i32
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_7]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_dyn_char_rhs_scalarEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, i32, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>)
+! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
+! CHECK: %[[VAL_10:.*]] = arith.constant 12 : index
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_9]] typeparams %[[VAL_10]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX48656C6C6F20776F726C6421"} : (!fir.ref<!fir.char<1,12>>, index) -> (!fir.ref<!fir.char<1,12>>, !fir.ref<!fir.char<1,12>>)
+! CHECK: hlfir.assign %[[VAL_11]]#0 to %[[VAL_8]]#0 realloc keep_lhs_len : !fir.ref<!fir.char<1,12>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
! Hit TODO: gathering lhs length in array expression
!subroutine test_deferred_char(x, c)
@@ -729,312 +239,49 @@ subroutine test_dyn_char_rhs_scalar(x, n)
! x = "Hello world!"
!end subroutine
-! CHECK-LABEL: func @_QMalloc_assignPtest_cst_char(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>{{.*}},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine test_cst_char(x, c)
character(10), allocatable :: x(:)
character(12) :: c(20)
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<20x!fir.char<1,12>>>
-! CHECK: %[[VAL_3:.*]] = arith.constant 12 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
-! CHECK: %[[VAL_6:.*]] = arith.constant 20 : index
-! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_4]](%[[VAL_7]]) : (!fir.ref<!fir.array<20x!fir.char<1,12>>>, !fir.shape<1>) -> !fir.array<20x!fir.char<1,12>>
-! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
-! CHECK: %[[VAL_10:.*]] = fir.box_addr %[[VAL_9]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.heap<!fir.array<?x!fir.char<1,10>>>) -> i64
-! CHECK: %[[VAL_12:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_13:.*]] = arith.cmpi ne, %[[VAL_11]], %[[VAL_12]] : i64
-! CHECK: %[[VAL_14:.*]]:2 = fir.if %[[VAL_13]] -> (i1, !fir.heap<!fir.array<?x!fir.char<1,10>>>) {
-! CHECK: %[[VAL_15:.*]] = arith.constant false
-! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_17:.*]]:3 = fir.box_dims %[[VAL_9]], %[[VAL_16]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_17]]#1, %[[VAL_6]] : index
-! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_18]], %[[VAL_15]] : i1
-! CHECK: %[[VAL_20:.*]] = fir.if %[[VAL_19]] -> (!fir.heap<!fir.array<?x!fir.char<1,10>>>) {
-! CHECK: %[[VAL_21:.*]] = fir.allocmem !fir.array<?x!fir.char<1,10>>, %[[VAL_6]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_23:.*]] = fir.array_load %[[VAL_21]](%[[VAL_22]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
-! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_25:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_6]], %[[VAL_24]] : index
-! CHECK: %[[VAL_27:.*]] = fir.do_loop %[[VAL_28:.*]] = %[[VAL_25]] to %[[VAL_26]] step %[[VAL_24]] unordered iter_args(%[[VAL_29:.*]] = %[[VAL_23]]) -> (!fir.array<?x!fir.char<1,10>>) {
-! CHECK: %[[VAL_30:.*]] = fir.array_access %[[VAL_8]], %[[VAL_28]] : (!fir.array<20x!fir.char<1,12>>, index) -> !fir.ref<!fir.char<1,12>>
-! CHECK: %[[VAL_31:.*]] = fir.array_access %[[VAL_29]], %[[VAL_28]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_32:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_33:.*]] = arith.cmpi slt, %[[VAL_32]], %[[VAL_3]] : index
-! CHECK: %[[VAL_34:.*]] = arith.select %[[VAL_33]], %[[VAL_32]], %[[VAL_3]] : index
-! CHECK: %[[VAL_35:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_34]] : (index) -> i64
-! CHECK: %[[VAL_37:.*]] = arith.muli %[[VAL_35]], %[[VAL_36]] : i64
-! CHECK: %[[VAL_38:.*]] = arith.constant false
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_30]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_39]], %[[VAL_40]], %[[VAL_37]], %[[VAL_38]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_41:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_42:.*]] = arith.subi %[[VAL_32]], %[[VAL_41]] : index
-! CHECK: %[[VAL_43:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_44:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_45:.*]] = fir.insert_value %[[VAL_44]], %[[VAL_43]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_47:.*]] = %[[VAL_34]] to %[[VAL_42]] step %[[VAL_46]] {
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
-! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_47]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_45]] to %[[VAL_49]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_50:.*]] = fir.array_amend %[[VAL_29]], %[[VAL_31]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
-! CHECK: fir.result %[[VAL_50]] : !fir.array<?x!fir.char<1,10>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_23]], %[[VAL_51:.*]] to %[[VAL_21]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: fir.result %[[VAL_21]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: } else {
-! CHECK: %[[VAL_52:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_53:.*]] = fir.array_load %[[VAL_10]](%[[VAL_52]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
-! CHECK: %[[VAL_54:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_55:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_56:.*]] = arith.subi %[[VAL_6]], %[[VAL_54]] : index
-! CHECK: %[[VAL_57:.*]] = fir.do_loop %[[VAL_58:.*]] = %[[VAL_55]] to %[[VAL_56]] step %[[VAL_54]] unordered iter_args(%[[VAL_59:.*]] = %[[VAL_53]]) -> (!fir.array<?x!fir.char<1,10>>) {
-! CHECK: %[[VAL_60:.*]] = fir.array_access %[[VAL_8]], %[[VAL_58]] : (!fir.array<20x!fir.char<1,12>>, index) -> !fir.ref<!fir.char<1,12>>
-! CHECK: %[[VAL_61:.*]] = fir.array_access %[[VAL_59]], %[[VAL_58]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_62:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_63:.*]] = arith.cmpi slt, %[[VAL_62]], %[[VAL_3]] : index
-! CHECK: %[[VAL_64:.*]] = arith.select %[[VAL_63]], %[[VAL_62]], %[[VAL_3]] : index
-! CHECK: %[[VAL_65:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_66:.*]] = fir.convert %[[VAL_64]] : (index) -> i64
-! CHECK: %[[VAL_67:.*]] = arith.muli %[[VAL_65]], %[[VAL_66]] : i64
-! CHECK: %[[VAL_68:.*]] = arith.constant false
-! CHECK: %[[VAL_69:.*]] = fir.convert %[[VAL_61]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_70:.*]] = fir.convert %[[VAL_60]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_69]], %[[VAL_70]], %[[VAL_67]], %[[VAL_68]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_71:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_72:.*]] = arith.subi %[[VAL_62]], %[[VAL_71]] : index
-! CHECK: %[[VAL_73:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_74:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_75:.*]] = fir.insert_value %[[VAL_74]], %[[VAL_73]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_76:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_77:.*]] = %[[VAL_64]] to %[[VAL_72]] step %[[VAL_76]] {
-! CHECK: %[[VAL_78:.*]] = fir.convert %[[VAL_61]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
-! CHECK: %[[VAL_79:.*]] = fir.coordinate_of %[[VAL_78]], %[[VAL_77]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_75]] to %[[VAL_79]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_80:.*]] = fir.array_amend %[[VAL_59]], %[[VAL_61]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
-! CHECK: fir.result %[[VAL_80]] : !fir.array<?x!fir.char<1,10>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_53]], %[[VAL_81:.*]] to %[[VAL_10]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: fir.result %[[VAL_10]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_19]], %[[VAL_82:.*]] : i1, !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: } else {
-! CHECK: %[[VAL_83:.*]] = arith.constant true
-! CHECK: %[[VAL_84:.*]] = fir.allocmem !fir.array<?x!fir.char<1,10>>, %[[VAL_6]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_85:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_86:.*]] = fir.array_load %[[VAL_84]](%[[VAL_85]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
-! CHECK: %[[VAL_87:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_88:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_89:.*]] = arith.subi %[[VAL_6]], %[[VAL_87]] : index
-! CHECK: %[[VAL_90:.*]] = fir.do_loop %[[VAL_91:.*]] = %[[VAL_88]] to %[[VAL_89]] step %[[VAL_87]] unordered iter_args(%[[VAL_92:.*]] = %[[VAL_86]]) -> (!fir.array<?x!fir.char<1,10>>) {
-! CHECK: %[[VAL_93:.*]] = fir.array_access %[[VAL_8]], %[[VAL_91]] : (!fir.array<20x!fir.char<1,12>>, index) -> !fir.ref<!fir.char<1,12>>
-! CHECK: %[[VAL_94:.*]] = fir.array_access %[[VAL_92]], %[[VAL_91]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_95:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_96:.*]] = arith.cmpi slt, %[[VAL_95]], %[[VAL_3]] : index
-! CHECK: %[[VAL_97:.*]] = arith.select %[[VAL_96]], %[[VAL_95]], %[[VAL_3]] : index
-! CHECK: %[[VAL_98:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_99:.*]] = fir.convert %[[VAL_97]] : (index) -> i64
-! CHECK: %[[VAL_100:.*]] = arith.muli %[[VAL_98]], %[[VAL_99]] : i64
-! CHECK: %[[VAL_101:.*]] = arith.constant false
-! CHECK: %[[VAL_102:.*]] = fir.convert %[[VAL_94]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_103:.*]] = fir.convert %[[VAL_93]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_102]], %[[VAL_103]], %[[VAL_100]], %[[VAL_101]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_104:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_105:.*]] = arith.subi %[[VAL_95]], %[[VAL_104]] : index
-! CHECK: %[[VAL_106:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_107:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_108:.*]] = fir.insert_value %[[VAL_107]], %[[VAL_106]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_109:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_110:.*]] = %[[VAL_97]] to %[[VAL_105]] step %[[VAL_109]] {
-! CHECK: %[[VAL_111:.*]] = fir.convert %[[VAL_94]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
-! CHECK: %[[VAL_112:.*]] = fir.coordinate_of %[[VAL_111]], %[[VAL_110]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_108]] to %[[VAL_112]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_113:.*]] = fir.array_amend %[[VAL_92]], %[[VAL_94]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
-! CHECK: fir.result %[[VAL_113]] : !fir.array<?x!fir.char<1,10>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_86]], %[[VAL_114:.*]] to %[[VAL_84]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: fir.result %[[VAL_83]], %[[VAL_84]] : i1, !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_115:.*]]#0 {
-! CHECK: fir.if %[[VAL_13]] {
-! CHECK: fir.freemem %[[VAL_10]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
-! CHECK: }
-! CHECK: %[[VAL_116:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_117:.*]] = fir.embox %[[VAL_115]]#1(%[[VAL_116]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>
-! CHECK: fir.store %[[VAL_117]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
x = c
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_cst_char(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<20x!fir.char<1,12>>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 12 : index
+! CHECK: %[[VAL_6:.*]] = arith.constant 20 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_7]]) typeparams %[[VAL_5]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_cst_charEc"} : (!fir.ref<!fir.array<20x!fir.char<1,12>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.ref<!fir.array<20x!fir.char<1,12>>>, !fir.ref<!fir.array<20x!fir.char<1,12>>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_9]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_cst_charEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>, index, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>)
+! CHECK: hlfir.assign %[[VAL_8]]#0 to %[[VAL_10]]#0 realloc keep_lhs_len : !fir.ref<!fir.array<20x!fir.char<1,12>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_dyn_char(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_2:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine test_dyn_char(x, n, c)
integer :: n
character(n), allocatable :: x(:)
character(*) :: c(20)
-! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<20x!fir.char<1,?>>>
-! CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
-! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[VAL_7:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_8:.*]] = arith.cmpi sgt, %[[VAL_6]], %[[VAL_7]] : i32
-! CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_8]], %[[VAL_6]], %[[VAL_7]] : i32
-! CHECK: %[[VAL_10:.*]] = arith.constant 20 : index
-! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_4]](%[[VAL_11]]) typeparams %[[VAL_3]]#1 : (!fir.ref<!fir.array<20x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<20x!fir.char<1,?>>
-! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
-! CHECK: %[[VAL_14:.*]] = fir.box_addr %[[VAL_13]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,?>>>
-! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>) -> i64
-! CHECK: %[[VAL_16:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_17:.*]] = arith.cmpi ne, %[[VAL_15]], %[[VAL_16]] : i64
-! CHECK: %[[VAL_18:.*]]:2 = fir.if %[[VAL_17]] -> (i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>) {
-! CHECK: %[[VAL_19:.*]] = arith.constant false
-! CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_21:.*]]:3 = fir.box_dims %[[VAL_13]], %[[VAL_20]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_22:.*]] = arith.cmpi ne, %[[VAL_21]]#1, %[[VAL_10]] : index
-! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_22]], %[[VAL_19]] : i1
-! CHECK: %[[VAL_24:.*]] = fir.if %[[VAL_23]] -> (!fir.heap<!fir.array<?x!fir.char<1,?>>>) {
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK: %[[VAL_26:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%[[VAL_25]] : index), %[[VAL_10]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_27:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_28:.*]] = fir.array_load %[[VAL_26]](%[[VAL_27]]) typeparams %[[VAL_9]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_30:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_31:.*]] = arith.subi %[[VAL_10]], %[[VAL_29]] : index
-! CHECK: %[[VAL_32:.*]] = fir.do_loop %[[VAL_33:.*]] = %[[VAL_30]] to %[[VAL_31]] step %[[VAL_29]] unordered iter_args(%[[VAL_34:.*]] = %[[VAL_28]]) -> (!fir.array<?x!fir.char<1,?>>) {
-! CHECK: %[[VAL_35:.*]] = fir.array_access %[[VAL_12]], %[[VAL_33]] typeparams %[[VAL_3]]#1 : (!fir.array<20x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_36:.*]] = fir.array_access %[[VAL_34]], %[[VAL_33]] typeparams %[[VAL_9]] : (!fir.array<?x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK: %[[VAL_38:.*]] = arith.cmpi slt, %[[VAL_37]], %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_39:.*]] = arith.select %[[VAL_38]], %[[VAL_37]], %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_40:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_39]] : (index) -> i64
-! CHECK: %[[VAL_42:.*]] = arith.muli %[[VAL_40]], %[[VAL_41]] : i64
-! CHECK: %[[VAL_43:.*]] = arith.constant false
-! CHECK: %[[VAL_44:.*]] = fir.convert %[[VAL_36]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_44]], %[[VAL_45]], %[[VAL_42]], %[[VAL_43]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_46:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_47:.*]] = arith.subi %[[VAL_9]], %[[VAL_46]] : i32
-! CHECK: %[[VAL_48:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_49:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_50:.*]] = fir.insert_value %[[VAL_49]], %[[VAL_48]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_51:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_47]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_53:.*]] = %[[VAL_39]] to %[[VAL_52]] step %[[VAL_51]] {
-! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_36]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_53]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_50]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_56:.*]] = fir.array_amend %[[VAL_34]], %[[VAL_36]] : (!fir.array<?x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_56]] : !fir.array<?x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_28]], %[[VAL_57:.*]] to %[[VAL_26]] typeparams %[[VAL_9]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>, i32
-! CHECK: fir.result %[[VAL_26]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
-! CHECK: } else {
-! CHECK: %[[VAL_58:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_59:.*]] = fir.array_load %[[VAL_14]](%[[VAL_58]]) typeparams %[[VAL_9]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: %[[VAL_60:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_61:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_62:.*]] = arith.subi %[[VAL_10]], %[[VAL_60]] : index
-! CHECK: %[[VAL_63:.*]] = fir.do_loop %[[VAL_64:.*]] = %[[VAL_61]] to %[[VAL_62]] step %[[VAL_60]] unordered iter_args(%[[VAL_65:.*]] = %[[VAL_59]]) -> (!fir.array<?x!fir.char<1,?>>) {
-! CHECK: %[[VAL_66:.*]] = fir.array_access %[[VAL_12]], %[[VAL_64]] typeparams %[[VAL_3]]#1 : (!fir.array<20x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_67:.*]] = fir.array_access %[[VAL_65]], %[[VAL_64]] typeparams %[[VAL_9]] : (!fir.array<?x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK: %[[VAL_69:.*]] = arith.cmpi slt, %[[VAL_68]], %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_70:.*]] = arith.select %[[VAL_69]], %[[VAL_68]], %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_71:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_70]] : (index) -> i64
-! CHECK: %[[VAL_73:.*]] = arith.muli %[[VAL_71]], %[[VAL_72]] : i64
-! CHECK: %[[VAL_74:.*]] = arith.constant false
-! CHECK: %[[VAL_75:.*]] = fir.convert %[[VAL_67]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_76:.*]] = fir.convert %[[VAL_66]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_75]], %[[VAL_76]], %[[VAL_73]], %[[VAL_74]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_77:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_78:.*]] = arith.subi %[[VAL_9]], %[[VAL_77]] : i32
-! CHECK: %[[VAL_79:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_80:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_81:.*]] = fir.insert_value %[[VAL_80]], %[[VAL_79]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_82:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_83:.*]] = fir.convert %[[VAL_78]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_84:.*]] = %[[VAL_70]] to %[[VAL_83]] step %[[VAL_82]] {
-! CHECK: %[[VAL_85:.*]] = fir.convert %[[VAL_67]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_86:.*]] = fir.coordinate_of %[[VAL_85]], %[[VAL_84]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_81]] to %[[VAL_86]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_87:.*]] = fir.array_amend %[[VAL_65]], %[[VAL_67]] : (!fir.array<?x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_87]] : !fir.array<?x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_59]], %[[VAL_88:.*]] to %[[VAL_14]] typeparams %[[VAL_9]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>, i32
-! CHECK: fir.result %[[VAL_14]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_23]], %[[VAL_89:.*]] : i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>
-! CHECK: } else {
-! CHECK: %[[VAL_90:.*]] = arith.constant true
-! CHECK: %[[VAL_91:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK: %[[VAL_92:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%[[VAL_91]] : index), %[[VAL_10]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_93:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_94:.*]] = fir.array_load %[[VAL_92]](%[[VAL_93]]) typeparams %[[VAL_9]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: %[[VAL_95:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_96:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_97:.*]] = arith.subi %[[VAL_10]], %[[VAL_95]] : index
-! CHECK: %[[VAL_98:.*]] = fir.do_loop %[[VAL_99:.*]] = %[[VAL_96]] to %[[VAL_97]] step %[[VAL_95]] unordered iter_args(%[[VAL_100:.*]] = %[[VAL_94]]) -> (!fir.array<?x!fir.char<1,?>>) {
-! CHECK: %[[VAL_101:.*]] = fir.array_access %[[VAL_12]], %[[VAL_99]] typeparams %[[VAL_3]]#1 : (!fir.array<20x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_102:.*]] = fir.array_access %[[VAL_100]], %[[VAL_99]] typeparams %[[VAL_9]] : (!fir.array<?x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_103:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK: %[[VAL_104:.*]] = arith.cmpi slt, %[[VAL_103]], %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_105:.*]] = arith.select %[[VAL_104]], %[[VAL_103]], %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_106:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_107:.*]] = fir.convert %[[VAL_105]] : (index) -> i64
-! CHECK: %[[VAL_108:.*]] = arith.muli %[[VAL_106]], %[[VAL_107]] : i64
-! CHECK: %[[VAL_109:.*]] = arith.constant false
-! CHECK: %[[VAL_110:.*]] = fir.convert %[[VAL_102]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_111:.*]] = fir.convert %[[VAL_101]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_110]], %[[VAL_111]], %[[VAL_108]], %[[VAL_109]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_112:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_113:.*]] = arith.subi %[[VAL_9]], %[[VAL_112]] : i32
-! CHECK: %[[VAL_114:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_115:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_116:.*]] = fir.insert_value %[[VAL_115]], %[[VAL_114]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_117:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_118:.*]] = fir.convert %[[VAL_113]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_119:.*]] = %[[VAL_105]] to %[[VAL_118]] step %[[VAL_117]] {
-! CHECK: %[[VAL_120:.*]] = fir.convert %[[VAL_102]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_121:.*]] = fir.coordinate_of %[[VAL_120]], %[[VAL_119]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_116]] to %[[VAL_121]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_122:.*]] = fir.array_amend %[[VAL_100]], %[[VAL_102]] : (!fir.array<?x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_122]] : !fir.array<?x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_94]], %[[VAL_123:.*]] to %[[VAL_92]] typeparams %[[VAL_9]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>, i32
-! CHECK: fir.result %[[VAL_90]], %[[VAL_92]] : i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_124:.*]]#0 {
-! CHECK: %[[VAL_125:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK: fir.if %[[VAL_17]] {
-! CHECK: fir.freemem %[[VAL_14]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
-! CHECK: }
-! CHECK: %[[VAL_126:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_127:.*]] = fir.embox %[[VAL_124]]#1(%[[VAL_126]]) typeparams %[[VAL_125]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>
-! CHECK: fir.store %[[VAL_127]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
x = c
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_dyn_char(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<20x!fir.char<1,?>>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 20 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_7]]) typeparams %[[VAL_4]]#1 dummy_scope %[[VAL_3]] {uniq_name = "_QMalloc_assignFtest_dyn_charEc"} : (!fir.ref<!fir.array<20x!fir.char<1,?>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.box<!fir.array<20x!fir.char<1,?>>>, !fir.ref<!fir.array<20x!fir.char<1,?>>>)
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_3]] {uniq_name = "_QMalloc_assignFtest_dyn_charEn"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<i32>
+! CHECK: %[[VAL_11:.*]] = arith.constant 0 : i32
+! CHECK: %[[VAL_12:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_11]] : i32
+! CHECK: %[[VAL_13:.*]] = arith.select %[[VAL_12]], %[[VAL_10]], %[[VAL_11]] : i32
+! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_13]] dummy_scope %[[VAL_3]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_dyn_charEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, i32, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>)
+! CHECK: hlfir.assign %[[VAL_8]]#0 to %[[VAL_14]]#0 realloc keep_lhs_len : !fir.box<!fir.array<20x!fir.char<1,?>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_derived_with_init
subroutine test_derived_with_init(x, y)
type t
integer, allocatable :: a(:)
@@ -1045,21 +292,15 @@ subroutine test_derived_with_init(x, y)
! during the automatic allocation (setting its rank and allocation
! status) before it is assigned with the component of `y`
x = y
-! CHECK: fir.if %{{.*}} {
-! CHECK: %[[VAL_11:.*]] = fir.allocmem !fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}> {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_12:.*]] = fir.embox %[[VAL_11]] : (!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>) -> !fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>
-! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_12]] : (!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAInitialize(%[[VAL_15]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32) -> ()
-! CHECK: fir.result %[[VAL_11]] : !fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>
-! CHECK: } else {
-! CHECK: fir.result %{{.*}} : !fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>
-! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_derived_with_init(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>> {fir.bindc_name = "y"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_derived_with_initEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>, !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>)
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMalloc_assignFtest_derived_with_initEy"} : (!fir.ref<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>, !fir.dscope) -> (!fir.ref<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>, !fir.ref<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>)
+! CHECK: hlfir.assign %[[VAL_10]]#0 to %[[VAL_9]]#0 realloc : !fir.ref<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>, !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_vector_subscript(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "x"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "y"},
-! CHECK-SAME: %[[VAL_2:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "v"}) {
subroutine test_vector_subscript(x, y, v)
! Test that the new shape is computed correctly in presence of
! vector subscripts on the RHS and that it is used to allocate
@@ -1067,94 +308,18 @@ subroutine test_vector_subscript(x, y, v)
integer, allocatable :: x(:)
integer :: y(:), v(:)
x = y(v)
-! CHECK: %[[VAL_3:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_4]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_6]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_2]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
-! CHECK: %[[VAL_9:.*]] = arith.cmpi sgt, %[[VAL_7]]#1, %[[VAL_5]]#1 : index
-! CHECK: %[[VAL_10:.*]] = arith.select %[[VAL_9]], %[[VAL_5]]#1, %[[VAL_7]]#1 : index
-! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
-! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
-! CHECK: %[[VAL_13:.*]] = fir.box_addr %[[VAL_12]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.heap<!fir.array<?xi32>>) -> i64
-! CHECK: %[[VAL_15:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_16:.*]] = arith.cmpi ne, %[[VAL_14]], %[[VAL_15]] : i64
-! CHECK: %[[VAL_17:.*]]:2 = fir.if %[[VAL_16]] -> (i1, !fir.heap<!fir.array<?xi32>>) {
-! CHECK: %[[VAL_18:.*]] = arith.constant false
-! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_20:.*]]:3 = fir.box_dims %[[VAL_12]], %[[VAL_19]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_21:.*]] = arith.cmpi ne, %[[VAL_20]]#1, %[[VAL_10]] : index
-! CHECK: %[[VAL_22:.*]] = arith.select %[[VAL_21]], %[[VAL_21]], %[[VAL_18]] : i1
-! CHECK: %[[VAL_23:.*]] = fir.if %[[VAL_22]] -> (!fir.heap<!fir.array<?xi32>>) {
-! CHECK: %[[VAL_24:.*]] = fir.allocmem !fir.array<?xi32>, %[[VAL_10]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_24]](%[[VAL_25]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.array<?xi32>
-! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_10]], %[[VAL_27]] : index
-! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_26]]) -> (!fir.array<?xi32>) {
-! CHECK: %[[VAL_33:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_31]] : (!fir.array<?xi32>, index) -> i32
-! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i32) -> index
-! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_34]], %[[VAL_3]] : index
-! CHECK: %[[VAL_36:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_35]] : (!fir.array<?xi32>, index) -> i32
-! CHECK: %[[VAL_37:.*]] = fir.array_update %[[VAL_32]], %[[VAL_36]], %[[VAL_31]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
-! CHECK: fir.result %[[VAL_37]] : !fir.array<?xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_26]], %[[VAL_38:.*]] to %[[VAL_24]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.heap<!fir.array<?xi32>>
-! CHECK: fir.result %[[VAL_24]] : !fir.heap<!fir.array<?xi32>>
-! CHECK: } else {
-! CHECK: %[[VAL_39:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_40:.*]] = fir.array_load %[[VAL_13]](%[[VAL_39]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.array<?xi32>
-! CHECK: %[[VAL_41:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_42:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_43:.*]] = arith.subi %[[VAL_10]], %[[VAL_41]] : index
-! CHECK: %[[VAL_44:.*]] = fir.do_loop %[[VAL_45:.*]] = %[[VAL_42]] to %[[VAL_43]] step %[[VAL_41]] unordered iter_args(%[[VAL_46:.*]] = %[[VAL_40]]) -> (!fir.array<?xi32>) {
-! CHECK: %[[VAL_47:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_45]] : (!fir.array<?xi32>, index) -> i32
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_47]] : (i32) -> index
-! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_48]], %[[VAL_3]] : index
-! CHECK: %[[VAL_50:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_49]] : (!fir.array<?xi32>, index) -> i32
-! CHECK: %[[VAL_51:.*]] = fir.array_update %[[VAL_46]], %[[VAL_50]], %[[VAL_45]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
-! CHECK: fir.result %[[VAL_51]] : !fir.array<?xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_40]], %[[VAL_52:.*]] to %[[VAL_13]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.heap<!fir.array<?xi32>>
-! CHECK: fir.result %[[VAL_13]] : !fir.heap<!fir.array<?xi32>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_22]], %[[VAL_53:.*]] : i1, !fir.heap<!fir.array<?xi32>>
-! CHECK: } else {
-! CHECK: %[[VAL_54:.*]] = arith.constant true
-! CHECK: %[[VAL_55:.*]] = fir.allocmem !fir.array<?xi32>, %[[VAL_10]] {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_56:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_57:.*]] = fir.array_load %[[VAL_55]](%[[VAL_56]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.array<?xi32>
-! CHECK: %[[VAL_58:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_59:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_60:.*]] = arith.subi %[[VAL_10]], %[[VAL_58]] : index
-! CHECK: %[[VAL_61:.*]] = fir.do_loop %[[VAL_62:.*]] = %[[VAL_59]] to %[[VAL_60]] step %[[VAL_58]] unordered iter_args(%[[VAL_63:.*]] = %[[VAL_57]]) -> (!fir.array<?xi32>) {
-! CHECK: %[[VAL_64:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_62]] : (!fir.array<?xi32>, index) -> i32
-! CHECK: %[[VAL_65:.*]] = fir.convert %[[VAL_64]] : (i32) -> index
-! CHECK: %[[VAL_66:.*]] = arith.subi %[[VAL_65]], %[[VAL_3]] : index
-! CHECK: %[[VAL_67:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_66]] : (!fir.array<?xi32>, index) -> i32
-! CHECK: %[[VAL_68:.*]] = fir.array_update %[[VAL_63]], %[[VAL_67]], %[[VAL_62]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
-! CHECK: fir.result %[[VAL_68]] : !fir.array<?xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_57]], %[[VAL_69:.*]] to %[[VAL_55]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.heap<!fir.array<?xi32>>
-! CHECK: fir.result %[[VAL_54]], %[[VAL_55]] : i1, !fir.heap<!fir.array<?xi32>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_70:.*]]#0 {
-! CHECK: fir.if %[[VAL_16]] {
-! CHECK: fir.freemem %[[VAL_13]] : !fir.heap<!fir.array<?xi32>>
-! CHECK: }
-! CHECK: %[[VAL_71:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_72:.*]] = fir.embox %[[VAL_70]]#1(%[[VAL_71]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
-! CHECK: fir.store %[[VAL_72]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_vector_subscript(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "y"},
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "v"}) {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %[[VAL_3]] {uniq_name = "_QMalloc_assignFtest_vector_subscriptEv"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_3]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_vector_subscriptEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_3]] {uniq_name = "_QMalloc_assignFtest_vector_subscriptEy"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
+! CHECK: %[[VAL_16:.*]] = hlfir.elemental %{{.*}} unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
+! CHECK: hlfir.assign %[[VAL_16]] to %[[VAL_5]]#0 realloc : !hlfir.expr<?xi32>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
-! CHECK-LABEL: func @_QMalloc_assignPtest_both_sides_with_elemental_call(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>> {fir.bindc_name = "x"}) {
subroutine test_both_sides_with_elemental_call(x)
interface
elemental real function elt(x)
@@ -1163,89 +328,28 @@ end function elt
end interface
real, allocatable :: x(:)
x = elt(x)
-! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_4:.*]] = fir.box_addr %[[VAL_1]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
-! CHECK: %[[VAL_5:.*]] = fir.shape_shift %[[VAL_3]]#0, %[[VAL_3]]#1 : (index, index) -> !fir.shapeshift<1>
-! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-! CHECK: %[[VAL_7:.*]] = fir.box_addr %[[VAL_6]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.heap<!fir.array<?xf32>>) -> i64
-! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_10:.*]] = arith.cmpi ne, %[[VAL_8]], %[[VAL_9]] : i64
-! CHECK: %[[VAL_11:.*]]:2 = fir.if %[[VAL_10]] -> (i1, !fir.heap<!fir.array<?xf32>>) {
-! CHECK: %[[VAL_12:.*]] = arith.constant false
-! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_14:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_13]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
-! CHECK: %[[VAL_15:.*]] = arith.cmpi ne, %[[VAL_14]]#1, %[[VAL_3]]#1 : index
-! CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_15]], %[[VAL_12]] : i1
-! CHECK: %[[VAL_17:.*]] = fir.if %[[VAL_16]] -> (!fir.heap<!fir.array<?xf32>>) {
-! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.array<?xf32>, %[[VAL_3]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_18]](%[[VAL_19]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_21]] : index
-! CHECK: %[[VAL_24:.*]] = fir.do_loop %[[VAL_25:.*]] = %[[VAL_22]] to %[[VAL_23]] step %[[VAL_21]] unordered iter_args(%[[VAL_26:.*]] = %[[VAL_20]]) -> (!fir.array<?xf32>) {
-! CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_25]], %[[VAL_3]]#0 : index
-! CHECK: %[[VAL_28:.*]] = fir.array_coor %[[VAL_4]](%[[VAL_5]]) %[[VAL_27]] : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
-! CHECK: %[[VAL_29:.*]] = fir.call @_QPelt(%[[VAL_28]]) {{.*}}: (!fir.ref<f32>) -> f32
-! CHECK: %[[VAL_30:.*]] = fir.array_update %[[VAL_26]], %[[VAL_29]], %[[VAL_25]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
-! CHECK: fir.result %[[VAL_30]] : !fir.array<?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_20]], %[[VAL_31:.*]] to %[[VAL_18]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>>
-! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_32:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_33:.*]] = fir.array_load %[[VAL_7]](%[[VAL_32]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_35:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_34]] : index
-! CHECK: %[[VAL_37:.*]] = fir.do_loop %[[VAL_38:.*]] = %[[VAL_35]] to %[[VAL_36]] step %[[VAL_34]] unordered iter_args(%[[VAL_39:.*]] = %[[VAL_33]]) -> (!fir.array<?xf32>) {
-! CHECK: %[[VAL_40:.*]] = arith.addi %[[VAL_38]], %[[VAL_3]]#0 : index
-! CHECK: %[[VAL_41:.*]] = fir.array_coor %[[VAL_4]](%[[VAL_5]]) %[[VAL_40]] : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
-! CHECK: %[[VAL_42:.*]] = fir.call @_QPelt(%[[VAL_41]]) {{.*}}: (!fir.ref<f32>) -> f32
-! CHECK: %[[VAL_43:.*]] = fir.array_update %[[VAL_39]], %[[VAL_42]], %[[VAL_38]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
-! CHECK: fir.result %[[VAL_43]] : !fir.array<?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_33]], %[[VAL_44:.*]] to %[[VAL_7]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>>
-! CHECK: fir.result %[[VAL_7]] : !fir.heap<!fir.array<?xf32>>
-! CHECK: }
-! CHECK: fir.result %[[VAL_16]], %[[VAL_45:.*]] : i1, !fir.heap<!fir.array<?xf32>>
-! CHECK: } else {
-! CHECK: %[[VAL_46:.*]] = arith.constant true
-! CHECK: %[[VAL_47:.*]] = fir.allocmem !fir.array<?xf32>, %[[VAL_3]]#1 {uniq_name = ".auto.alloc"}
-! CHECK: %[[VAL_48:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_49:.*]] = fir.array_load %[[VAL_47]](%[[VAL_48]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_50:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_51:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_52:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_50]] : index
-! CHECK: %[[VAL_53:.*]] = fir.do_loop %[[VAL_54:.*]] = %[[VAL_51]] to %[[VAL_52]] step %[[VAL_50]] unordered iter_args(%[[VAL_55:.*]] = %[[VAL_49]]) -> (!fir.array<?xf32>) {
-! CHECK: %[[VAL_56:.*]] = arith.addi %[[VAL_54]], %[[VAL_3]]#0 : index
-! CHECK: %[[VAL_57:.*]] = fir.array_coor %[[VAL_4]](%[[VAL_5]]) %[[VAL_56]] : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
-! CHECK: %[[VAL_58:.*]] = fir.call @_QPelt(%[[VAL_57]]) {{.*}}: (!fir.ref<f32>) -> f32
-! CHECK: %[[VAL_59:.*]] = fir.array_update %[[VAL_55]], %[[VAL_58]], %[[VAL_54]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
-! CHECK: fir.result %[[VAL_59]] : !fir.array<?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_49]], %[[VAL_60:.*]] to %[[VAL_47]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>>
-! CHECK: fir.result %[[VAL_46]], %[[VAL_47]] : i1, !fir.heap<!fir.array<?xf32>>
-! CHECK: }
-! CHECK: fir.if %[[VAL_61:.*]]#0 {
-! CHECK: fir.if %[[VAL_10]] {
-! CHECK: fir.freemem %[[VAL_7]] : !fir.heap<!fir.array<?xf32>>
-! CHECK: }
-! CHECK: %[[VAL_62:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_63:.*]] = fir.embox %[[VAL_61]]#1(%[[VAL_62]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xf32>>>
-! CHECK: fir.store %[[VAL_63]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-! CHECK: }
-! CHECK: return
-! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMalloc_assignPtest_both_sides_with_elemental_call(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMalloc_assignFtest_both_sides_with_elemental_callEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>)
+! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_4]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xf32> {
+! CHECK: ^bb0(%[[VAL_8:.*]]: index):
+! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_9]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_10]]#0, %[[VAL_11]] : index
+! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_8]], %[[VAL_12]] : index
+! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_3]] (%[[VAL_13]]) : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> !fir.ref<f32>
+! CHECK: %[[VAL_15:.*]] = fir.call @_QPelt(%[[VAL_14]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.ref<f32>) -> f32
+! CHECK: hlfir.yield_element %[[VAL_15]] : f32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_7]] to %[[VAL_2]]#0 realloc : !hlfir.expr<?xf32>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-! CHECK: fir.global linkonce @[[error_message]] constant : !fir.char<1,76> {
-! CHECK: %[[msg:.*]] = fir.string_lit "array left hand side must be allocated when the right hand side is a scalar\00"(76) : !fir.char<1,76>
-! CHECK: fir.has_value %[[msg:.*]] : !fir.char<1,76>
-! CHECK: }
end module
diff --git a/flang/test/Lower/array-character.f90 b/flang/test/Lower/array-character.f90
index 53adc5c02958c..62664fa92f8f7 100644
--- a/flang/test/Lower/array-character.f90
+++ b/flang/test/Lower/array-character.f90
@@ -1,178 +1,113 @@
-! RUN: bbc -hlfir=false -fwrapv %s -o - | fir-opt --canonicalize --cse | FileCheck %s
+! RUN: bbc -emit-hlfir -fwrapv %s -o - | FileCheck %s
-! CHECK-LABEL: func @_QPissue(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine issue(c1, c2)
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 32 : i8
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 3 : index
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 4 : index
- ! CHECK-DAG: %[[VAL_6:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_7:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_8:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<3x!fir.char<1,4>>>
- ! CHECK: %[[VAL_10:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<3x!fir.char<1,?>>>
- ! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
- ! CHECK: cf.br ^bb1(%[[VAL_6]], %[[VAL_4]] : index, index)
- ! CHECK: ^bb1(%[[VAL_13:.*]]: index, %[[VAL_14:.*]]: index):
- ! CHECK: %[[VAL_15:.*]] = arith.cmpi sgt, %[[VAL_14]], %[[VAL_6]] : index
- ! CHECK: cf.cond_br %[[VAL_15]], ^bb2, ^bb6
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_13]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_17:.*]] = fir.array_coor %[[VAL_11]](%[[VAL_12]]) %[[VAL_16]] typeparams %[[VAL_10]]#1 : (!fir.ref<!fir.array<3x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_18:.*]] = fir.array_coor %[[VAL_9]](%[[VAL_12]]) %[[VAL_16]] : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,4>>
- ! CHECK: %[[VAL_19:.*]] = arith.cmpi sgt, %[[VAL_10]]#1, %[[VAL_5]] : index
- ! CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_19]], %[[VAL_5]], %[[VAL_10]]#1 : index
- ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (index) -> i64
- ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_17]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_22]], %[[VAL_23]], %[[VAL_21]], %[[VAL_2]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_24:.*]] = fir.undefined !fir.char<1>
- ! CHECK: %[[VAL_25:.*]] = fir.insert_value %[[VAL_24]], %[[VAL_3]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
- ! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_5]], %[[VAL_20]] : index
- ! CHECK: cf.br ^bb3(%[[VAL_20]], %[[VAL_26]] : index, index)
- ! CHECK: ^bb3(%[[VAL_27:.*]]: index, %[[VAL_28:.*]]: index):
- ! CHECK: %[[VAL_29:.*]] = arith.cmpi sgt, %[[VAL_28]], %[[VAL_6]] : index
- ! CHECK: cf.cond_br %[[VAL_29]], ^bb4, ^bb5
- ! CHECK: ^bb4:
- ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<4x!fir.char<1>>>
- ! CHECK: %[[VAL_31:.*]] = fir.coordinate_of %[[VAL_30]], %[[VAL_27]] : (!fir.ref<!fir.array<4x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
- ! CHECK: fir.store %[[VAL_25]] to %[[VAL_31]] : !fir.ref<!fir.char<1>>
- ! CHECK: %[[VAL_32:.*]] = arith.addi %[[VAL_27]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_28]], %[[VAL_7]] : index
- ! CHECK: cf.br ^bb3(%[[VAL_32]], %[[VAL_33]] : index, index)
- ! CHECK: ^bb5:
- ! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_14]], %[[VAL_7]] : index
- ! CHECK: cf.br ^bb1(%[[VAL_16]], %[[VAL_34]] : index, index)
character(4) :: c1(3)
character(*) :: c2(3)
c1 = c2
- ! CHECK: return
- ! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QPissue(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<3x!fir.char<1,4>>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_6:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_7]]) typeparams %[[VAL_5]] dummy_scope %[[VAL_2]] {uniq_name = "_QFissueEc1"} : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.ref<!fir.array<3x!fir.char<1,4>>>)
+! CHECK: %[[VAL_9:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<3x!fir.char<1,?>>>
+! CHECK: %[[VAL_11:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_11]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_10]](%[[VAL_12]]) typeparams %[[VAL_9]]#1 dummy_scope %[[VAL_2]] {uniq_name = "_QFissueEc2"} : (!fir.ref<!fir.array<3x!fir.char<1,?>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.box<!fir.array<3x!fir.char<1,?>>>, !fir.ref<!fir.array<3x!fir.char<1,?>>>)
+! CHECK: hlfir.assign %[[VAL_13]]#0 to %[[VAL_8]]#0 : !fir.box<!fir.array<3x!fir.char<1,?>>>, !fir.ref<!fir.array<3x!fir.char<1,4>>>
-! CHECK-LABEL: func @_QQmain() attributes {fir.bindc_name = "p"} {
program p
- ! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 4 : index
- ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 3 : index
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 6 : i32
- ! CHECK: %[[VAL_5:.*]] = fir.alloca !fir.array<3x!fir.char<1,4>> {bindc_name = "c1", uniq_name = "_QFEc1"}
- ! CHECK: %[[VAL_6:.*]] = fir.address_of(@_QFEc2) : !fir.ref<!fir.array<3x!fir.char<1,4>>>
- ! CHECK: %[[VAL_7:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,
- ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_9:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_2]], %[[VAL_8]], %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_11:.*]] = fir.embox %[[VAL_6]](%[[VAL_10]]) : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>) -> !fir.box<!fir.array<3x!fir.char<1,4>>>
- ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.box<!fir.array<3x!fir.char<1,4>>>) -> !fir.box<none>
- ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_9]], %[[VAL_12]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- ! CHECK: %[[VAL_14:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_9]]) {{.*}}: (!fir.ref<i8>) -> i32
- ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.array<3x!fir.char<1,4>>>) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_15]], %[[VAL_0]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
- ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_6]] : (!fir.ref<!fir.array<3x!fir.char<1,4>>>) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_18:.*]] = fir.emboxchar %[[VAL_17]], %[[VAL_0]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.call @_QPissue(%[[VAL_16]], %[[VAL_18]]) {{.*}}: (!fir.boxchar<1>, !fir.boxchar<1>) -> ()
- ! CHECK: %[[VAL_19:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_2]], %[[VAL_8]], %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_20:.*]] = fir.embox %[[VAL_5]](%[[VAL_10]]) : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>) -> !fir.box<!fir.array<3x!fir.char<1,4>>>
- ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (!fir.box<!fir.array<3x!fir.char<1,4>>>) -> !fir.box<none>
- ! CHECK: %[[VAL_22:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_19]], %[[VAL_21]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- ! CHECK: %[[VAL_23:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_19]]) {{.*}}: (!fir.ref<i8>) -> i32
- ! CHECK: fir.call @_QPcharlit() {{.*}}: () -> ()
character(4) :: c1(3)
character(4) :: c2(3) = ["abcd", " ", " "]
print *, c2
call issue(c1, c2)
print *, c1
call charlit
- ! CHECK: return
- ! CHECK: }
end program p
-! CHECK-LABEL: func @_QPcharlit() {
+! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "p"} {
+! CHECK: %[[VAL_0:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_1:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.array<3x!fir.char<1,4>> {bindc_name = "c1", uniq_name = "_QFEc1"}
+! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_2]](%[[VAL_3]]) typeparams %[[VAL_0]] {uniq_name = "_QFEc1"} : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.ref<!fir.array<3x!fir.char<1,4>>>)
+! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QFEc2) : !fir.ref<!fir.array<3x!fir.char<1,4>>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_7:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_8]]) typeparams %[[VAL_6]] {uniq_name = "_QFEc2"} : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.ref<!fir.array<3x!fir.char<1,4>>>)
+! CHECK: %[[VAL_10:.*]] = arith.constant 6 : i32
+! CHECK: %[[VAL_14:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_10]], %{{.*}}, %{{.*}}) fastmath<contract> : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
+! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_16:.*]] = fir.embox %[[VAL_9]]#1(%[[VAL_15]]) : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>) -> !fir.box<!fir.array<3x!fir.char<1,4>>>
+! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (!fir.box<!fir.array<3x!fir.char<1,4>>>) -> !fir.box<none>
+! CHECK: %[[VAL_18:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_14]], %[[VAL_17]]) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>) -> i1
+! CHECK: %[[VAL_19:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_14]]) fastmath<contract> : (!fir.ref<i8>) -> i32
+! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_4]]#1 : (!fir.ref<!fir.array<3x!fir.char<1,4>>>) -> !fir.ref<!fir.char<1,4>>
+! CHECK: %[[VAL_21:.*]] = fir.emboxchar %[[VAL_20]], %[[VAL_0]] : (!fir.ref<!fir.char<1,4>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_9]]#1 : (!fir.ref<!fir.array<3x!fir.char<1,4>>>) -> !fir.ref<!fir.char<1,4>>
+! CHECK: %[[VAL_23:.*]] = fir.emboxchar %[[VAL_22]], %[[VAL_6]] : (!fir.ref<!fir.char<1,4>>, index) -> !fir.boxchar<1>
+! CHECK: fir.call @_QPissue(%[[VAL_21]], %[[VAL_23]]) fastmath<contract> : (!fir.boxchar<1>, !fir.boxchar<1>) -> ()
+! CHECK: %[[VAL_24:.*]] = arith.constant 6 : i32
+! CHECK: %[[VAL_28:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_24]], %{{.*}}, %{{.*}}) fastmath<contract> : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
+! CHECK: %[[VAL_29:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_30:.*]] = fir.embox %[[VAL_4]]#1(%[[VAL_29]]) : (!fir.ref<!fir.array<3x!fir.char<1,4>>>, !fir.shape<1>) -> !fir.box<!fir.array<3x!fir.char<1,4>>>
+! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_30]] : (!fir.box<!fir.array<3x!fir.char<1,4>>>) -> !fir.box<none>
+! CHECK: %[[VAL_32:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_28]], %[[VAL_31]]) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>) -> i1
+! CHECK: %[[VAL_33:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_28]]) fastmath<contract> : (!fir.ref<i8>) -> i32
+! CHECK: fir.call @_QPcharlit() fastmath<contract> : () -> ()
+
subroutine charlit
- ! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 6 : i32
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 3 : index
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 4 : index
- ! CHECK-DAG: %[[VAL_6:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_7:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_8:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,
- ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_10:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_0]], %[[VAL_9]], %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_11:.*]] = fir.address_of(@_QQro.4x3xc1.0) : !fir.ref<!fir.array<4x!fir.char<1,3>>>
- ! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_13:.*]] = fir.allocmem !fir.array<4x!fir.char<1,3>>
- ! CHECK: cf.br ^bb1(%[[VAL_6]], %[[VAL_5]] : index, index)
- ! CHECK: ^bb1(%[[VAL_14:.*]]: index, %[[VAL_15:.*]]: index):
- ! CHECK: %[[VAL_16:.*]] = arith.cmpi sgt, %[[VAL_15]], %[[VAL_6]] : index
- ! CHECK: cond_br %[[VAL_16]], ^bb2, ^bb3
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_17:.*]] = arith.addi %[[VAL_14]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_18:.*]] = fir.array_coor %[[VAL_11]](%[[VAL_12]]) %[[VAL_17]] : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,3>>
- ! CHECK: %[[VAL_19:.*]] = fir.array_coor %[[VAL_13]](%[[VAL_12]]) %[[VAL_17]] : (!fir.heap<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,3>>
- ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
- ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_21]], %[[VAL_22]], %[[VAL_20]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_15]], %[[VAL_7]] : index
- ! CHECK: cf.br ^bb1(%[[VAL_17]], %[[VAL_23]] : index, index)
- ! CHECK: ^bb3:
- ! CHECK: %[[VAL_24:.*]] = fir.embox %[[VAL_13]](%[[VAL_12]]) : (!fir.heap<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.char<1,3>>>
- ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (!fir.box<!fir.array<4x!fir.char<1,3>>>) -> !fir.box<none>
- ! CHECK: %[[VAL_26:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_10]], %[[VAL_25]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- ! CHECK: fir.freemem %[[VAL_13]]
- ! CHECK: %[[VAL_27:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_10]]) {{.*}}: (!fir.ref<i8>) -> i32
- ! CHECK: %[[VAL_28:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_0]], %[[VAL_9]], %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_29:.*]] = fir.allocmem !fir.array<4x!fir.char<1,3>>
- ! CHECK: br ^bb4(%[[VAL_6]], %[[VAL_5]] : index, index)
- ! CHECK: ^bb4(%[[VAL_30:.*]]: index, %[[VAL_31:.*]]: index):
- ! CHECK: %[[VAL_32:.*]] = arith.cmpi sgt, %[[VAL_31]], %[[VAL_6]] : index
- ! CHECK: cond_br %[[VAL_32]], ^bb5, ^bb6
- ! CHECK: ^bb5:
- ! CHECK: %[[VAL_33:.*]] = arith.addi %[[VAL_30]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_34:.*]] = fir.array_coor %[[VAL_11]](%[[VAL_12]]) %[[VAL_33]] : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,3>>
- ! CHECK: %[[VAL_35:.*]] = fir.array_coor %[[VAL_29]](%[[VAL_12]]) %[[VAL_33]] : (!fir.heap<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,3>>
- ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
- ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_37]], %[[VAL_38]], %[[VAL_36]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_39:.*]] = arith.subi %[[VAL_31]], %[[VAL_7]] : index
- ! CHECK: br ^bb4(%[[VAL_33]], %[[VAL_39]] : index, index)
- ! CHECK: ^bb6:
- ! CHECK: %[[VAL_40:.*]] = fir.embox %[[VAL_29]](%[[VAL_12]]) : (!fir.heap<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.char<1,3>>>
- ! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_40]] : (!fir.box<!fir.array<4x!fir.char<1,3>>>) -> !fir.box<none>
- ! CHECK: %[[VAL_42:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_28]], %[[VAL_41]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- ! CHECK: fir.freemem %[[VAL_29]] : !fir.heap<!fir.array<4x!fir.char<1,3>>>
- ! CHECK: %[[VAL_43:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_28]]) {{.*}}: (!fir.ref<i8>) -> i32
- ! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_0]], %[[VAL_9]], %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_45:.*]] = fir.allocmem !fir.array<4x!fir.char<1,3>>
- ! CHECK: br ^bb7(%[[VAL_6]], %[[VAL_5]] : index, index)
- ! CHECK: ^bb7(%[[VAL_46:.*]]: index, %[[VAL_47:.*]]: index):
- ! CHECK: %[[VAL_48:.*]] = arith.cmpi sgt, %[[VAL_47]], %[[VAL_6]] : index
- ! CHECK: cond_br %[[VAL_48]], ^bb8, ^bb9
- ! CHECK: ^bb8:
- ! CHECK: %[[VAL_49:.*]] = arith.addi %[[VAL_46]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_50:.*]] = fir.array_coor %[[VAL_11]](%[[VAL_12]]) %[[VAL_49]] : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,3>>
- ! CHECK: %[[VAL_51:.*]] = fir.array_coor %[[VAL_45]](%[[VAL_12]]) %[[VAL_49]] : (!fir.heap<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,3>>
- ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
- ! CHECK: %[[VAL_53:.*]] = fir.convert %[[VAL_51]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_50]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_53]], %[[VAL_54]], %[[VAL_52]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_55:.*]] = arith.subi %[[VAL_47]], %[[VAL_7]] : index
- ! CHECK: br ^bb7(%[[VAL_49]], %[[VAL_55]] : index, index)
- ! CHECK: ^bb9:
- ! CHECK: %[[VAL_56:.*]] = fir.embox %[[VAL_45]](%[[VAL_12]]) : (!fir.heap<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.char<1,3>>>
- ! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_56]] : (!fir.box<!fir.array<4x!fir.char<1,3>>>) -> !fir.box<none>
- ! CHECK: %[[VAL_58:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_44]], %[[VAL_57]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- ! CHECK: fir.freemem %[[VAL_45]] : !fir.heap<!fir.array<4x!fir.char<1,3>>>
- ! CHECK: %[[VAL_59:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_44]]) {{.*}}: (!fir.ref<i8>) -> i32
print*, ['AA ', 'MM ', 'MM ', 'ZZ ']
print*, ['AA ', 'MM ', 'MM ', 'ZZ ']
print*, ['AA ', 'MM ', 'MM ', 'ZZ ']
- ! CHECK: return
- ! CHECK: }
end
+! CHECK-LABEL: func.func @_QPcharlit() {
+! CHECK: %[[VAL_0:.*]] = arith.constant 6 : i32
+! CHECK: %[[VAL_4:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_0]], %{{.*}}, %{{.*}}) fastmath<contract> : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
+! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QQro.4x3xc1.0) : !fir.ref<!fir.array<4x!fir.char<1,3>>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_7:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_8]]) typeparams %[[VAL_7]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQro.4x3xc1.0"} : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.ref<!fir.array<4x!fir.char<1,3>>>)
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]] = fir.embox %[[VAL_9]]#1(%[[VAL_10]]) : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.char<1,3>>>
+! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.box<!fir.array<4x!fir.char<1,3>>>) -> !fir.box<none>
+! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_4]], %[[VAL_12]]) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>) -> i1
+! CHECK: %[[VAL_14:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_4]]) fastmath<contract> : (!fir.ref<i8>) -> i32
+! CHECK: %[[VAL_15:.*]] = arith.constant 6 : i32
+! CHECK: %[[VAL_19:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_15]], %{{.*}}, %{{.*}}) fastmath<contract> : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
+! CHECK: %[[VAL_20:.*]] = fir.address_of(@_QQro.4x3xc1.0) : !fir.ref<!fir.array<4x!fir.char<1,3>>>
+! CHECK: %[[VAL_21:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_22:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_21]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_24:.*]]:2 = hlfir.declare %[[VAL_20]](%[[VAL_23]]) typeparams %[[VAL_22]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQro.4x3xc1.0"} : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.ref<!fir.array<4x!fir.char<1,3>>>)
+! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_21]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_26:.*]] = fir.embox %[[VAL_24]]#1(%[[VAL_25]]) : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.char<1,3>>>
+! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (!fir.box<!fir.array<4x!fir.char<1,3>>>) -> !fir.box<none>
+! CHECK: %[[VAL_28:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_19]], %[[VAL_27]]) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>) -> i1
+! CHECK: %[[VAL_29:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_19]]) fastmath<contract> : (!fir.ref<i8>) -> i32
+! CHECK: %[[VAL_30:.*]] = arith.constant 6 : i32
+! CHECK: %[[VAL_34:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_30]], %{{.*}}, %{{.*}}) fastmath<contract> : (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
+! CHECK: %[[VAL_35:.*]] = fir.address_of(@_QQro.4x3xc1.0) : !fir.ref<!fir.array<4x!fir.char<1,3>>>
+! CHECK: %[[VAL_36:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_37:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_38:.*]] = fir.shape %[[VAL_36]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_39:.*]]:2 = hlfir.declare %[[VAL_35]](%[[VAL_38]]) typeparams %[[VAL_37]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQro.4x3xc1.0"} : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.ref<!fir.array<4x!fir.char<1,3>>>)
+! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_36]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_41:.*]] = fir.embox %[[VAL_39]]#1(%[[VAL_40]]) : (!fir.ref<!fir.array<4x!fir.char<1,3>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.char<1,3>>>
+! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_41]] : (!fir.box<!fir.array<4x!fir.char<1,3>>>) -> !fir.box<none>
+! CHECK: %[[VAL_43:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_34]], %[[VAL_42]]) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>) -> i1
+! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_34]]) fastmath<contract> : (!fir.ref<i8>) -> i32
+! CHECK: return
+! CHECK: }
! CHECK: fir.global internal @_QQro.4x3xc1.0 constant : !fir.array<4x!fir.char<1,3>>
! CHECK: AA
diff --git a/flang/test/Lower/array-copy.f90 b/flang/test/Lower/array-copy.f90
deleted file mode 100644
index 1339367b9f7d1..0000000000000
--- a/flang/test/Lower/array-copy.f90
+++ /dev/null
@@ -1,144 +0,0 @@
-! Test array-value-copy
-
-! RUN: bbc -hlfir=false %s -o - | FileCheck %s
-
-! Copy not needed
-! CHECK-LABEL: func @_QPtest1(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: fir.freemem %
-! CHECK: return
-! CHECK: }
-subroutine test1(a)
- integer :: a(3)
-
- a = a + 1
-end subroutine test1
-
-! Copy not needed
-! CHECK-LABEL: func @_QPtest2(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: fir.freemem %
-! CHECK: return
-! CHECK: }
-subroutine test2(a, b)
- integer :: a(3), b(3)
-
- a = b + 1
-end subroutine test2
-
-! Copy not needed
-! CHECK-LABEL: func @_QPtest3(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: fir.freemem %
-! CHECK: return
-! CHECK: }
-subroutine test3(a)
- integer :: a(3)
-
- forall (i=1:3)
- a(i) = a(i) + 1
- end forall
-end subroutine test3
-
-! Make a copy. (Crossing dependence)
-! CHECK-LABEL: func @_QPtest4(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.array<3xi32>>
-! CHECK: return
-! CHECK: }
-subroutine test4(a)
- integer :: a(3)
-
- forall (i=1:3)
- a(i) = a(4-i) + 1
- end forall
-end subroutine test4
-
-! Make a copy. (Carried dependence)
-! CHECK-LABEL: func @_QPtest5(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.array<3xi32>>
-! CHECK: return
-! CHECK: }
-subroutine test5(a)
- integer :: a(3)
-
- forall (i=2:3)
- a(i) = a(i-1) + 14
- end forall
-end subroutine test5
-
-! Make a copy. (Carried dependence)
-! CHECK-LABEL: func @_QPtest6(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.array<3x!fir.type<_QFtest6Tt{m:!fir.array<3xi32>}>>>
-! CHECK: return
-! CHECK: }
-subroutine test6(a)
- type t
- integer :: m(3)
- end type t
- type(t) :: a(3)
-
- forall (i=2:3)
- a(i)%m = a(i-1)%m + 14
- end forall
-end subroutine test6
-
-! Make a copy. (Overlapping partial CHARACTER update.)
-! CHECK-LABEL: func @_QPtest7(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: fir.freemem %{{.*}} : !fir.heap<!fir.array<3x!fir.char<1,8>>>
-! CHECK: return
-! CHECK: }
-subroutine test7(a)
- character(8) :: a(3)
-
- a(:)(2:5) = a(:)(3:6)
-end subroutine test7
-
-! Do not make a copy.
-! CHECK-LABEL: func @_QPtest8(
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: fir.freemem %
-! CHECK: return
-! CHECK: }
-subroutine test8(a,b)
- character(8) :: a(3), b(3)
-
- a(:)(2:5) = b(:)(3:6)
-end subroutine test8
-
-! Do make a copy. Assume vector subscripts cause dependences.
-! CHECK-LABEL: func @_QPtest9(
-! CHECK-SAME: %[[a:[^:]+]]: !fir.ref<!fir.array<?x?xf32>>
-! CHECK: %[[und:.*]] = fir.undefined index
-! CHECK: %[[slice:.*]] = fir.slice %[[und]], %[[und]], %[[und]],
-! CHECK: %[[heap:.*]] = fir.allocmem !fir.array<?x?xf32>, %{{.*}}, %{{.*}}
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: = fir.array_coor %[[a]](%{{.*}}) [%[[slice]]] %{{.*}}, %{{.*}} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>, !fir.slice<2>, index, index) -> !fir.ref<f32>
-! CHECK: = fir.array_coor %[[heap]](%{{.*}}) [%[[slice]]] %{{.*}}, %{{.*}} : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>, !fir.slice<2>, index, index) -> !fir.ref<f32>
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK-NOT: ^bb{{[0-9]+}}(%{{.*}}: index, %{{.*}}: index):
-! CHECK: fir.freemem %[[heap]]
-subroutine test9(a,v1,v2,n)
- real :: a(n,n)
- integer :: v1(n), v2(n)
- a(v1,:) = a(v2,:)
-end subroutine test9
diff --git a/flang/test/Lower/array-derived-assignments.f90 b/flang/test/Lower/array-derived-assignments.f90
deleted file mode 100644
index 3a66a0824666b..0000000000000
--- a/flang/test/Lower/array-derived-assignments.f90
+++ /dev/null
@@ -1,104 +0,0 @@
-! Test derived type assignment lowering inside array expression
-! RUN: bbc -hlfir=false -fwrapv %s -o - | FileCheck %s
-
-module array_derived_assign
- type simple_copy
- integer :: i
- character(10) :: c(20)
- real, pointer :: p(:)
- end type
- type deep_copy
- integer :: i
- real, allocatable :: a(:)
- end type
-contains
-
-! Simple copies are implemented inline component by component.
-! CHECK-LABEL: func @_QMarray_derived_assignPtest_simple_copy(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>>{{.*}}) {
-subroutine test_simple_copy(t1, t2)
- type(simple_copy) :: t1(10), t2(10)
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 20 : index
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_6:.*]] = arith.constant 1 : index
- ! CHECK-DAG: %[[VAL_7:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
- ! CHECK: br ^bb1(%[[VAL_5]], %[[VAL_3]] : index, index)
- ! CHECK: ^bb1(%[[VAL_8:.*]]: index, %[[VAL_9:.*]]: index):
- ! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_9]], %[[VAL_5]] : index
- ! CHECK: cond_br %[[VAL_10]], ^bb2, ^bb6
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_8]], %[[VAL_6]] : index
- ! CHECK: %[[VAL_12:.*]] = fir.array_coor %[[VAL_1]](%[[VAL_7]]) %[[VAL_11]] : (!fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>>, !fir.shape<1>, index) -> !fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>
- ! CHECK: %[[VAL_13:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_7]]) %[[VAL_11]] : (!fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>>, !fir.shape<1>, index) -> !fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>
- ! CHECK: %[[VAL_14:.*]] = fir.field_index i, !fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>
- ! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_14]] : (!fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_14]] : (!fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_15]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_17]] to %[[VAL_16]] : !fir.ref<i32>
- ! CHECK: %[[VAL_18:.*]] = fir.field_index c, !fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>
- ! CHECK: %[[VAL_19:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_18]] : (!fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>, !fir.field) -> !fir.ref<!fir.array<20x!fir.char<1,10>>>
- ! CHECK: %[[VAL_20:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_18]] : (!fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>, !fir.field) -> !fir.ref<!fir.array<20x!fir.char<1,10>>>
- ! CHECK: br ^bb3(%[[VAL_5]], %[[VAL_2]] : index, index)
- ! CHECK: ^bb3(%[[VAL_21:.*]]: index, %[[VAL_22:.*]]: index):
- ! CHECK: %[[VAL_23:.*]] = arith.cmpi sgt, %[[VAL_22]], %[[VAL_5]] : index
- ! CHECK: cond_br %[[VAL_23]], ^bb4, ^bb5
- ! CHECK: ^bb4:
- ! CHECK: %[[VAL_24:.*]] = fir.coordinate_of %[[VAL_20]], %[[VAL_21]] : (!fir.ref<!fir.array<20x!fir.char<1,10>>>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_19]], %[[VAL_21]] : (!fir.ref<!fir.array<20x!fir.char<1,10>>>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
- ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_27]], %[[VAL_28]], %[[VAL_26]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_21]], %[[VAL_6]] : index
- ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_22]], %[[VAL_6]] : index
- ! CHECK: br ^bb3(%[[VAL_29]], %[[VAL_30]] : index, index)
- ! CHECK: ^bb5:
- ! CHECK: %[[VAL_31:.*]] = fir.field_index p, !fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>
- ! CHECK: %[[VAL_32:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_31]] : (!fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>, !fir.field) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
- ! CHECK: %[[VAL_33:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_31]] : (!fir.ref<!fir.type<_QMarray_derived_assignTsimple_copy{i:i32,c:!fir.array<20x!fir.char<1,10>>,p:!fir.box<!fir.ptr<!fir.array<?xf32>>>}>>, !fir.field) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
- ! CHECK: %[[VAL_34:.*]] = fir.load %[[VAL_32]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
- ! CHECK: fir.store %[[VAL_34]] to %[[VAL_33]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
- ! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_9]], %[[VAL_6]] : index
- ! CHECK: br ^bb1(%[[VAL_11]], %[[VAL_35]] : index, index)
- ! CHECK: ^bb6:
- t1 = t2
- ! CHECK: return
- ! CHECK: }
-end subroutine
-
-! Types require more complex assignments are passed to the runtime
-! CHECK-LABEL: func @_QMarray_derived_assignPtest_deep_copy(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>{{.*}}) {
-subroutine test_deep_copy(t1, t2)
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_6:.*]] = fir.alloca !fir.box<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>
- ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
- ! CHECK: br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index)
- ! CHECK: ^bb1(%[[VAL_8:.*]]: index, %[[VAL_9:.*]]: index):
- ! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_9]], %[[VAL_4]] : index
- ! CHECK: cond_br %[[VAL_10]], ^bb2, ^bb3
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_8]], %[[VAL_5]] : index
- ! CHECK: %[[VAL_12:.*]] = fir.array_coor %[[VAL_1]](%[[VAL_7]]) %[[VAL_11]] : (!fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>, !fir.shape<1>, index) -> !fir.ref<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>
- ! CHECK: %[[VAL_13:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_7]]) %[[VAL_11]] : (!fir.ref<!fir.array<10x!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>, !fir.shape<1>, index) -> !fir.ref<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>
- ! CHECK: %[[VAL_14:.*]] = fir.embox %[[VAL_13]] : (!fir.ref<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>) -> !fir.box<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>
- ! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_12]] : (!fir.ref<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>) -> !fir.box<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>
- ! CHECK: fir.store %[[VAL_14]] to %[[VAL_6]] : !fir.ref<!fir.box<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>
- ! CHECK: %[[VAL_16:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,
- ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_6]] : (!fir.ref<!fir.box<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>) -> !fir.ref<!fir.box<none>>
- ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_15]] : (!fir.box<!fir.type<_QMarray_derived_assignTdeep_copy{i:i32,a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>) -> !fir.box<none>
- ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
- ! CHECK: fir.call @_FortranAAssign(%[[VAL_17]], %[[VAL_18]], %[[VAL_19]], %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
- ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_9]], %[[VAL_5]] : index
- ! CHECK: br ^bb1(%[[VAL_11]], %[[VAL_21]] : index, index)
- type(deep_copy) :: t1(10), t2(10)
- t1 = t2
- ! CHECK: return
- ! CHECK: }
-end subroutine
-
-end module
diff --git a/flang/test/Lower/array-elemental-calls-char-byval.f90 b/flang/test/Lower/array-elemental-calls-char-byval.f90
index 682191fc78956..446a4eac9b35e 100644
--- a/flang/test/Lower/array-elemental-calls-char-byval.f90
+++ b/flang/test/Lower/array-elemental-calls-char-byval.f90
@@ -1,6 +1,6 @@
! Test lowering of elemental calls with character argument
! with the VALUE attribute.
-! RUN: bbc -hlfir=false -fwrapv -o - %s | FileCheck %s
+! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
module char_elem_byval
@@ -13,183 +13,199 @@ elemental integer function elem(c, j)
end interface
contains
-! CHECK-LABEL: func @_QMchar_elem_byvalPfoo1(
-! CHECK-SAME: %[[VAL_22:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_19:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_5:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo1(i, j, c)
integer :: i(10), j(10)
character(*) :: c(10)
-! CHECK-DAG: %[[VAL_0:.*]] = arith.constant false
-! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_5]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
-! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
-! CHECK: br ^bb1(%[[VAL_2]], %[[VAL_1]] : index, index)
-! CHECK: ^bb1(%[[VAL_8:.*]]: index, %[[VAL_9:.*]]: index):
-! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_9]], %[[VAL_2]] : index
-! CHECK: cond_br %[[VAL_10]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_8]], %[[VAL_3]] : index
-! CHECK: %[[VAL_12:.*]] = fir.array_coor %[[VAL_6]](%[[VAL_7]]) %[[VAL_11]] typeparams %[[VAL_4]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_13:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_4]]#1 : index) {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_4]]#1 : (index) -> i64
-! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_12]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_15]], %[[VAL_16]], %[[VAL_14]], %[[VAL_0]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_17:.*]] = fir.emboxchar %[[VAL_13]], %[[VAL_4]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_18:.*]] = fir.array_coor %[[VAL_19]](%[[VAL_7]]) %[[VAL_11]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_20:.*]] = fir.call @_QPelem(%[[VAL_17]], %[[VAL_18]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_21:.*]] = fir.array_coor %[[VAL_22]](%[[VAL_7]]) %[[VAL_11]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_20]] to %[[VAL_21]] : !fir.ref<i32>
-! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_9]], %[[VAL_3]] : index
-! CHECK: br ^bb1(%[[VAL_11]], %[[VAL_23]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(c, j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elem_byvalPfoo1(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"},
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_7]]) typeparams %[[VAL_4]]#1 dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo1Ec"} : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.box<!fir.array<10x!fir.char<1,?>>>, !fir.ref<!fir.array<10x!fir.char<1,?>>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_10]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo1Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_12:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_13]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo1Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_15:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_16:.*]]: index):
+! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_16]]) typeparams %[[VAL_4]]#1 : (!fir.box<!fir.array<10x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_18:.*]] = hlfir.as_expr %[[VAL_17]] : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
+! CHECK: %[[VAL_19:.*]]:3 = hlfir.associate %[[VAL_18]] typeparams %[[VAL_4]]#1 {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>, i1)
+! CHECK: %[[VAL_20:.*]] = hlfir.designate %[[VAL_14]]#0 (%[[VAL_16]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_21:.*]] = fir.call @_QPelem(%[[VAL_19]]#0, %[[VAL_20]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_19]]#1, %[[VAL_19]]#2 : !fir.ref<!fir.char<1,?>>, i1
+! CHECK: hlfir.yield_element %[[VAL_21]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_15]] to %[[VAL_11]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_15]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elem_byvalPfoo2(
-! CHECK-SAME: %[[VAL_44:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_41:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_29:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo2(i, j, c)
integer :: i(10), j(10)
character(*) :: c
-! CHECK-DAG: %[[VAL_24:.*]] = arith.constant false
-! CHECK-DAG: %[[VAL_25:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_26:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]]:2 = fir.unboxchar %[[VAL_29]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_30:.*]] = fir.shape %[[VAL_25]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_31:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_28]]#1 : index) {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_28]]#1 : (index) -> i64
-! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_28]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_33]], %[[VAL_34]], %[[VAL_32]], %[[VAL_24]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: br ^bb1(%[[VAL_26]], %[[VAL_25]] : index, index)
-! CHECK: ^bb1(%[[VAL_35:.*]]: index, %[[VAL_36:.*]]: index):
-! CHECK: %[[VAL_37:.*]] = arith.cmpi sgt, %[[VAL_36]], %[[VAL_26]] : index
-! CHECK: cond_br %[[VAL_37]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_38:.*]] = fir.emboxchar %[[VAL_31]], %[[VAL_28]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_39:.*]] = arith.addi %[[VAL_35]], %[[VAL_27]] : index
-! CHECK: %[[VAL_40:.*]] = fir.array_coor %[[VAL_41]](%[[VAL_30]]) %[[VAL_39]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_42:.*]] = fir.call @_QPelem(%[[VAL_38]], %[[VAL_40]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_43:.*]] = fir.array_coor %[[VAL_44]](%[[VAL_30]]) %[[VAL_39]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_42]] to %[[VAL_43]] : !fir.ref<i32>
-! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_36]], %[[VAL_27]] : index
-! CHECK: br ^bb1(%[[VAL_39]], %[[VAL_45]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(c, j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elem_byvalPfoo2(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"},
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo2Ec"} : (!fir.ref<!fir.char<1,?>>, index, !fir.dscope) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_7]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo2Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_10]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo2Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_10]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_13:.*]]: index):
+! CHECK: %[[VAL_14:.*]] = hlfir.as_expr %[[VAL_5]]#0 : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
+! CHECK: %[[VAL_15:.*]]:3 = hlfir.associate %[[VAL_14]] typeparams %[[VAL_4]]#1 {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>, i1)
+! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_17:.*]] = fir.call @_QPelem(%[[VAL_15]]#0, %[[VAL_16]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_15]]#1, %[[VAL_15]]#2 : !fir.ref<!fir.char<1,?>>, i1
+! CHECK: hlfir.yield_element %[[VAL_17]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_8]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elem_byvalPfoo3(
-! CHECK-SAME: %[[VAL_65:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_55:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}) {
subroutine foo3(i, j)
integer :: i(10), j(10)
-! CHECK-DAG: %[[VAL_46:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_47:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_48:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_49:.*]] = fir.shape %[[VAL_46]] : (index) -> !fir.shape<1>
-! CHECK: br ^bb1(%[[VAL_47]], %[[VAL_46]] : index, index)
-! CHECK: ^bb1(%[[VAL_50:.*]]: index, %[[VAL_51:.*]]: index):
-! CHECK: %[[VAL_52:.*]] = arith.cmpi sgt, %[[VAL_51]], %[[VAL_47]] : index
-! CHECK: cond_br %[[VAL_52]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_53:.*]] = arith.addi %[[VAL_50]], %[[VAL_48]] : index
-! CHECK: %[[VAL_54:.*]] = fir.array_coor %[[VAL_55]](%[[VAL_49]]) %[[VAL_53]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_56:.*]] = fir.load %[[VAL_54]] : !fir.ref<i32>
-! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_56]] : (i32) -> i8
-! CHECK: %[[VAL_58:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_59:.*]] = fir.insert_value %[[VAL_58]], %[[VAL_57]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_60:.*]] = fir.alloca !fir.char<1> {bindc_name = ".chrtmp"}
-! CHECK: fir.store %[[VAL_59]] to %[[VAL_60]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_62:.*]] = fir.emboxchar %[[VAL_60]], %[[VAL_48]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_63:.*]] = fir.call @_QPelem(%[[VAL_62]], %[[VAL_54]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_64:.*]] = fir.array_coor %[[VAL_65]](%[[VAL_49]]) %[[VAL_53]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_63]] to %[[VAL_64]] : !fir.ref<i32>
-! CHECK: %[[VAL_66:.*]] = arith.subi %[[VAL_51]], %[[VAL_48]] : index
-! CHECK: br ^bb1(%[[VAL_53]], %[[VAL_66]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(char(j), j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elem_byvalPfoo3(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.char<1>
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_5]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo3Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_8]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo3Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi64> {
+! CHECK: ^bb0(%[[VAL_11:.*]]: index):
+! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_11]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref<i32>
+! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
+! CHECK: hlfir.yield_element %[[VAL_14]] : i64
+! CHECK: }
+! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_8]] typeparams %[[VAL_15]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<10x!fir.char<1>> {
+! CHECK: ^bb0(%[[VAL_17:.*]]: index):
+! CHECK: %[[VAL_18:.*]] = hlfir.apply %[[VAL_10]], %[[VAL_17]] : (!hlfir.expr<10xi64>, index) -> i64
+! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> i8
+! CHECK: %[[VAL_20:.*]] = fir.undefined !fir.char<1>
+! CHECK: %[[VAL_21:.*]] = fir.insert_value %[[VAL_20]], %[[VAL_19]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
+! CHECK: fir.store %[[VAL_21]] to %[[VAL_2]] : !fir.ref<!fir.char<1>>
+! CHECK: %[[VAL_22:.*]] = arith.constant false
+! CHECK: %[[VAL_23:.*]] = hlfir.as_expr %[[VAL_2]] move %[[VAL_22]] : (!fir.ref<!fir.char<1>>, i1) -> !hlfir.expr<!fir.char<1>>
+! CHECK: hlfir.yield_element %[[VAL_23]] : !hlfir.expr<!fir.char<1>>
+! CHECK: }
+! CHECK: %[[VAL_24:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_25:.*]]: index):
+! CHECK: %[[VAL_26:.*]] = hlfir.apply %[[VAL_16]], %[[VAL_25]] typeparams %[[VAL_15]] : (!hlfir.expr<10x!fir.char<1>>, index, index) -> !hlfir.expr<!fir.char<1>>
+! CHECK: %[[VAL_27:.*]]:3 = hlfir.associate %[[VAL_26]] typeparams %[[VAL_15]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1>>, index) -> (!fir.ref<!fir.char<1>>, !fir.ref<!fir.char<1>>, i1)
+! CHECK: %[[VAL_28:.*]] = fir.emboxchar %[[VAL_27]]#1, %[[VAL_15]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_25]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_30:.*]] = fir.call @_QPelem(%[[VAL_28]], %[[VAL_29]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_27]]#1, %[[VAL_27]]#2 : !fir.ref<!fir.char<1>>, i1
+! CHECK: hlfir.yield_element %[[VAL_30]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_24]] to %[[VAL_6]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_24]] : !hlfir.expr<10xi32>
+! CHECK: hlfir.destroy %[[VAL_16]] : !hlfir.expr<10x!fir.char<1>>
+! CHECK: hlfir.destroy %[[VAL_10]] : !hlfir.expr<10xi64>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elem_byvalPfoo4(
-! CHECK-SAME: %[[VAL_93:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_74:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}) {
subroutine foo4(i, j)
integer :: i(10), j(10)
-! CHECK-DAG: %[[VAL_67:.*]] = arith.constant 0 : i64
-! CHECK-DAG: %[[VAL_68:.*]] = arith.constant false
-! CHECK-DAG: %[[VAL_69:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_70:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_71:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_66:.*]] = fir.alloca !fir.char<1> {adapt.valuebyref}
-! CHECK: %[[VAL_72:.*]] = fir.shape %[[VAL_69]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_73:.*]] = fir.coordinate_of %[[VAL_74]], %[[VAL_67]] : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
-! CHECK: %[[VAL_75:.*]] = fir.load %[[VAL_73]] : !fir.ref<i32>
-! CHECK: %[[VAL_76:.*]] = fir.convert %[[VAL_75]] : (i32) -> i8
-! CHECK: %[[VAL_77:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_78:.*]] = fir.insert_value %[[VAL_77]], %[[VAL_76]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: fir.store %[[VAL_78]] to %[[VAL_66]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_80:.*]] = fir.alloca !fir.char<1> {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_81:.*]] = fir.convert %[[VAL_71]] : (index) -> i64
-! CHECK: %[[VAL_82:.*]] = fir.convert %[[VAL_80]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_83:.*]] = fir.convert %[[VAL_66]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_82]], %[[VAL_83]], %[[VAL_81]], %[[VAL_68]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: br ^bb1(%[[VAL_70]], %[[VAL_69]] : index, index)
-! CHECK: ^bb1(%[[VAL_84:.*]]: index, %[[VAL_85:.*]]: index):
-! CHECK: %[[VAL_86:.*]] = arith.cmpi sgt, %[[VAL_85]], %[[VAL_70]] : index
-! CHECK: cond_br %[[VAL_86]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_88:.*]] = fir.emboxchar %[[VAL_80]], %[[VAL_71]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_89:.*]] = arith.addi %[[VAL_84]], %[[VAL_71]] : index
-! CHECK: %[[VAL_90:.*]] = fir.array_coor %[[VAL_74]](%[[VAL_72]]) %[[VAL_89]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_91:.*]] = fir.call @_QPelem(%[[VAL_88]], %[[VAL_90]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_92:.*]] = fir.array_coor %[[VAL_93]](%[[VAL_72]]) %[[VAL_89]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_91]] to %[[VAL_92]] : !fir.ref<i32>
-! CHECK: %[[VAL_94:.*]] = arith.subi %[[VAL_85]], %[[VAL_71]] : index
-! CHECK: br ^bb1(%[[VAL_89]], %[[VAL_94]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(char(j(1)), j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elem_byvalPfoo4(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.char<1>
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_5]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo4Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_8]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elem_byvalFfoo4Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_10]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_11]] : !fir.ref<i32>
+! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i32) -> i64
+! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> i8
+! CHECK: %[[VAL_15:.*]] = fir.undefined !fir.char<1>
+! CHECK: %[[VAL_16:.*]] = fir.insert_value %[[VAL_15]], %[[VAL_14]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
+! CHECK: fir.store %[[VAL_16]] to %[[VAL_2]] : !fir.ref<!fir.char<1>>
+! CHECK: %[[VAL_17:.*]] = arith.constant false
+! CHECK: %[[VAL_18:.*]] = hlfir.as_expr %[[VAL_2]] move %[[VAL_17]] : (!fir.ref<!fir.char<1>>, i1) -> !hlfir.expr<!fir.char<1>>
+! CHECK: %[[VAL_19:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_20:.*]]: index):
+! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_22:.*]]:3 = hlfir.associate %[[VAL_18]] typeparams %[[VAL_21]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1>>, index) -> (!fir.ref<!fir.char<1>>, !fir.ref<!fir.char<1>>, i1)
+! CHECK: %[[VAL_23:.*]] = fir.emboxchar %[[VAL_22]]#1, %[[VAL_21]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_24:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_20]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_25:.*]] = fir.call @_QPelem(%[[VAL_23]], %[[VAL_24]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_22]]#1, %[[VAL_22]]#2 : !fir.ref<!fir.char<1>>, i1
+! CHECK: hlfir.yield_element %[[VAL_25]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_19]] to %[[VAL_6]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_19]] : !hlfir.expr<10xi32>
+! CHECK: hlfir.destroy %[[VAL_18]] : !hlfir.expr<!fir.char<1>>
+! CHECK: return
+! CHECK: }
! Note: the copy of the constant is important because VALUE argument can be
! modified on the caller side.
-! CHECK-LABEL: func @_QMchar_elem_byvalPfoo5(
-! CHECK-SAME: %[[VAL_116:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_113:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}) {
subroutine foo5(i, j)
integer :: i(10), j(10)
-! CHECK-DAG: %[[VAL_95:.*]] = arith.constant 5 : index
-! CHECK-DAG: %[[VAL_96:.*]] = arith.constant false
-! CHECK-DAG: %[[VAL_97:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_98:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_99:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_100:.*]] = fir.shape %[[VAL_97]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_101:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>>
-! CHECK: %[[VAL_102:.*]] = fir.alloca !fir.char<1,5> {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_103:.*]] = fir.convert %[[VAL_95]] : (index) -> i64
-! CHECK: %[[VAL_104:.*]] = fir.convert %[[VAL_102]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_105:.*]] = fir.convert %[[VAL_101]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_104]], %[[VAL_105]], %[[VAL_103]], %[[VAL_96]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: br ^bb1(%[[VAL_98]], %[[VAL_97]] : index, index)
-! CHECK: ^bb1(%[[VAL_106:.*]]: index, %[[VAL_107:.*]]: index):
-! CHECK: %[[VAL_108:.*]] = arith.cmpi sgt, %[[VAL_107]], %[[VAL_98]] : index
-! CHECK: cond_br %[[VAL_108]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_110:.*]] = fir.emboxchar %[[VAL_102]], %[[VAL_95]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_111:.*]] = arith.addi %[[VAL_106]], %[[VAL_99]] : index
-! CHECK: %[[VAL_112:.*]] = fir.array_coor %[[VAL_113]](%[[VAL_100]]) %[[VAL_111]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_114:.*]] = fir.call @_QPelem(%[[VAL_110]], %[[VAL_112]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_115:.*]] = fir.array_coor %[[VAL_116]](%[[VAL_100]]) %[[VAL_111]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_114]] to %[[VAL_115]] : !fir.ref<i32>
-! CHECK: %[[VAL_117:.*]] = arith.subi %[[VAL_107]], %[[VAL_99]] : index
-! CHECK: br ^bb1(%[[VAL_111]], %[[VAL_117]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem("hello", j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elem_byvalPfoo5(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_4]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elem_byvalFfoo5Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_7]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elem_byvalFfoo5Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QQclX68656C6C6F) : !fir.ref<!fir.char<1,5>>
+! CHECK: %[[VAL_10:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_9]] typeparams %[[VAL_10]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX68656C6C6F"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_13:.*]]: index):
+! CHECK: %[[VAL_14:.*]] = hlfir.as_expr %[[VAL_11]]#0 : (!fir.ref<!fir.char<1,5>>) -> !hlfir.expr<!fir.char<1,5>>
+! CHECK: %[[VAL_15:.*]]:3 = hlfir.associate %[[VAL_14]] typeparams %[[VAL_10]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>, i1)
+! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_15]]#1, %[[VAL_10]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_18:.*]] = fir.call @_QPelem(%[[VAL_16]], %[[VAL_17]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_15]]#1, %[[VAL_15]]#2 : !fir.ref<!fir.char<1,5>>, i1
+! CHECK: hlfir.yield_element %[[VAL_18]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_5]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
end module
diff --git a/flang/test/Lower/array-elemental-calls-char.f90 b/flang/test/Lower/array-elemental-calls-char.f90
index 00e2f8e8f9c12..691d8c27e93c6 100644
--- a/flang/test/Lower/array-elemental-calls-char.f90
+++ b/flang/test/Lower/array-elemental-calls-char.f90
@@ -1,6 +1,6 @@
! Test lowering of elemental calls with character argument
! without the VALUE attribute.
-! RUN: bbc -hlfir=false -fwrapv -o - %s | FileCheck %s
+! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
module char_elem
@@ -18,251 +18,259 @@ elemental integer function elem2(c, j)
contains
-! CHECK-LABEL: func @_QMchar_elemPfoo1(
-! CHECK-SAME: %[[VAL_15:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_4:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo1(i, c)
integer :: i(10)
character(*) :: c(10)
-! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_4]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
-! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1>
-! CHECK: br ^bb1(%[[VAL_1]], %[[VAL_0]] : index, index)
-! CHECK: ^bb1(%[[VAL_7:.*]]: index, %[[VAL_8:.*]]: index):
-! CHECK: %[[VAL_9:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_1]] : index
-! CHECK: cond_br %[[VAL_9]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_7]], %[[VAL_2]] : index
-! CHECK: %[[VAL_11:.*]] = fir.array_coor %[[VAL_5]](%[[VAL_6]]) %[[VAL_10]] typeparams %[[VAL_3]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_12:.*]] = fir.emboxchar %[[VAL_11]], %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_13:.*]] = fir.call @_QPelem(%[[VAL_12]]) {{.*}}: (!fir.boxchar<1>) -> i32
-! CHECK: %[[VAL_14:.*]] = fir.array_coor %[[VAL_15]](%[[VAL_6]]) %[[VAL_10]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_13]] to %[[VAL_14]] : !fir.ref<i32>
-! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_8]], %[[VAL_2]] : index
-! CHECK: br ^bb1(%[[VAL_10]], %[[VAL_16]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(c)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo1(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_6]]) typeparams %[[VAL_3]]#1 dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elemFfoo1Ec"} : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.box<!fir.array<10x!fir.char<1,?>>>, !fir.ref<!fir.array<10x!fir.char<1,?>>>)
+! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_9]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elemFfoo1Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_12:.*]]: index):
+! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_12]]) typeparams %[[VAL_3]]#1 : (!fir.box<!fir.array<10x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_14:.*]] = fir.call @_QPelem(%[[VAL_13]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>) -> i32
+! CHECK: hlfir.yield_element %[[VAL_14]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_11]] to %[[VAL_10]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_11]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elemPfoo1b(
-! CHECK-SAME: %[[VAL_33:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_21:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo1b(i, c)
integer :: i(10)
character(10) :: c(10)
-! CHECK-DAG: %[[VAL_17:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_18:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_19:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_20:.*]]:2 = fir.unboxchar %[[VAL_21]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
-! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_17]] : (index) -> !fir.shape<1>
-! CHECK: br ^bb1(%[[VAL_18]], %[[VAL_17]] : index, index)
-! CHECK: ^bb1(%[[VAL_24:.*]]: index, %[[VAL_25:.*]]: index):
-! CHECK: %[[VAL_26:.*]] = arith.cmpi sgt, %[[VAL_25]], %[[VAL_18]] : index
-! CHECK: cond_br %[[VAL_26]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_24]], %[[VAL_19]] : index
-! CHECK: %[[VAL_28:.*]] = fir.array_coor %[[VAL_22]](%[[VAL_23]]) %[[VAL_27]] : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_30:.*]] = fir.emboxchar %[[VAL_28]], %[[VAL_17]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_31:.*]] = fir.call @_QPelem(%[[VAL_30]]) {{.*}}: (!fir.boxchar<1>) -> i32
-! CHECK: %[[VAL_32:.*]] = fir.array_coor %[[VAL_33]](%[[VAL_23]]) %[[VAL_27]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_31]] to %[[VAL_32]] : !fir.ref<i32>
-! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_25]], %[[VAL_19]] : index
-! CHECK: br ^bb1(%[[VAL_27]], %[[VAL_34]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(c)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo1b(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_7]]) typeparams %[[VAL_5]] dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elemFfoo1bEc"} : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.ref<!fir.array<10x!fir.char<1,10>>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_10]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elemFfoo1bEi"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_13:.*]]: index):
+! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_13]]) typeparams %[[VAL_5]] : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
+! CHECK: %[[VAL_15:.*]] = fir.emboxchar %[[VAL_14]], %[[VAL_5]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_16:.*]] = fir.call @_QPelem(%[[VAL_15]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>) -> i32
+! CHECK: hlfir.yield_element %[[VAL_16]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_11]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elemPfoo2(
-! CHECK-SAME: %[[VAL_50:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_47:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_39:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo2(i, j, c)
-! CHECK-DAG: %[[VAL_35:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_36:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_37:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_38:.*]]:2 = fir.unboxchar %[[VAL_39]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_35]] : (index) -> !fir.shape<1>
-! CHECK: br ^bb1(%[[VAL_36]], %[[VAL_35]] : index, index)
-! CHECK: ^bb1(%[[VAL_41:.*]]: index, %[[VAL_42:.*]]: index):
-! CHECK: %[[VAL_43:.*]] = arith.cmpi sgt, %[[VAL_42]], %[[VAL_36]] : index
-! CHECK: cond_br %[[VAL_43]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_44:.*]] = fir.emboxchar %[[VAL_38]]#0, %[[VAL_38]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_45:.*]] = arith.addi %[[VAL_41]], %[[VAL_37]] : index
-! CHECK: %[[VAL_46:.*]] = fir.array_coor %[[VAL_47]](%[[VAL_40]]) %[[VAL_45]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_48:.*]] = fir.call @_QPelem2(%[[VAL_44]], %[[VAL_46]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_49:.*]] = fir.array_coor %[[VAL_50]](%[[VAL_40]]) %[[VAL_45]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_48]] to %[[VAL_49]] : !fir.ref<i32>
-! CHECK: %[[VAL_51:.*]] = arith.subi %[[VAL_42]], %[[VAL_37]] : index
-! CHECK: br ^bb1(%[[VAL_45]], %[[VAL_51]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
integer :: i(10), j(10)
character(*) :: c
i = elem2(c, j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo2(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"},
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo2Ec"} : (!fir.ref<!fir.char<1,?>>, index, !fir.dscope) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_7]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo2Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_10]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo2Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_10]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_13:.*]]: index):
+! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_15:.*]] = fir.call @_QPelem2(%[[VAL_5]]#0, %[[VAL_14]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.yield_element %[[VAL_15]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_8]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func.func @_QMchar_elemPfoo2b(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_2:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo2b(i, j, c)
integer :: i(10), j(10)
character(10) :: c
-! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: cf.br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index)
-! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
-! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_4]] : index
-! CHECK: cf.cond_br %[[VAL_11]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_13:.*]] = fir.emboxchar %[[VAL_7]], %[[VAL_3]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_9]], %[[VAL_5]] : index
-! CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_1]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_16:.*]] = fir.call @_QPelem2(%[[VAL_13]], %[[VAL_15]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_17:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_16]] to %[[VAL_17]] : !fir.ref<i32>
-! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_10]], %[[VAL_5]] : index
-! CHECK: cf.br ^bb1(%[[VAL_14]], %[[VAL_18]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
-! CHECK: }
i = elem2(c, j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo2b(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"},
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,10>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]] typeparams %[[VAL_6]] dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo2bEc"} : (!fir.ref<!fir.char<1,10>>, index, !fir.dscope) -> (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>)
+! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_9]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo2bEi"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_11:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_11]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_12]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo2bEj"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_14:.*]] = hlfir.elemental %[[VAL_12]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_15:.*]]: index):
+! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_7]]#1, %[[VAL_6]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_13]]#0 (%[[VAL_15]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_18:.*]] = fir.call @_QPelem2(%[[VAL_16]], %[[VAL_17]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.yield_element %[[VAL_18]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_14]] to %[[VAL_10]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_14]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elemPfoo3(
-! CHECK-SAME: %[[VAL_88:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_79:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}})
subroutine foo3(i, j)
integer :: i(10), j(10)
-! CHECK-DAG: %[[VAL_69:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_70:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_71:.*]] = arith.constant 1 : index
-! CHECK-DAG: %[[VAL_72:.*]] = fir.alloca !fir.char<1>
-! CHECK: %[[VAL_73:.*]] = fir.shape %[[VAL_69]] : (index) -> !fir.shape<1>
-! CHECK: br ^bb1(%[[VAL_70]], %[[VAL_69]] : index, index)
-! CHECK: ^bb1(%[[VAL_74:.*]]: index, %[[VAL_75:.*]]: index):
-! CHECK: %[[VAL_76:.*]] = arith.cmpi sgt, %[[VAL_75]], %[[VAL_70]] : index
-! CHECK: cond_br %[[VAL_76]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_77:.*]] = arith.addi %[[VAL_74]], %[[VAL_71]] : index
-! CHECK: %[[VAL_78:.*]] = fir.array_coor %[[VAL_79]](%[[VAL_73]]) %[[VAL_77]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_80:.*]] = fir.load %[[VAL_78]] : !fir.ref<i32>
-! CHECK: %[[VAL_81:.*]] = fir.convert %[[VAL_80]] : (i32) -> i8
-! CHECK: %[[VAL_82:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_83:.*]] = fir.insert_value %[[VAL_82]], %[[VAL_81]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: fir.store %[[VAL_83]] to %[[VAL_72]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_85:.*]] = fir.emboxchar %[[VAL_72]], %[[VAL_71]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_86:.*]] = fir.call @_QPelem(%[[VAL_85]]) {{.*}}: (!fir.boxchar<1>) -> i32
-! CHECK: %[[VAL_87:.*]] = fir.array_coor %[[VAL_88]](%[[VAL_73]]) %[[VAL_77]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_86]] to %[[VAL_87]] : !fir.ref<i32>
-! CHECK: %[[VAL_89:.*]] = arith.subi %[[VAL_75]], %[[VAL_71]] : index
-! CHECK: br ^bb1(%[[VAL_77]], %[[VAL_89]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem(char(j))
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo3(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.char<1>
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_5]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo3Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_8]]) dummy_scope %[[VAL_3]] {uniq_name = "_QMchar_elemFfoo3Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi64> {
+! CHECK: ^bb0(%[[VAL_11:.*]]: index):
+! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_11]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref<i32>
+! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
+! CHECK: hlfir.yield_element %[[VAL_14]] : i64
+! CHECK: }
+! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_8]] typeparams %[[VAL_15]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<10x!fir.char<1>> {
+! CHECK: ^bb0(%[[VAL_17:.*]]: index):
+! CHECK: %[[VAL_18:.*]] = hlfir.apply %[[VAL_10]], %[[VAL_17]] : (!hlfir.expr<10xi64>, index) -> i64
+! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> i8
+! CHECK: %[[VAL_20:.*]] = fir.undefined !fir.char<1>
+! CHECK: %[[VAL_21:.*]] = fir.insert_value %[[VAL_20]], %[[VAL_19]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
+! CHECK: fir.store %[[VAL_21]] to %[[VAL_2]] : !fir.ref<!fir.char<1>>
+! CHECK: %[[VAL_22:.*]] = arith.constant false
+! CHECK: %[[VAL_23:.*]] = hlfir.as_expr %[[VAL_2]] move %[[VAL_22]] : (!fir.ref<!fir.char<1>>, i1) -> !hlfir.expr<!fir.char<1>>
+! CHECK: hlfir.yield_element %[[VAL_23]] : !hlfir.expr<!fir.char<1>>
+! CHECK: }
+! CHECK: %[[VAL_24:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_25:.*]]: index):
+! CHECK: %[[VAL_26:.*]] = hlfir.apply %[[VAL_16]], %[[VAL_25]] typeparams %[[VAL_15]] : (!hlfir.expr<10x!fir.char<1>>, index, index) -> !hlfir.expr<!fir.char<1>>
+! CHECK: %[[VAL_27:.*]]:3 = hlfir.associate %[[VAL_26]] typeparams %[[VAL_15]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1>>, index) -> (!fir.ref<!fir.char<1>>, !fir.ref<!fir.char<1>>, i1)
+! CHECK: %[[VAL_28:.*]] = fir.emboxchar %[[VAL_27]]#1, %[[VAL_15]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_29:.*]] = fir.call @_QPelem(%[[VAL_28]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_27]]#1, %[[VAL_27]]#2 : !fir.ref<!fir.char<1>>, i1
+! CHECK: hlfir.yield_element %[[VAL_29]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_24]] to %[[VAL_6]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_24]] : !hlfir.expr<10xi32>
+! CHECK: hlfir.destroy %[[VAL_16]] : !hlfir.expr<10x!fir.char<1>>
+! CHECK: hlfir.destroy %[[VAL_10]] : !hlfir.expr<10xi64>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QMchar_elemPfoo4(
-! CHECK-SAME: %[[VAL_106:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_103:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}})
subroutine foo4(i, j)
integer :: i(10), j(10)
-! CHECK-DAG: %[[VAL_90:.*]] = arith.constant 5 : index
-! CHECK-DAG: %[[VAL_91:.*]] = arith.constant 10 : index
-! CHECK-DAG: %[[VAL_92:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_93:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_94:.*]] = fir.shape %[[VAL_91]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_95:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>>
-! CHECK: br ^bb1(%[[VAL_92]], %[[VAL_91]] : index, index)
-! CHECK: ^bb1(%[[VAL_96:.*]]: index, %[[VAL_97:.*]]: index):
-! CHECK: %[[VAL_98:.*]] = arith.cmpi sgt, %[[VAL_97]], %[[VAL_92]] : index
-! CHECK: cond_br %[[VAL_98]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_100:.*]] = fir.emboxchar %[[VAL_95]], %[[VAL_90]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
-! CHECK: %[[VAL_101:.*]] = arith.addi %[[VAL_96]], %[[VAL_93]] : index
-! CHECK: %[[VAL_102:.*]] = fir.array_coor %[[VAL_103]](%[[VAL_94]]) %[[VAL_101]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: %[[VAL_104:.*]] = fir.call @_QPelem2(%[[VAL_100]], %[[VAL_102]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
-! CHECK: %[[VAL_105:.*]] = fir.array_coor %[[VAL_106]](%[[VAL_94]]) %[[VAL_101]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_104]] to %[[VAL_105]] : !fir.ref<i32>
-! CHECK: %[[VAL_107:.*]] = arith.subi %[[VAL_97]], %[[VAL_93]] : index
-! CHECK: br ^bb1(%[[VAL_101]], %[[VAL_107]] : index, index)
-! CHECK: ^bb3:
-! CHECK: return
i = elem2("hello", j)
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo4(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_4]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elemFfoo4Ei"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_7]]) dummy_scope %[[VAL_2]] {uniq_name = "_QMchar_elemFfoo4Ej"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QQclX68656C6C6F) : !fir.ref<!fir.char<1,5>>
+! CHECK: %[[VAL_10:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_9]] typeparams %[[VAL_10]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX68656C6C6F"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_13:.*]]: index):
+! CHECK: %[[VAL_14:.*]] = hlfir.as_expr %[[VAL_11]]#0 : (!fir.ref<!fir.char<1,5>>) -> !hlfir.expr<!fir.char<1,5>>
+! CHECK: %[[VAL_15:.*]]:3 = hlfir.associate %[[VAL_14]] typeparams %[[VAL_10]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>, i1)
+! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_15]]#1, %[[VAL_10]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
+! CHECK: %[[VAL_18:.*]] = fir.call @_QPelem2(%[[VAL_16]], %[[VAL_17]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
+! CHECK: hlfir.end_associate %[[VAL_15]]#1, %[[VAL_15]]#2 : !fir.ref<!fir.char<1,5>>, i1
+! CHECK: hlfir.yield_element %[[VAL_18]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_12]] to %[[VAL_5]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
! Test character return for elemental functions.
-! CHECK-LABEL: func @_QMchar_elemPelem_return_char(
-! CHECK-SAME: %{{.*}}: !fir.ref<!fir.char<1,?>>{{.*}}, %{{.*}}: index{{.*}}, %{{.*}}: !fir.boxchar<1>{{.*}}) -> !fir.boxchar<1>
elemental function elem_return_char(c)
character(*), intent(in) :: c
character(len(c)) :: elem_return_char
elem_return_char = "ab" // c
end function
-! CHECK-LABEL: func @_QMchar_elemPfoo6(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
subroutine foo6(c)
- ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 32 : i8
- ! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
- ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
- ! CHECK: br ^bb1(%[[VAL_3]], %[[VAL_1]] : index, index)
- ! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
- ! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_3]] : index
- ! CHECK: cond_br %[[VAL_11]], ^bb2, ^bb6
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_9]], %[[VAL_2]] : index
- ! CHECK: %[[VAL_13:.*]] = fir.array_coor %[[VAL_7]](%[[VAL_8]]) %[[VAL_12]] typeparams %[[VAL_6]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_14:.*]] = fir.emboxchar %[[VAL_13]], %[[VAL_6]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
- ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i32
- ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
- ! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_16]], %{{.*}} : index
- ! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_16]], %{{.*}} : index
- ! CHECK: %[[VAL_17:.*]] = llvm.intr.stacksave : !llvm.ptr
- ! CHECK: %[[VAL_18:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
- ! CHECK: %[[VAL_19:.*]] = fir.call @_QMchar_elemPelem_return_char(%[[VAL_18]], %[[SELECT]], %[[VAL_14]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
- ! CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_6]]#1, %[[SELECT]] : index
- ! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_6]]#1, %[[SELECT]] : index
- ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (index) -> i64
- ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_23]], %[[VAL_24]], %[[VAL_22]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_6]]#1, %[[VAL_2]] : index
- ! CHECK: %[[VAL_26:.*]] = fir.undefined !fir.char<1>
- ! CHECK: %[[VAL_27:.*]] = fir.insert_value %[[VAL_26]], %[[VAL_5]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
- ! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_25]], %[[VAL_21]] : index
- ! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_28]], %[[VAL_2]] : index
- ! CHECK: br ^bb3(%[[VAL_21]], %[[VAL_29]] : index, index)
- ! CHECK: ^bb3(%[[VAL_30:.*]]: index, %[[VAL_31:.*]]: index):
- ! CHECK: %[[VAL_32:.*]] = arith.cmpi sgt, %[[VAL_31]], %[[VAL_3]] : index
- ! CHECK: cond_br %[[VAL_32]], ^bb4, ^bb5
- ! CHECK: ^bb4:
- ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
- ! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_30]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
- ! CHECK: fir.store %[[VAL_27]] to %[[VAL_34]] : !fir.ref<!fir.char<1>>
- ! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_30]], %[[VAL_2]] : index
- ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_31]], %[[VAL_2]] : index
- ! CHECK: br ^bb3(%[[VAL_35]], %[[VAL_36]] : index, index)
- ! CHECK: ^bb5:
- ! CHECK: llvm.intr.stackrestore %[[VAL_17]] : !llvm.ptr
- ! CHECK: %[[VAL_37:.*]] = arith.subi %[[VAL_10]], %[[VAL_2]] : index
- ! CHECK: br ^bb1(%[[VAL_12]], %[[VAL_37]] : index, index)
- ! CHECK: ^bb6:
-
implicit none
character(*) :: c(10)
c = elem_return_char(c)
- ! CHECK: return
- ! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QMchar_elemPfoo6(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
+! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_5]]) typeparams %[[VAL_2]]#1 dummy_scope %[[VAL_1]] {uniq_name = "_QMchar_elemFfoo6Ec"} : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.box<!fir.array<10x!fir.char<1,?>>>, !fir.ref<!fir.array<10x!fir.char<1,?>>>)
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>) -> !fir.ref<!fir.char<1,?>>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]] typeparams %[[VAL_2]]#1 {uniq_name = "dummy.tmp"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
+! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> i32
+! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i32) -> i64
+! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
+! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_14:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_13]] : index
+! CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_14]], %[[VAL_12]], %[[VAL_13]] : index
+! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_15]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<10x!fir.char<1,?>> {
+! CHECK: ^bb0(%[[VAL_17:.*]]: index):
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_17]]) typeparams %[[VAL_2]]#1 : (!fir.box<!fir.array<10x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_19:.*]]:2 = fir.unboxchar %[[VAL_18]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]]#0 typeparams %[[VAL_19]]#1 {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QMchar_elemFelem_return_charEc"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_19]]#1 : (index) -> i64
+! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> i32
+! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i32) -> i64
+! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (i64) -> index
+! CHECK: %[[VAL_25:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_26:.*]] = arith.cmpi sgt, %[[VAL_24]], %[[VAL_25]] : index
+! CHECK: %[[VAL_27:.*]] = arith.select %[[VAL_26]], %[[VAL_24]], %[[VAL_25]] : index
+! CHECK: %[[VAL_28:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_27]] : index) {bindc_name = ".result"}
+! CHECK: %[[VAL_29:.*]] = fir.call @_QMchar_elemPelem_return_char(%[[VAL_28]], %[[VAL_27]], %[[VAL_18]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.ref<!fir.char<1,?>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
+! CHECK: %[[VAL_30:.*]]:2 = hlfir.declare %[[VAL_28]] typeparams %[[VAL_27]] {uniq_name = ".tmp.func_result"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK: %[[VAL_31:.*]] = arith.constant false
+! CHECK: %[[VAL_32:.*]] = hlfir.as_expr %[[VAL_30]]#0 move %[[VAL_31]] : (!fir.boxchar<1>, i1) -> !hlfir.expr<!fir.char<1,?>>
+! CHECK: hlfir.yield_element %[[VAL_32]] : !hlfir.expr<!fir.char<1,?>>
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_16]] to %[[VAL_6]]#0 : !hlfir.expr<10x!fir.char<1,?>>, !fir.box<!fir.array<10x!fir.char<1,?>>>
+! CHECK: hlfir.destroy %[[VAL_16]] : !hlfir.expr<10x!fir.char<1,?>>
+! CHECK: return
+! CHECK: }
end module
diff --git a/flang/test/Lower/array-expression.f90 b/flang/test/Lower/array-expression.f90
deleted file mode 100644
index bdfbe6dd35095..0000000000000
--- a/flang/test/Lower/array-expression.f90
+++ /dev/null
@@ -1,1265 +0,0 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-
-! CHECK-LABEL: func @_QPtest1
-subroutine test1(a,b,c,n)
- integer :: n
- real, intent(out) :: a(n)
- real, intent(in) :: b(n), c(n)
- ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
- ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
- ! CHECK-DAG: %[[C:.*]] = fir.array_load %arg2(%
- ! CHECK: %[[T:.*]] = fir.do_loop
- ! CHECK-DAG: %[[Bi:.*]] = fir.array_fetch %[[B]]
- ! CHECK-DAG: %[[Ci:.*]] = fir.array_fetch %[[C]]
- ! CHECK: %[[rv:.*]] = arith.addf %[[Bi]], %[[Ci]]
- ! CHECK: fir.array_update %{{.*}}, %[[rv]], %
- a = b + c
- ! CHECK: fir.array_merge_store %[[A]], %[[T]] to %arg0
-end subroutine test1
-
-! CHECK-LABEL: func @_QPtest1b
-subroutine test1b(a,b,c,d,n)
- integer :: n
- real, intent(out) :: a(n)
- real, intent(in) :: b(n), c(n), d(n)
- ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
- ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
- ! CHECK-DAG: %[[C:.*]] = fir.array_load %arg2(%
- ! CHECK-DAG: %[[D:.*]] = fir.array_load %arg3(%
- ! CHECK: %[[T:.*]] = fir.do_loop
- ! CHECK-DAG: %[[Bi:.*]] = fir.array_fetch %[[B]]
- ! CHECK-DAG: %[[Ci:.*]] = fir.array_fetch %[[C]]
- ! CHECK: %[[rv1:.*]] = arith.addf %[[Bi]], %[[Ci]]
- ! CHECK: %[[Di:.*]] = fir.array_fetch %[[D]]
- ! CHECK: %[[rv:.*]] = arith.addf %[[rv1]], %[[Di]]
- ! CHECK: fir.array_update %{{.*}}, %[[rv]], %
- a = b + c + d
- ! CHECK: fir.array_merge_store %[[A]], %[[T]] to %arg0
-end subroutine test1b
-
-! CHECK-LABEL: func @_QPtest2(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}) {
-! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_5:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_7:.*]] = fir.array_load %[[VAL_2]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_4]]#1, %[[VAL_8]] : index
-! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_9]] to %[[VAL_10]] step %[[VAL_8]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_5]]) -> (!fir.array<?xf32>) {
-! CHECK: %[[VAL_14:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_12]] : (!fir.array<?xf32>, index) -> f32
-! CHECK: %[[VAL_15:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_12]] : (!fir.array<?xf32>, index) -> f32
-! CHECK: %[[VAL_16:.*]] = arith.addf %[[VAL_14]], %[[VAL_15]] {{.*}}: f32
-! CHECK: %[[VAL_17:.*]] = fir.array_update %[[VAL_13]], %[[VAL_16]], %[[VAL_12]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
-! CHECK: fir.result %[[VAL_17]] : !fir.array<?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_5]], %[[VAL_18:.*]] to %[[VAL_0]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.box<!fir.array<?xf32>>
-! CHECK: return
-! CHECK: }
-subroutine test2(a,b,c)
- real, intent(out) :: a(:)
- real, intent(in) :: b(:), c(:)
- a = b + c
-end subroutine test2
-
-! CHECK-LABEL: func @_QPtest3
-subroutine test3(a,b,c,n)
- integer :: n
- real, intent(out) :: a(n)
- real, intent(in) :: b(n), c
- ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
- ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
- ! CHECK-DAG: %[[C:.*]] = fir.load %arg2
- ! CHECK: %[[T:.*]] = fir.do_loop
- ! CHECK: %[[Bi:.*]] = fir.array_fetch %[[B]]
- ! CHECK: %[[rv:.*]] = arith.addf %[[Bi]], %[[C]]
- ! CHECK: %[[Ti:.*]] = fir.array_update %{{.*}}, %[[rv]], %
- ! CHECK: fir.result %[[Ti]]
- a = b + c
- ! CHECK: fir.array_merge_store %[[A]], %[[T]] to %arg0
-end subroutine test3
-
-! CHECK-LABEL: func @_QPtest4
-subroutine test4(a,b,c)
-! TODO: this declaration fails in CallInterface lowering
-! real, allocatable, intent(out) :: a(:)
- real :: a(100) ! FIXME: fake it for now
- real, intent(in) :: b(:), c
- ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
- ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1
- ! CHECK: fir.do_loop
- ! CHECK: fir.array_fetch %[[B]], %
- ! CHECK: fir.array_update
- a = b + c
- ! CHECK: fir.array_merge_store %[[A]], %{{.*}} to %arg0
-end subroutine test4
-
-! CHECK-LABEL: func @_QPtest5
-subroutine test5(a,b,c)
-! TODO: this declaration fails in CallInterface lowering
-! real, allocatable, intent(out) :: a(:)
-! real, pointer, intent(in) :: b(:)
- real :: a(100), b(100) ! FIXME: fake it for now
- real, intent(in) :: c
- ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
- ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
- ! CHECK: fir.do_loop
- ! CHECK: fir.array_fetch %[[B]], %
- ! CHECK: fir.array_update
- a = b + c
- ! CHECK: fir.array_merge_store %[[A]], %{{.*}} to %arg0
-end subroutine test5
-
-! CHECK-LABEL: func @_QPtest6(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_4:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> i64
-! CHECK: %[[VAL_7A:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
-! CHECK: %[[C0:.*]] = arith.constant 0 : index
-! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_7A]], %[[C0]] : index
-! CHECK: %[[VAL_7:.*]] = arith.select %[[CMP]], %[[VAL_7A]], %[[C0]] : index
-! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32>
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i32) -> i64
-! CHECK: %[[VAL_10A:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
-! CHECK: %[[C0_2:.*]] = arith.constant 0 : index
-! CHECK: %[[CMP_2:.*]] = arith.cmpi sgt, %[[VAL_10A]], %[[C0_2]] : index
-! CHECK: %[[VAL_10:.*]] = arith.select %[[CMP_2]], %[[VAL_10A]], %[[C0_2]] : index
-! CHECK: %[[VAL_11:.*]] = arith.constant 3 : i64
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
-! CHECK: %[[VAL_13:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
-! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> i64
-! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
-! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_17]], %[[VAL_12]] : index
-! CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_19]], %[[VAL_14]] : index
-! CHECK: %[[VAL_21:.*]] = arith.divsi %[[VAL_20]], %[[VAL_14]] : index
-! CHECK: %[[VAL_22:.*]] = arith.cmpi sgt, %[[VAL_21]], %[[VAL_18]] : index
-! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_21]], %[[VAL_18]] : index
-! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_25:.*]] = fir.slice %[[VAL_12]], %[[VAL_17]], %[[VAL_14]] : (index, index, index) -> !fir.slice<1>
-! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_0]](%[[VAL_24]]) {{\[}}%[[VAL_25]]] : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_27:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_28:.*]] = fir.array_load %[[VAL_1]](%[[VAL_27]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_29:.*]] = fir.load %[[VAL_2]] : !fir.ref<f32>
-! CHECK: %[[VAL_30:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_31:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_23]], %[[VAL_30]] : index
-! CHECK: %[[VAL_33:.*]] = fir.do_loop %[[VAL_34:.*]] = %[[VAL_31]] to %[[VAL_32]] step %[[VAL_30]] unordered iter_args(%[[VAL_35:.*]] = %[[VAL_26]]) -> (!fir.array<?xf32>) {
-! CHECK: %[[VAL_36:.*]] = fir.array_fetch %[[VAL_28]], %[[VAL_34]] : (!fir.array<?xf32>, index) -> f32
-! CHECK: %[[VAL_37:.*]] = arith.addf %[[VAL_36]], %[[VAL_29]] {{.*}}: f32
-! CHECK: %[[VAL_38:.*]] = fir.array_update %[[VAL_35]], %[[VAL_37]], %[[VAL_34]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
-! CHECK: fir.result %[[VAL_38]] : !fir.array<?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_26]], %[[VAL_39:.*]] to %[[VAL_0]]{{\[}}%[[VAL_25]]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.ref<!fir.array<?xf32>>, !fir.slice<1>
-! CHECK: return
-! CHECK: }
-
-subroutine test6(a,b,c,n,m)
- integer :: n, m
- real, intent(out) :: a(n)
- real, intent(in) :: b(m), c
- a(3:n:4) = b + c
-end subroutine test6
-
-! CHECK-LABEL: func @_QPtest6a(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x50xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
-! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_3:.*]] = arith.constant 50 : index
-! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_1]](%[[VAL_5]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
-! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_8:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_9:.*]] = fir.undefined index
-! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_8]] : (i64) -> index
-! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_10]], %[[VAL_7]] : index
-! CHECK: %[[VAL_12:.*]] = arith.constant 41 : i64
-! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
-! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
-! CHECK: %[[VAL_16:.*]] = arith.constant 50 : i64
-! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
-! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_19:.*]] = fir.slice %[[VAL_8]], %[[VAL_9]], %[[VAL_9]], %[[VAL_13]], %[[VAL_17]], %[[VAL_15]] : (i64, index, index, index, index, index) -> !fir.slice<2>
-! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_0]](%[[VAL_18]]) {{\[}}%[[VAL_19]]] : (!fir.ref<!fir.array<10x50xf32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.array<10x50xf32>
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_4]], %[[VAL_21]] : index
-! CHECK: %[[VAL_24:.*]] = fir.do_loop %[[VAL_25:.*]] = %[[VAL_22]] to %[[VAL_23]] step %[[VAL_21]] unordered iter_args(%[[VAL_26:.*]] = %[[VAL_6]]) -> (!fir.array<10xf32>) {
-! CHECK: %[[VAL_27:.*]] = fir.array_fetch %[[VAL_20]], %[[VAL_11]], %[[VAL_25]] : (!fir.array<10x50xf32>, index, index) -> f32
-! CHECK: %[[VAL_28:.*]] = fir.array_update %[[VAL_26]], %[[VAL_27]], %[[VAL_25]] : (!fir.array<10xf32>, f32, index) -> !fir.array<10xf32>
-! CHECK: fir.result %[[VAL_28]] : !fir.array<10xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_29:.*]] to %[[VAL_1]] : !fir.array<10xf32>, !fir.array<10xf32>, !fir.ref<!fir.array<10xf32>>
-! CHECK: return
-! CHECK: }
-
-subroutine test6a(a,b)
- ! copy part of 1 row to b. a's projection has rank 1.
- real :: a(10,50)
- real :: b(10)
- b = a(4,41:50)
-end subroutine test6a
-
-! CHECK-LABEL: func @_QPtest6b(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x50xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
-! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_3:.*]] = arith.constant 50 : index
-! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_6:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_7:.*]] = fir.undefined index
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
-! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_8]], %[[VAL_5]] : index
-! CHECK: %[[VAL_10:.*]] = arith.constant 41 : i64
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
-! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
-! CHECK: %[[VAL_14:.*]] = arith.constant 50 : i64
-! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
-! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_15]], %[[VAL_11]] : index
-! CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_17]], %[[VAL_13]] : index
-! CHECK: %[[VAL_19:.*]] = arith.divsi %[[VAL_18]], %[[VAL_13]] : index
-! CHECK: %[[VAL_20:.*]] = arith.cmpi sgt, %[[VAL_19]], %[[VAL_16]] : index
-! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_19]], %[[VAL_16]] : index
-! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_23:.*]] = fir.slice %[[VAL_6]], %[[VAL_7]], %[[VAL_7]], %[[VAL_11]], %[[VAL_15]], %[[VAL_13]] : (i64, index, index, index, index, index) -> !fir.slice<2>
-! CHECK: %[[VAL_24:.*]] = fir.array_load %[[VAL_0]](%[[VAL_22]]) {{\[}}%[[VAL_23]]] : (!fir.ref<!fir.array<10x50xf32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.array<10x50xf32>
-! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_1]](%[[VAL_25]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
-! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_21]], %[[VAL_27]] : index
-! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_24]]) -> (!fir.array<10x50xf32>) {
-! CHECK: %[[VAL_33:.*]] = fir.array_fetch %[[VAL_26]], %[[VAL_31]] : (!fir.array<10xf32>, index) -> f32
-! CHECK: %[[VAL_34:.*]] = fir.array_update %[[VAL_32]], %[[VAL_33]], %[[VAL_9]], %[[VAL_31]] : (!fir.array<10x50xf32>, f32, index, index) -> !fir.array<10x50xf32>
-! CHECK: fir.result %[[VAL_34]] : !fir.array<10x50xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_24]], %[[VAL_35:.*]] to %[[VAL_0]]{{\[}}%[[VAL_23]]] : !fir.array<10x50xf32>, !fir.array<10x50xf32>, !fir.ref<!fir.array<10x50xf32>>, !fir.slice<2>
-! CHECK: return
-! CHECK: }
-
-subroutine test6b(a,b)
- ! copy b to columns 41 to 50 of row 4 of a
- real :: a(10,50)
- real :: b(10)
- a(4,41:50) = b
-end subroutine test6b
-
-! CHECK-LABEL: func @_QPtest7(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i32) -> i64
-! CHECK: %[[VAL_5A:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
-! CHECK: %[[C0:.*]] = arith.constant 0 : index
-! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_5A]], %[[C0]] : index
-! CHECK: %[[VAL_5:.*]] = arith.select %[[CMP]], %[[VAL_5A]], %[[C0]] : index
-! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> i64
-! CHECK: %[[VAL_8A:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
-! CHECK: %[[C0_2:.*]] = arith.constant 0 : index
-! CHECK: %[[CMP_2:.*]] = arith.cmpi sgt, %[[VAL_8A]], %[[C0_2]] : index
-! CHECK: %[[VAL_8:.*]] = arith.select %[[CMP_2]], %[[VAL_8A]], %[[C0_2]] : index
-! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_0]](%[[VAL_9]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_0]](%[[VAL_11]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_14:.*]] = fir.array_load %[[VAL_1]](%[[VAL_13]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
-! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_5]], %[[VAL_15]] : index
-! CHECK: %[[VAL_18:.*]] = fir.do_loop %[[VAL_19:.*]] = %[[VAL_16]] to %[[VAL_17]] step %[[VAL_15]] unordered iter_args(%[[VAL_20:.*]] = %[[VAL_10]]) -> (!fir.array<?xf32>) {
-! CHECK: %[[VAL_21:.*]] = fir.array_fetch %[[VAL_12]], %[[VAL_19]] : (!fir.array<?xf32>, index) -> f32
-! CHECK: %[[VAL_22:.*]] = fir.array_fetch %[[VAL_14]], %[[VAL_19]] : (!fir.array<?xf32>, index) -> f32
-! CHECK: %[[VAL_23:.*]] = arith.addf %[[VAL_21]], %[[VAL_22]] {{.*}}: f32
-! CHECK: %[[VAL_24:.*]] = fir.array_update %[[VAL_20]], %[[VAL_23]], %[[VAL_19]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
-! CHECK: fir.result %[[VAL_24]] : !fir.array<?xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_10]], %[[VAL_25:.*]] to %[[VAL_0]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.ref<!fir.array<?xf32>>
-! CHECK: return
-! CHECK: }
-
-! This is NOT a conflict. `a` appears on both the lhs and rhs here, but there
-! are no loop-carried dependences and no copy is needed.
-subroutine test7(a,b,n)
- integer :: n
- real, intent(inout) :: a(n)
- real, intent(in) :: b(n)
- a = a + b
-end subroutine test7
-
-! CHECK-LABEL: func @_QPtest8(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}) {
-! CHECK: %[[VAL_2:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_4:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
-! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_7:.*]] = arith.subi %[[VAL_5]], %[[VAL_6]] : i64
-! CHECK: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_7]] : (!fir.ref<!fir.array<100xi32>>, i64) -> !fir.ref<i32>
-! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_8]] : !fir.ref<i32>
-! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_11:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_2]], %[[VAL_10]] : index
-! CHECK: %[[VAL_13:.*]] = fir.do_loop %[[VAL_14:.*]] = %[[VAL_11]] to %[[VAL_12]] step %[[VAL_10]] unordered iter_args(%[[VAL_15:.*]] = %[[VAL_4]]) -> (!fir.array<100xi32>) {
-! CHECK: %[[VAL_16:.*]] = fir.array_update %[[VAL_15]], %[[VAL_9]], %[[VAL_14]] : (!fir.array<100xi32>, i32, index) -> !fir.array<100xi32>
-! CHECK: fir.result %[[VAL_16]] : !fir.array<100xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_4]], %[[VAL_17:.*]] to %[[VAL_0]] : !fir.array<100xi32>, !fir.array<100xi32>, !fir.ref<!fir.array<100xi32>>
-! CHECK: return
-! CHECK: }
-
-subroutine test8(a,b)
- integer :: a(100), b(100)
- a = b(1)
-end subroutine test8
-
-subroutine test10(a,b,c,d)
- interface
- ! Function takea an array and yields an array
- function foo(a) result(res)
- real :: a(:) ! FIXME: must be before res or semantics fails
- ! as `size(a,1)` fails to resolve to the argument
- real, dimension(size(a,1)) :: res
- end function foo
- end interface
- interface
- ! Function takes an array and yields a scalar
- real function bar(a)
- real :: a(:)
- end function bar
- end interface
- real :: a(:), b(:), c(:), d(:)
-! a = b + foo(c + foo(d + bar(a)))
-end subroutine test10
-
-! CHECK-LABEL: func @_QPtest11(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_3:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}) {
-! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_6:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_7:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_0]](%[[VAL_8]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
-! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]](%[[VAL_10]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
-! CHECK: %[[VAL_12:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_2]](%[[VAL_14]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
-! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_3]](%[[VAL_16]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
-! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.array<100xf32>
-! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_18]](%[[VAL_19]]) : (!fir.heap<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_12]], %[[VAL_21]] : index
-! CHECK: %[[VAL_24:.*]] = fir.do_loop %[[VAL_25:.*]] = %[[VAL_22]] to %[[VAL_23]] step %[[VAL_21]] unordered iter_args(%[[VAL_26:.*]] = %[[VAL_20]]) -> (!fir.array<100xf32>) {
-! CHECK: %[[VAL_27:.*]] = fir.array_fetch %[[VAL_15]], %[[VAL_25]] : (!fir.array<100xf32>, index) -> f32
-! CHECK: %[[VAL_28:.*]] = fir.array_fetch %[[VAL_17]], %[[VAL_25]] : (!fir.array<100xf32>, index) -> f32
-! CHECK: %[[VAL_29:.*]] = arith.addf %[[VAL_27]], %[[VAL_28]] {{.*}}: f32
-! CHECK: %[[VAL_30:.*]] = fir.array_update %[[VAL_26]], %[[VAL_29]], %[[VAL_25]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
-! CHECK: fir.result %[[VAL_30]] : !fir.array<100xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_20]], %[[VAL_31:.*]] to %[[VAL_18]] : !fir.array<100xf32>, !fir.array<100xf32>, !fir.heap<!fir.array<100xf32>>
-! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<100xf32>>) -> !fir.ref<!fir.array<100xf32>>
-! CHECK: %[[VAL_33:.*]] = fir.call @_QPbar(%[[VAL_32]]) {{.*}}: (!fir.ref<!fir.array<100xf32>>) -> f32
-! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_35:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_4]], %[[VAL_34]] : index
-! CHECK: %[[VAL_37:.*]] = fir.do_loop %[[VAL_38:.*]] = %[[VAL_35]] to %[[VAL_36]] step %[[VAL_34]] unordered iter_args(%[[VAL_39:.*]] = %[[VAL_9]]) -> (!fir.array<100xf32>) {
-! CHECK: %[[VAL_40:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_38]] : (!fir.array<100xf32>, index) -> f32
-! CHECK: %[[VAL_41:.*]] = arith.addf %[[VAL_40]], %[[VAL_33]] {{.*}}: f32
-! CHECK: %[[VAL_42:.*]] = fir.array_update %[[VAL_39]], %[[VAL_41]], %[[VAL_38]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
-! CHECK: fir.result %[[VAL_42]] : !fir.array<100xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_43:.*]] to %[[VAL_0]] : !fir.array<100xf32>, !fir.array<100xf32>, !fir.ref<!fir.array<100xf32>>
-! CHECK: fir.freemem %[[VAL_18]]
-! CHECK: return
-! CHECK: }
-
-subroutine test11(a,b,c,d)
- real, external :: bar
- real :: a(100), b(100), c(100), d(100)
- a = b + bar(c + d)
-end subroutine test11
-
-! CHECK-LABEL: func @_QPtest12
-subroutine test12(a,b,c,d,n,m)
- integer :: n, m
- ! CHECK: %[[n:.*]] = fir.load %arg4
- ! CHECK: %[[m:.*]] = fir.load %arg5
- ! CHECK: %[[sha:.*]] = fir.shape %
- ! CHECK: %[[A:.*]] = fir.array_load %arg0(%[[sha]])
- ! CHECK: %[[shb:.*]] = fir.shape %
- ! CHECK: %[[B:.*]] = fir.array_load %arg1(%[[shb]])
- ! CHECK: %[[C:.*]] = fir.array_load %arg2(%
- ! CHECK: %[[D:.*]] = fir.array_load %arg3(%
- ! CHECK: %[[tmp:.*]] = fir.allocmem !fir.array<?xf32>, %{{.*}} {{{.*}}uniq_name = ".array.expr"}
- ! CHECK: %[[T:.*]] = fir.array_load %[[tmp]](%
- real, external :: bar
- real :: a(n), b(n), c(m), d(m)
- ! CHECK: %[[LOOP:.*]] = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %[[T]])
- ! CHECK-DAG: fir.array_fetch %[[C]]
- ! CHECK-DAG: fir.array_fetch %[[D]]
- ! CHECK: fir.array_merge_store %[[T]], %[[LOOP]]
- ! CHECK: %[[CALL:.*]] = fir.call @_QPbar
- ! CHECK: %[[LOOP2:.*]] = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %[[A]])
- ! CHECK: fir.array_fetch %[[B]]
- ! CHECK: fir.array_merge_store %[[A]], %[[LOOP2]] to %arg0
- a = b + bar(c + d)
- ! CHECK: fir.freemem %[[tmp]] : !fir.heap<!fir.array<?xf32>>
-end subroutine test12
-
-! CHECK-LABEL: func @_QPtest13
-subroutine test13(a,b,c,d,n,m,i)
- real :: a(n), b(m)
- complex :: c(n), d(m)
- ! CHECK: %[[A_shape:.*]] = fir.shape %
- ! CHECK: %[[A:.*]] = fir.array_load %arg0(%[[A_shape]])
- ! CHECK: %[[B_shape:.*]] = fir.shape %
- ! CHECK: %[[B_slice:.*]] = fir.slice %
- ! CHECK: %[[B:.*]] = fir.array_load %arg1(%[[B_shape]]) [%[[B_slice]]]
- ! CHECK: %[[C_shape:.*]] = fir.shape %
- ! CHECK: %[[C_slice:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} path %
- ! CHECK: %[[C:.*]] = fir.array_load %arg2(%[[C_shape]]) [%[[C_slice]]]
- ! CHECK: %[[D_shape:.*]] = fir.shape %
- ! CHECK: %[[D_slice:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} path %
- ! CHECK: %[[D:.*]] = fir.array_load %arg3(%[[D_shape]]) [%[[D_slice]]]
- ! CHECK: = arith.constant -6.2598534E+18 : f32
- ! CHECK: %[[A_result:.*]] = fir.do_loop %{{.*}} = %{{.*}} iter_args(%[[A_in:.*]] = %[[A]]) ->
- ! CHECK: fir.array_fetch %[[B]],
- ! CHECK: fir.array_fetch %[[C]],
- ! CHECK: fir.array_fetch %[[D]],
- ! CHECK: fir.array_update %[[A_in]],
- a = b(i:i+2*n-2:2) + c%im - d(i:i+2*n-2:2)%re + x'deadbeef'
- ! CHECK: fir.array_merge_store %[[A]], %[[A_result]] to %arg0
-end subroutine test13
-
-! Test elemental call to function f
-! CHECK-LABEL: func @_QPtest14(
-! CHECK-SAME: %[[a:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
-subroutine test14(a,b)
- ! CHECK: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
- interface
- real elemental function f1(i)
- real, intent(in) :: i
- end function f1
- end interface
- real :: a(100), b(100)
- ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
- ! CHECK: %[[ishift:.*]] = arith.addi %[[i]], %c1{{.*}} : index
- ! CHECK: %[[tmp:.*]] = fir.array_coor %[[a]](%{{.*}}) %[[ishift]] : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>
- ! CHECK: %[[fres:.*]] = fir.call @_QPf1(%[[tmp]]) {{.*}}: (!fir.ref<f32>) -> f32
- ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
- ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
- ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
- b = f1(a)
-end subroutine test14
-
-! Test elemental intrinsic function (abs)
-! CHECK-LABEL: func @_QPtest15(
-! CHECK-SAME: %[[a:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
-subroutine test15(a,b)
- ! CHECK-DAG: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
- ! CHECK-DAG: %[[aarr:.*]] = fir.array_load %[[a]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
- real :: a(100), b(100)
- ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
- ! CHECK: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
- ! CHECK: %[[fres:.*]] = math.absf %[[val]] {{.*}}: f32
- ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
- ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
- ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
- b = abs(a)
-end subroutine test15
-
-! Test elemental call to function f2 with VALUE attribute
-! CHECK-LABEL: func @_QPtest16(
-! CHECK-SAME: %[[a:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
-subroutine test16(a,b)
- ! CHECK-DAG: %[[aarr:.*]] = fir.array_load %[[a]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
- ! CHECK-DAG: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
- interface
- real elemental function f2(i)
- real, VALUE :: i
- end function f2
- end interface
- real :: a(100), b(100)
- ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
- ! CHECK: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
- ! CHECK: %[[fres:.*]] = fir.call @_QPf2(%[[val]]) {{.*}}: (f32) -> f32
- ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
- ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
- ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
- b = f2(a)
-end subroutine test16
-
-! Test elemental impure call to function f3.
-!
-! CHECK-LABEL: func @_QPtest17(
-! CHECK-SAME: %[[a:[^:]+]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:[^:]+]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[c:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
-subroutine test17(a,b,c)
- ! CHECK-DAG: %[[aarr:.*]] = fir.array_load %[[a]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
- ! CHECK-DAG: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>) -> !fir.array<100xf32>
- interface
- real elemental impure function f3(i,j,k)
- real, intent(inout) :: i, j, k
- end function f3
- end interface
- real :: a(100), b(2:101), c(3:102)
- ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
- ! CHECK-DAG: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
- ! CHECK-DAG: %[[ic:.*]] = arith.addi %[[i]], %c3{{.*}} : index
- ! CHECK-DAG: %[[ccoor:.*]] = fir.array_coor %[[c]](%{{.*}}) %[[ic]] : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
- ! CHECK-DAG: %[[ib:.*]] = arith.addi %[[i]], %c2{{.*}} : index
- ! CHECK-DAG: %[[bcoor:.*]] = fir.array_coor %[[b]](%{{.*}}) %[[ib]] : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
- ! CHECK-DAG: %[[ia:.*]] = arith.addi %[[i]], %c1{{.*}} : index
- ! CHECK-DAG: %[[acoor:.*]] = fir.array_coor %[[a]](%{{.*}}) %[[ia]] : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>
- ! CHECK: %[[fres:.*]] = fir.call @_QPf3(%[[ccoor]], %[[bcoor]], %[[acoor]]) {{.*}}: (!fir.ref<f32>, !fir.ref<f32>, !fir.ref<f32>) -> f32
- ! CHECK: %[[fadd:.*]] = arith.addf %[[val]], %[[fres]] {{.*}}: f32
- ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fadd]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
-
- ! See 10.1.4.p2 note 1. The expression below is illegal if `f3` defines the
- ! argument `a` for this statement. Since, this cannot be proven statically by
- ! the compiler, the constraint is left to the user. The compiler may give a
- ! warning that `k` is neither VALUE nor INTENT(IN) and the actual argument,
- ! `a`, appears elsewhere in the same statement.
- b = a + f3(c, b, a)
-
- ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
- ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
-end subroutine test17
-
-! CHECK-LABEL: func @_QPtest18() {
-! CHECK: %[[VAL_0:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.array<10x10xi32> {bindc_name = "array", fir.target, uniq_name = "_QFtest18Earray"}
-! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtest18Ei"}
-! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xi32>>> {bindc_name = "row_i", uniq_name = "_QFtest18Erow_i"}
-! CHECK: %[[VAL_5:.*]] = fir.zero_bits !fir.ptr<!fir.array<?xi32>>
-! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_5]](%[[VAL_7]]) : (!fir.ptr<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
-! CHECK: fir.store %[[VAL_8]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
-! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i32) -> i64
-! CHECK: %[[VAL_12:.*]] = fir.undefined index
-! CHECK: %[[VAL_13:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
-! CHECK: %[[VAL_15:.*]] = arith.addi %[[VAL_9]], %[[VAL_1]] : index
-! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_15]], %[[VAL_9]] : index
-! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_0]], %[[VAL_1]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_18:.*]] = fir.slice %[[VAL_11]], %[[VAL_12]], %[[VAL_12]], %[[VAL_9]], %[[VAL_16]], %[[VAL_14]] : (i64, index, index, index, index, index) -> !fir.slice<2>
-! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_2]](%[[VAL_17]]) {{\[}}%[[VAL_18]]] : (!fir.ref<!fir.array<10x10xi32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.box<!fir.array<?xi32>>
-! CHECK: %[[VAL_20:.*]] = fir.rebox %[[VAL_19]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
-! CHECK: fir.store %[[VAL_20]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
-! CHECK: return
-! CHECK: }
-
-subroutine test18
- integer, target :: array(10,10)
- integer, pointer :: row_i(:)
- row_i => array(i, :)
-end subroutine test18
-
-! CHECK-LABEL: func @_QPtest_column_and_row_order(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<2x3xf32>>{{.*}}) {
-! CHECK: %[[VAL_1:.*]] = arith.constant 2 : index
-! CHECK: %[[VAL_2:.*]] = arith.constant 3 : index
-! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_1]], %[[VAL_2]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_4:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) : (!fir.ref<!fir.array<2x3xf32>>, !fir.shape<2>) -> !fir.array<2x3xf32>
-! CHECK: %[[VAL_6:.*]] = arith.constant 4.200000e+01 : f32
-! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_1]], %[[VAL_7]] : index
-! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_2]], %[[VAL_7]] : index
-! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_8]] to %[[VAL_10]] step %[[VAL_7]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_4]]) -> (!fir.array<2x3xf32>) {
-! CHECK: %[[VAL_14:.*]] = fir.do_loop %[[VAL_15:.*]] = %[[VAL_8]] to %[[VAL_9]] step %[[VAL_7]] unordered iter_args(%[[VAL_16:.*]] = %[[VAL_13]]) -> (!fir.array<2x3xf32>) {
-! CHECK: %[[VAL_17:.*]] = fir.array_update %[[VAL_16]], %[[VAL_6]], %[[VAL_15]], %[[VAL_12]] : (!fir.array<2x3xf32>, f32, index, index) -> !fir.array<2x3xf32>
-! CHECK: fir.result %[[VAL_17]] : !fir.array<2x3xf32>
-! CHECK: }
-! CHECK: fir.result %[[VAL_18:.*]] : !fir.array<2x3xf32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_4]], %[[VAL_19:.*]] to %[[VAL_0]] : !fir.array<2x3xf32>, !fir.array<2x3xf32>, !fir.ref<!fir.array<2x3xf32>>
-! CHECK: return
-! CHECK: }
-
-subroutine test_column_and_row_order(x)
- real :: x(2,3)
- x = 42
-end subroutine
-
-! CHECK-LABEL: func @_QPtest_assigning_to_assumed_shape_slices(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}) {
-! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_2:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i64) -> index
-! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_4]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
-! CHECK: %[[VAL_6:.*]] = arith.addi %[[VAL_1]], %[[VAL_5]]#1 : index
-! CHECK: %[[VAL_7:.*]] = arith.subi %[[VAL_6]], %[[VAL_1]] : index
-! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_7]], %[[VAL_1]] : index
-! CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_9]], %[[VAL_3]] : index
-! CHECK: %[[VAL_11:.*]] = arith.divsi %[[VAL_10]], %[[VAL_3]] : index
-! CHECK: %[[VAL_12:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_8]] : index
-! CHECK: %[[VAL_13:.*]] = arith.select %[[VAL_12]], %[[VAL_11]], %[[VAL_8]] : index
-! CHECK: %[[VAL_14:.*]] = fir.slice %[[VAL_1]], %[[VAL_7]], %[[VAL_3]] : (index, index, index) -> !fir.slice<1>
-! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_0]] {{\[}}%[[VAL_14]]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>) -> !fir.array<?xi32>
-! CHECK: %[[VAL_16:.*]] = arith.constant 42 : i32
-! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_13]], %[[VAL_17]] : index
-! CHECK: %[[VAL_20:.*]] = fir.do_loop %[[VAL_21:.*]] = %[[VAL_18]] to %[[VAL_19]] step %[[VAL_17]] unordered iter_args(%[[VAL_22:.*]] = %[[VAL_15]]) -> (!fir.array<?xi32>) {
-! CHECK: %[[VAL_23:.*]] = fir.array_update %[[VAL_22]], %[[VAL_16]], %[[VAL_21]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
-! CHECK: fir.result %[[VAL_23]] : !fir.array<?xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_15]], %[[VAL_24:.*]] to %[[VAL_0]]{{\[}}%[[VAL_14]]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.box<!fir.array<?xi32>>, !fir.slice<1>
-! CHECK: return
-! CHECK: }
-
-subroutine test_assigning_to_assumed_shape_slices(x)
- integer :: x(:)
- x(::2) = 42
-end subroutine
-
-! CHECK-LABEL: func @_QPtest19a(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
-! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<10x!fir.char<1,10>>
-! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_6]](%[[VAL_10]]) : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<10x!fir.char<1,10>>
-! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_4]], %[[VAL_12]] : index
-! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_13]] to %[[VAL_14]] step %[[VAL_12]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_9]]) -> (!fir.array<10x!fir.char<1,10>>) {
-! CHECK: %[[VAL_18:.*]] = fir.array_access %[[VAL_11]], %[[VAL_16]] : (!fir.array<10x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_17]], %[[VAL_16]] : (!fir.array<10x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_20:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (index) -> i64
-! CHECK: %[[VAL_23:.*]] = arith.muli %[[VAL_21]], %[[VAL_22]] : i64
-! CHECK: %[[VAL_24:.*]] = arith.constant false
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_25]], %[[VAL_26]], %[[VAL_23]], %[[VAL_24]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_27:.*]] = fir.array_amend %[[VAL_17]], %[[VAL_19]] : (!fir.array<10x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<10x!fir.char<1,10>>
-! CHECK: fir.result %[[VAL_27]] : !fir.array<10x!fir.char<1,10>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_28:.*]] to %[[VAL_3]] : !fir.array<10x!fir.char<1,10>>, !fir.array<10x!fir.char<1,10>>, !fir.ref<!fir.array<10x!fir.char<1,10>>>
-! CHECK: return
-! CHECK: }
-
-subroutine test19a(a,b)
- character(LEN=10) a(10)
- character(LEN=10) b(10)
- a = b
-end subroutine test19a
-
-! CHECK-LABEL: func @_QPtest19b(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<2>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<2>{{.*}}) {
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<2>) -> (!fir.ref<!fir.char<2,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<2,?>>) -> !fir.ref<!fir.array<20x!fir.char<2,8>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 20 : index
-! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<2>) -> (!fir.ref<!fir.char<2,?>>, index)
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<2,?>>) -> !fir.ref<!fir.array<20x!fir.char<2,10>>>
-! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_8:.*]] = arith.constant 20 : index
-! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_3]](%[[VAL_9]]) : (!fir.ref<!fir.array<20x!fir.char<2,8>>>, !fir.shape<1>) -> !fir.array<20x!fir.char<2,8>>
-! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_7]](%[[VAL_11]]) : (!fir.ref<!fir.array<20x!fir.char<2,10>>>, !fir.shape<1>) -> !fir.array<20x!fir.char<2,10>>
-! CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_4]], %[[VAL_13]] : index
-! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_14]] to %[[VAL_15]] step %[[VAL_13]] unordered iter_args(%[[VAL_18:.*]] = %[[VAL_10]]) -> (!fir.array<20x!fir.char<2,8>>) {
-! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_12]], %[[VAL_17]] : (!fir.array<20x!fir.char<2,10>>, index) -> !fir.ref<!fir.char<2,10>>
-! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_18]], %[[VAL_17]] : (!fir.array<20x!fir.char<2,8>>, index) -> !fir.ref<!fir.char<2,8>>
-! CHECK: %[[VAL_21:.*]] = arith.constant 8 : index
-! CHECK: %[[VAL_22:.*]] = arith.cmpi slt, %[[VAL_21]], %[[VAL_6]] : index
-! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_21]], %[[VAL_6]] : index
-! CHECK: %[[VAL_24:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_23]] : (index) -> i64
-! CHECK: %[[VAL_26:.*]] = arith.muli %[[VAL_24]], %[[VAL_25]] : i64
-! CHECK: %[[VAL_27:.*]] = arith.constant false
-! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<2,8>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<2,10>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_28]], %[[VAL_29]], %[[VAL_26]], %[[VAL_27]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_30:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_31:.*]] = arith.subi %[[VAL_21]], %[[VAL_30]] : index
-! CHECK: %[[VAL_32:.*]] = arith.constant 32 : i16
-! CHECK: %[[VAL_33:.*]] = fir.undefined !fir.char<2>
-! CHECK: %[[VAL_34:.*]] = fir.insert_value %[[VAL_33]], %[[VAL_32]], [0 : index] : (!fir.char<2>, i16) -> !fir.char<2>
-! CHECK: %[[VAL_35:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_36:.*]] = %[[VAL_23]] to %[[VAL_31]] step %[[VAL_35]] {
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<2,8>>) -> !fir.ref<!fir.array<8x!fir.char<2>>>
-! CHECK: %[[VAL_38:.*]] = fir.coordinate_of %[[VAL_37]], %[[VAL_36]] : (!fir.ref<!fir.array<8x!fir.char<2>>>, index) -> !fir.ref<!fir.char<2>>
-! CHECK: fir.store %[[VAL_34]] to %[[VAL_38]] : !fir.ref<!fir.char<2>>
-! CHECK: }
-! CHECK: %[[VAL_39:.*]] = fir.array_amend %[[VAL_18]], %[[VAL_20]] : (!fir.array<20x!fir.char<2,8>>, !fir.ref<!fir.char<2,8>>) -> !fir.array<20x!fir.char<2,8>>
-! CHECK: fir.result %[[VAL_39]] : !fir.array<20x!fir.char<2,8>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_10]], %[[VAL_40:.*]] to %[[VAL_3]] : !fir.array<20x!fir.char<2,8>>, !fir.array<20x!fir.char<2,8>>, !fir.ref<!fir.array<20x!fir.char<2,8>>>
-! CHECK: return
-! CHECK: }
-
-subroutine test19b(a,b)
- character(KIND=2, LEN=8) a(20)
- character(KIND=2, LEN=10) b(20)
- a = b
-end subroutine test19b
-
-! CHECK-LABEL: func @_QPtest19c(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<4>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<4>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<4>) -> (!fir.ref<!fir.char<4,?>>, index)
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<30x!fir.char<4,10>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_6:.*]] = arith.constant 30 : index
-! CHECK: %[[VAL_7:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<4>) -> (!fir.ref<!fir.char<4,?>>, index)
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<30x!fir.char<4,?>>>
-! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_9]] : i32
-! CHECK: %[[VAL_11:.*]] = arith.select %[[VAL_10]], %[[VAL_8]], %[[VAL_9]] : i32
-! CHECK: %[[VAL_13:.*]] = arith.constant 30 : index
-! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_12]](%[[VAL_14]]) typeparams %[[VAL_11]] : (!fir.ref<!fir.array<30x!fir.char<4,?>>>, !fir.shape<1>, i32) -> !fir.array<30x!fir.char<4,?>>
-! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_5]](%[[VAL_16]]) : (!fir.ref<!fir.array<30x!fir.char<4,10>>>, !fir.shape<1>) -> !fir.array<30x!fir.char<4,10>>
-! CHECK: %[[VAL_18:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_13]], %[[VAL_18]] : index
-! CHECK: %[[VAL_21:.*]] = fir.do_loop %[[VAL_22:.*]] = %[[VAL_19]] to %[[VAL_20]] step %[[VAL_18]] unordered iter_args(%[[VAL_23:.*]] = %[[VAL_15]]) -> (!fir.array<30x!fir.char<4,?>>) {
-! CHECK: %[[VAL_24:.*]] = fir.array_access %[[VAL_17]], %[[VAL_22]] : (!fir.array<30x!fir.char<4,10>>, index) -> !fir.ref<!fir.char<4,10>>
-! CHECK: %[[VAL_25:.*]] = fir.array_access %[[VAL_23]], %[[VAL_22]] typeparams %[[VAL_11]] : (!fir.array<30x!fir.char<4,?>>, index, i32) -> !fir.ref<!fir.char<4,?>>
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_11]] : (i32) -> index
-! CHECK: %[[VAL_27:.*]] = arith.cmpi slt, %[[VAL_26]], %[[VAL_4]] : index
-! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_26]], %[[VAL_4]] : index
-! CHECK: %[[VAL_29:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_28]] : (index) -> i64
-! CHECK: %[[VAL_31:.*]] = arith.muli %[[VAL_29]], %[[VAL_30]] : i64
-! CHECK: %[[VAL_32:.*]] = arith.constant false
-! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<4,10>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_33]], %[[VAL_34]], %[[VAL_31]], %[[VAL_32]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_35:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_11]], %[[VAL_35]] : i32
-! CHECK: %[[VAL_37:.*]] = arith.constant 32 : i32
-! CHECK: %[[VAL_38:.*]] = fir.undefined !fir.char<4>
-! CHECK: %[[VAL_39:.*]] = fir.insert_value %[[VAL_38]], %[[VAL_37]], [0 : index] : (!fir.char<4>, i32) -> !fir.char<4>
-! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_36]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_42:.*]] = %[[VAL_28]] to %[[VAL_41]] step %[[VAL_40]] {
-! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<?x!fir.char<4>>>
-! CHECK: %[[VAL_44:.*]] = fir.coordinate_of %[[VAL_43]], %[[VAL_42]] : (!fir.ref<!fir.array<?x!fir.char<4>>>, index) -> !fir.ref<!fir.char<4>>
-! CHECK: fir.store %[[VAL_39]] to %[[VAL_44]] : !fir.ref<!fir.char<4>>
-! CHECK: }
-! CHECK: %[[VAL_45:.*]] = fir.array_amend %[[VAL_23]], %[[VAL_25]] : (!fir.array<30x!fir.char<4,?>>, !fir.ref<!fir.char<4,?>>) -> !fir.array<30x!fir.char<4,?>>
-! CHECK: fir.result %[[VAL_45]] : !fir.array<30x!fir.char<4,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_15]], %[[VAL_46:.*]] to %[[VAL_12]] typeparams %[[VAL_11]] : !fir.array<30x!fir.char<4,?>>, !fir.array<30x!fir.char<4,?>>, !fir.ref<!fir.array<30x!fir.char<4,?>>>, i32
-! CHECK: return
-! CHECK: }
-
-subroutine test19c(a,b,i)
- character(KIND=4, LEN=i) a(30)
- character(KIND=4, LEN=10) b(30)
- a = b
-end subroutine test19c
-
-! CHECK-LABEL: func @_QPtest19d(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<40x!fir.char<1,?>>>
-! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_7:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[VAL_6]] : i32
-! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_7]], %[[VAL_5]], %[[VAL_6]] : i32
-! CHECK: %[[VAL_10:.*]] = arith.constant 40 : index
-! CHECK: %[[VAL_11:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_11]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<40x!fir.char<1,?>>>
-! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK: %[[VAL_13:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_14:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_13]] : i32
-! CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_14]], %[[VAL_12]], %[[VAL_13]] : i32
-! CHECK: %[[VAL_17:.*]] = arith.constant 40 : index
-! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_19:.*]] = fir.array_load %[[VAL_9]](%[[VAL_18]]) typeparams %[[VAL_8]] : (!fir.ref<!fir.array<40x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<40x!fir.char<1,?>>
-! CHECK: %[[VAL_20:.*]] = fir.shape %[[VAL_17]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_21:.*]] = fir.array_load %[[VAL_16]](%[[VAL_20]]) typeparams %[[VAL_15]] : (!fir.ref<!fir.array<40x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<40x!fir.char<1,?>>
-! CHECK: %[[VAL_22:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_24:.*]] = arith.subi %[[VAL_10]], %[[VAL_22]] : index
-! CHECK: %[[VAL_25:.*]] = fir.do_loop %[[VAL_26:.*]] = %[[VAL_23]] to %[[VAL_24]] step %[[VAL_22]] unordered iter_args(%[[VAL_27:.*]] = %[[VAL_19]]) -> (!fir.array<40x!fir.char<1,?>>) {
-! CHECK: %[[VAL_28:.*]] = fir.array_access %[[VAL_21]], %[[VAL_26]] typeparams %[[VAL_15]] : (!fir.array<40x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_29:.*]] = fir.array_access %[[VAL_27]], %[[VAL_26]] typeparams %[[VAL_8]] : (!fir.array<40x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_8]] : (i32) -> index
-! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
-! CHECK: %[[VAL_32:.*]] = arith.cmpi slt, %[[VAL_30]], %[[VAL_31]] : index
-! CHECK: %[[VAL_33:.*]] = arith.select %[[VAL_32]], %[[VAL_30]], %[[VAL_31]] : index
-! CHECK: %[[VAL_34:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_33]] : (index) -> i64
-! CHECK: %[[VAL_36:.*]] = arith.muli %[[VAL_34]], %[[VAL_35]] : i64
-! CHECK: %[[VAL_37:.*]] = arith.constant false
-! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_38]], %[[VAL_39]], %[[VAL_36]], %[[VAL_37]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_40:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_8]], %[[VAL_40]] : i32
-! CHECK: %[[VAL_42:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_43:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_44:.*]] = fir.insert_value %[[VAL_43]], %[[VAL_42]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_45:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_41]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_47:.*]] = %[[VAL_33]] to %[[VAL_46]] step %[[VAL_45]] {
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_47]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_44]] to %[[VAL_49]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_50:.*]] = fir.array_amend %[[VAL_27]], %[[VAL_29]] : (!fir.array<40x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<40x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_50]] : !fir.array<40x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_19]], %[[VAL_51:.*]] to %[[VAL_9]] typeparams %[[VAL_8]] : !fir.array<40x!fir.char<1,?>>, !fir.array<40x!fir.char<1,?>>, !fir.ref<!fir.array<40x!fir.char<1,?>>>, i32
-! CHECK: return
-! CHECK: }
-
-subroutine test19d(a,b,i,j)
- character(i) a(40)
- character(j) b(40)
- a = b
-end subroutine test19d
-
-! CHECK-LABEL: func @_QPtest19e(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<50x!fir.char<1,?>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 50 : index
-! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<50x!fir.char<1,?>>>
-! CHECK: %[[VAL_7:.*]] = arith.constant 50 : index
-! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<50x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<50x!fir.char<1,?>>
-! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_6]](%[[VAL_10]]) typeparams %[[VAL_5]]#1 : (!fir.ref<!fir.array<50x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<50x!fir.char<1,?>>
-! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_4]], %[[VAL_12]] : index
-! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_13]] to %[[VAL_14]] step %[[VAL_12]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_9]]) -> (!fir.array<50x!fir.char<1,?>>) {
-! CHECK: %[[VAL_18:.*]] = fir.array_access %[[VAL_11]], %[[VAL_16]] typeparams %[[VAL_5]]#1 : (!fir.array<50x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_17]], %[[VAL_16]] typeparams %[[VAL_2]]#1 : (!fir.array<50x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_2]]#1, %[[VAL_5]]#1 : index
-! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_2]]#1, %[[VAL_5]]#1 : index
-! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (index) -> i64
-! CHECK: %[[VAL_24:.*]] = arith.muli %[[VAL_22]], %[[VAL_23]] : i64
-! CHECK: %[[VAL_25:.*]] = arith.constant false
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_26]], %[[VAL_27]], %[[VAL_24]], %[[VAL_25]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_28:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_2]]#1, %[[VAL_28]] : index
-! CHECK: %[[VAL_30:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_31:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_32:.*]] = fir.insert_value %[[VAL_31]], %[[VAL_30]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_33:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_34:.*]] = %[[VAL_21]] to %[[VAL_29]] step %[[VAL_33]] {
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_36:.*]] = fir.coordinate_of %[[VAL_35]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_32]] to %[[VAL_36]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_37:.*]] = fir.array_amend %[[VAL_17]], %[[VAL_19]] : (!fir.array<50x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<50x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_37]] : !fir.array<50x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_38:.*]] to %[[VAL_3]] typeparams %[[VAL_2]]#1 : !fir.array<50x!fir.char<1,?>>, !fir.array<50x!fir.char<1,?>>, !fir.ref<!fir.array<50x!fir.char<1,?>>>, index
-! CHECK: return
-! CHECK: }
-
-subroutine test19e(a,b)
- character(*) a(50)
- character(*) b(50)
- a = b
-end subroutine test19e
-
-! CHECK-LABEL: func @_QPtest19f(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<60x!fir.char<1,?>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 60 : index
-! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<60x!fir.char<1,?>>>
-! CHECK: %[[VAL_7:.*]] = arith.constant 60 : index
-! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<60x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<60x!fir.char<1,?>>
-! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QQclX70726566697820) : !fir.ref<!fir.char<1,7>>
-! CHECK: %[[VAL_11:.*]] = arith.constant 7 : index
-! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_6]](%[[VAL_12]]) typeparams %[[VAL_5]]#1 : (!fir.ref<!fir.array<60x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<60x!fir.char<1,?>>
-! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_4]], %[[VAL_14]] : index
-! CHECK: %[[VAL_17:.*]] = fir.do_loop %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_14]] unordered iter_args(%[[VAL_19:.*]] = %[[VAL_9]]) -> (!fir.array<60x!fir.char<1,?>>) {
-! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_13]], %[[VAL_18]] typeparams %[[VAL_5]]#1 : (!fir.array<60x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_21:.*]] = arith.addi %[[VAL_11]], %[[VAL_5]]#1 : index
-! CHECK: %[[VAL_22:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_21]] : index) {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_23:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_11]] : (index) -> i64
-! CHECK: %[[VAL_25:.*]] = arith.muli %[[VAL_23]], %[[VAL_24]] : i64
-! CHECK: %[[VAL_26:.*]] = arith.constant false
-! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_27]], %[[VAL_28]], %[[VAL_25]], %[[VAL_26]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_21]], %[[VAL_29]] : index
-! CHECK: fir.do_loop %[[VAL_31:.*]] = %[[VAL_11]] to %[[VAL_30]] step %[[VAL_29]] {
-! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_31]], %[[VAL_11]] : index
-! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_32]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_35:.*]] = fir.load %[[VAL_34]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_37:.*]] = fir.coordinate_of %[[VAL_36]], %[[VAL_31]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_35]] to %[[VAL_37]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_38:.*]] = fir.array_access %[[VAL_19]], %[[VAL_18]] typeparams %[[VAL_2]]#1 : (!fir.array<60x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_39:.*]] = arith.cmpi slt, %[[VAL_2]]#1, %[[VAL_21]] : index
-! CHECK: %[[VAL_40:.*]] = arith.select %[[VAL_39]], %[[VAL_2]]#1, %[[VAL_21]] : index
-! CHECK: %[[VAL_41:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_40]] : (index) -> i64
-! CHECK: %[[VAL_43:.*]] = arith.muli %[[VAL_41]], %[[VAL_42]] : i64
-! CHECK: %[[VAL_44:.*]] = arith.constant false
-! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_45]], %[[VAL_46]], %[[VAL_43]], %[[VAL_44]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_2]]#1, %[[VAL_47]] : index
-! CHECK: %[[VAL_49:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_50:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_51:.*]] = fir.insert_value %[[VAL_50]], %[[VAL_49]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_52:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_53:.*]] = %[[VAL_40]] to %[[VAL_48]] step %[[VAL_52]] {
-! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_53]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_51]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_56:.*]] = fir.array_amend %[[VAL_19]], %[[VAL_38]] : (!fir.array<60x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<60x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_56]] : !fir.array<60x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_57:.*]] to %[[VAL_3]] typeparams %[[VAL_2]]#1 : !fir.array<60x!fir.char<1,?>>, !fir.array<60x!fir.char<1,?>>, !fir.ref<!fir.array<60x!fir.char<1,?>>>, index
-! CHECK: return
-! CHECK: }
-
-subroutine test19f(a,b)
- character(*) a(60)
- character(*) b(60)
- a = "prefix " // b
-end subroutine test19f
-
-! CHECK-LABEL: func @_QPtest19g(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<4>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<2>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<2>) -> (!fir.ref<!fir.char<2,?>>, index)
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<2,?>>) -> !fir.ref<!fir.array<140x!fir.char<2,13>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 13 : index
-! CHECK: %[[VAL_6:.*]] = arith.constant 140 : index
-! CHECK: %[[VAL_7:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<4>) -> (!fir.ref<!fir.char<4,?>>, index)
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<70x!fir.char<4,?>>>
-! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_9]] : i32
-! CHECK: %[[VAL_11:.*]] = arith.select %[[VAL_10]], %[[VAL_8]], %[[VAL_9]] : i32
-! CHECK: %[[VAL_13:.*]] = arith.constant 70 : index
-! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_12]](%[[VAL_14]]) typeparams %[[VAL_11]] : (!fir.ref<!fir.array<70x!fir.char<4,?>>>, !fir.shape<1>, i32) -> !fir.array<70x!fir.char<4,?>>
-! CHECK: %[[VAL_16:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
-! CHECK: %[[VAL_18:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
-! CHECK: %[[VAL_20:.*]] = arith.constant 140 : i64
-! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i64) -> index
-! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_23:.*]] = fir.slice %[[VAL_17]], %[[VAL_21]], %[[VAL_19]] : (index, index, index) -> !fir.slice<1>
-! CHECK: %[[VAL_24:.*]] = fir.array_load %[[VAL_5]](%[[VAL_22]]) {{\[}}%[[VAL_23]]] : (!fir.ref<!fir.array<140x!fir.char<2,13>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<140x!fir.char<2,13>>
-! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i32) -> i64
-! CHECK: %[[char_temp:.*]] = fir.alloca !fir.char<4,?>(%{{[0-9]+}} : i64) {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_13]], %[[VAL_27]] : index
-! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_15]]) -> (!fir.array<70x!fir.char<4,?>>) {
-! CHECK: %[[VAL_33:.*]] = fir.array_access %[[VAL_24]], %[[VAL_31]] : (!fir.array<140x!fir.char<2,13>>, index) -> !fir.ref<!fir.char<2,13>>
-! CHECK: %[[VAL_34:.*]] = fir.alloca !fir.char<4,?>(%[[VAL_4]] : index)
-! CHECK: %[[VAL_46:.*]] = fir.array_access %[[VAL_32]], %[[VAL_31]] typeparams %[[VAL_11]] : (!fir.array<70x!fir.char<4,?>>, index, i32) -> !fir.ref<!fir.char<4,?>>
-! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_11]] : (i32) -> index
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_26]] : (i64) -> index
-! CHECK: %[[VAL_49:.*]] = arith.cmpi slt, %[[VAL_47]], %[[VAL_48]] : index
-! CHECK: %[[VAL_50:.*]] = arith.select %[[VAL_49]], %[[VAL_47]], %[[VAL_48]] : index
-! CHECK: %[[VAL_51:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_50]] : (index) -> i64
-! CHECK: %[[VAL_53:.*]] = arith.muli %[[VAL_51]], %[[VAL_52]] : i64
-! CHECK: %[[VAL_54:.*]] = arith.constant false
-! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_46]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_56:.*]] = fir.convert %[[char_temp]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_55]], %[[VAL_56]], %[[VAL_53]], %[[VAL_54]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_57:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_58:.*]] = arith.subi %[[VAL_11]], %[[VAL_57]] : i32
-! CHECK: %[[VAL_59:.*]] = arith.constant 32 : i32
-! CHECK: %[[VAL_60:.*]] = fir.undefined !fir.char<4>
-! CHECK: %[[VAL_61:.*]] = fir.insert_value %[[VAL_60]], %[[VAL_59]], [0 : index] : (!fir.char<4>, i32) -> !fir.char<4>
-! CHECK: %[[VAL_62:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_58]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_64:.*]] = %[[VAL_50]] to %[[VAL_63]] step %[[VAL_62]] {
-! CHECK: %[[VAL_65:.*]] = fir.convert %[[VAL_46]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<?x!fir.char<4>>>
-! CHECK: %[[VAL_66:.*]] = fir.coordinate_of %[[VAL_65]], %[[VAL_64]] : (!fir.ref<!fir.array<?x!fir.char<4>>>, index) -> !fir.ref<!fir.char<4>>
-! CHECK: fir.store %[[VAL_61]] to %[[VAL_66]] : !fir.ref<!fir.char<4>>
-! CHECK: }
-! CHECK: %[[VAL_67:.*]] = fir.array_amend %[[VAL_32]], %[[VAL_46]] : (!fir.array<70x!fir.char<4,?>>, !fir.ref<!fir.char<4,?>>) -> !fir.array<70x!fir.char<4,?>>
-! CHECK: fir.result %[[VAL_67]] : !fir.array<70x!fir.char<4,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_15]], %[[VAL_68:.*]] to %[[VAL_12]] typeparams %[[VAL_11]] : !fir.array<70x!fir.char<4,?>>, !fir.array<70x!fir.char<4,?>>, !fir.ref<!fir.array<70x!fir.char<4,?>>>, i32
-! CHECK: return
-! CHECK: }
-
-subroutine test19g(a,b,i)
- character(kind=4,len=i) a(70)
- character(kind=2,len=13) b(140)
- a = b(1:140:2)
-end subroutine test19g
-
-! CHECK-LABEL: func @_QPtest19h(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<70x!fir.char<1,?>>>
-! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
-! CHECK: %[[VAL_7:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[VAL_6]] : i32
-! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_7]], %[[VAL_5]], %[[VAL_6]] : i32
-! CHECK: %[[VAL_10:.*]] = arith.constant 70 : index
-! CHECK: %[[VAL_11:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
-! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
-! CHECK: %[[VAL_15A:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
-! CHECK: %[[C0:.*]] = arith.constant 0 : index
-! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_15A]], %[[C0]] : index
-! CHECK: %[[VAL_15:.*]] = arith.select %[[CMP]], %[[VAL_15A]], %[[C0]] : index
-! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_9]](%[[VAL_16]]) typeparams %[[VAL_8]] : (!fir.ref<!fir.array<70x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<70x!fir.char<1,?>>
-! CHECK: %[[VAL_18:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
-! CHECK: %[[VAL_20:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i64) -> index
-! CHECK: %[[VAL_22:.*]] = arith.constant 140 : i64
-! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
-! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_25:.*]] = fir.slice %[[VAL_19]], %[[VAL_23]], %[[VAL_21]] : (index, index, index) -> !fir.slice<1>
-! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_12]](%[[VAL_24]]) {{\[}}%[[VAL_25]]] typeparams %[[VAL_11]]#1 : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.array<?x!fir.char<1,?>>
-! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_10]], %[[VAL_27]] : index
-! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_17]]) -> (!fir.array<70x!fir.char<1,?>>) {
-! CHECK: %[[VAL_33:.*]] = fir.array_access %[[VAL_26]], %[[VAL_31]] typeparams %[[VAL_11]]#1 : (!fir.array<?x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_34:.*]] = fir.array_access %[[VAL_32]], %[[VAL_31]] typeparams %[[VAL_8]] : (!fir.array<70x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_8]] : (i32) -> index
-! CHECK: %[[VAL_36:.*]] = arith.cmpi slt, %[[VAL_35]], %[[VAL_11]]#1 : index
-! CHECK: %[[VAL_37:.*]] = arith.select %[[VAL_36]], %[[VAL_35]], %[[VAL_11]]#1 : index
-! CHECK: %[[VAL_38:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_37]] : (index) -> i64
-! CHECK: %[[VAL_40:.*]] = arith.muli %[[VAL_38]], %[[VAL_39]] : i64
-! CHECK: %[[VAL_41:.*]] = arith.constant false
-! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_33]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_42]], %[[VAL_43]], %[[VAL_40]], %[[VAL_41]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_44:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_8]], %[[VAL_44]] : i32
-! CHECK: %[[VAL_46:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_47:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_48:.*]] = fir.insert_value %[[VAL_47]], %[[VAL_46]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_49:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_50:.*]] = fir.convert %[[VAL_45]] : (i32) -> index
-! CHECK: fir.do_loop %[[VAL_51:.*]] = %[[VAL_37]] to %[[VAL_50]] step %[[VAL_49]] {
-! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_53:.*]] = fir.coordinate_of %[[VAL_52]], %[[VAL_51]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_48]] to %[[VAL_53]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_54:.*]] = fir.array_amend %[[VAL_32]], %[[VAL_34]] : (!fir.array<70x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<70x!fir.char<1,?>>
-! CHECK: fir.result %[[VAL_54]] : !fir.array<70x!fir.char<1,?>>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_17]], %[[VAL_55:.*]] to %[[VAL_9]] typeparams %[[VAL_8]] : !fir.array<70x!fir.char<1,?>>, !fir.array<70x!fir.char<1,?>>, !fir.ref<!fir.array<70x!fir.char<1,?>>>, i32
-! CHECK: return
-! CHECK: }
-
-subroutine test19h(a,b,i,j)
- character(i) a(70)
- character(*) b(j)
- a = b(1:140:2)
-end subroutine test19h
-
-! CHECK-LABEL: func @_QPtest_elemental_character_intrinsic(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
-! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
-! CHECK: %[[VAL_7:.*]] = arith.constant 2 : index
-! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_9:.*]] = arith.constant 6 : i32
-! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_12:.*]] = arith.constant {{.*}} : i32
-! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_9]], %[[VAL_11]], %[[VAL_12]]) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
-! CHECK: %[[VAL_15:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_17:.*]] = fir.shape_shift %[[VAL_7]], %[[VAL_8]] : (index, index) -> !fir.shapeshift<1>
-! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.array<10xi32>
-! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_18]](%[[VAL_19]]) : (!fir.heap<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.array<10xi32>
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_15]], %[[VAL_21]] : index
-! CHECK: %[[VAL_24:.*]] = fir.do_loop %[[VAL_25:.*]] = %[[VAL_22]] to %[[VAL_23]] step %[[VAL_21]] unordered iter_args(%[[VAL_26:.*]] = %[[VAL_20]]) -> (!fir.array<10xi32>) {
-! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_25]], %[[VAL_27]] : index
-! CHECK: %[[VAL_29:.*]] = fir.array_coor %[[VAL_3]](%[[VAL_16]]) %[[VAL_28]] typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_25]], %[[VAL_7]] : index
-! CHECK: %[[VAL_31:.*]] = fir.array_coor %[[VAL_6]](%[[VAL_17]]) %[[VAL_30]] typeparams %[[VAL_5]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shapeshift<1>, index, index) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_32:.*]] = arith.constant false
-! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_5]]#1 : (index) -> i64
-! CHECK: %[[VAL_37:.*]] = fir.call @_FortranAScan1(%[[VAL_33]], %[[VAL_34]], %[[VAL_35]], %[[VAL_36]], %[[VAL_32]]) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i8>, i64, i1) -> i64
-! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (i64) -> i32
-! CHECK: %[[VAL_39:.*]] = fir.array_update %[[VAL_26]], %[[VAL_38]], %[[VAL_25]] : (!fir.array<10xi32>, i32, index) -> !fir.array<10xi32>
-! CHECK: fir.result %[[VAL_39]] : !fir.array<10xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_20]], %[[VAL_40:.*]] to %[[VAL_18]] : !fir.array<10xi32>, !fir.array<10xi32>, !fir.heap<!fir.array<10xi32>>
-! CHECK: %[[VAL_41:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_42:.*]] = fir.embox %[[VAL_18]](%[[VAL_41]]) : (!fir.heap<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
-! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_42]] : (!fir.box<!fir.array<10xi32>>) -> !fir.box<none>
-! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_13]], %[[VAL_43]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
-! CHECK: fir.freemem %[[VAL_18]] : !fir.heap<!fir.array<10xi32>>
-! CHECK: %[[VAL_45:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_13]]) {{.*}}: (!fir.ref<i8>) -> i32
-! CHECK: return
-! CHECK: }
-
-subroutine test_elemental_character_intrinsic(c1, c2)
- character(*) :: c1(10), c2(2:11)
- print *, scan(c1, c2)
-end subroutine
-
-! Check that the expression is folded, with the first operation being an add
-! between x and y, resulting in a new temporary array.
-!
-! CHECK-LABEL: func @_QPtest20a(
-! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<4xi32>> {{.*}}, %[[ARG1:.*]]: !fir.ref<!fir.array<4xi32>> {{.*}}, %[[ARG2:.*]]: !fir.ref<!fir.array<4xi32>>
-! CHECK: %[[Z:.*]] = fir.array_load %[[ARG2]]({{.*}}) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: %[[X:.*]] = fir.array_load %[[ARG0]]({{.*}}) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: %[[Y:.*]] = fir.array_load %[[ARG1]]({{.*}}) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: %[[TEMP:.*]] = fir.allocmem !fir.array<4xi32>
-! CHECK: %[[TEMP2:.*]] = fir.array_load %[[TEMP]]({{.*}}) : (!fir.heap<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: {{.*}} = fir.do_loop %[[I:.*]] = {{.*}} iter_args(%[[TEMP3:.*]] = %[[TEMP2]]) -> (!fir.array<4xi32>) {
-! CHECK: %[[XI:.*]] = fir.array_fetch %[[X]], %[[I]] : (!fir.array<4xi32>, index) -> i32
-! CHECK: %[[YI:.*]] = fir.array_fetch %[[Y]], %[[I]] : (!fir.array<4xi32>, index) -> i32
-! CHECK: %[[ADD:.*]] = arith.addi %[[XI]], %[[YI]] : i32
-! CHECK: {{.*}} = fir.array_update %[[TEMP3]], %[[ADD]], %[[I]] : (!fir.array<4xi32>, i32, index) -> !fir.array<4xi32>
-! CHECK: }
-subroutine test20a(x, y, z)
- integer :: x(4), y(4), z(4)
-
- z = (/x/) + (/y/)
-end subroutine
-
-! Check that the expression is not folded, with the first operations being
-! array constructions from x and y.
-!
-! CHECK-LABEL: func @_QPtest20b(
-! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<4xi32>> {{.*}}, %[[ARG1:.*]]: !fir.ref<!fir.array<2x2xi32>> {{.*}}, %[[ARG2:.*]]: !fir.ref<!fir.array<4xi32>>
-! CHECK: %[[Z:.*]] = fir.array_load %[[ARG2]]({{.*}}) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: %[[X:.*]] = fir.array_load %[[ARG0]]({{.*}}) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: %[[TEMP:.*]] = fir.allocmem !fir.array<4xi32>
-! CHECK: %[[TEMP2:.*]] = fir.array_load %[[TEMP]]({{.*}}) : (!fir.heap<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: {{.*}} = fir.do_loop %[[I:.*]] = {{.*}} iter_args(%[[TEMP3:.*]] = %[[TEMP2]]) -> (!fir.array<4xi32>) {
-! CHECK: %[[XI:.*]] = fir.array_fetch %[[X]], %[[I]] : (!fir.array<4xi32>, index) -> i32
-! CHECK: {{.*}} = fir.array_update %[[TEMP3]], %[[XI]], %[[I]] : (!fir.array<4xi32>, i32, index) -> !fir.array<4xi32>
-! CHECK: }
-! CHECK: %[[Y:.*]] = fir.array_load %[[ARG1]]({{.*}}) : (!fir.ref<!fir.array<2x2xi32>>, !fir.shape<2>) -> !fir.array<2x2xi32>
-! CHECK: %[[TEMP4:.*]] = fir.allocmem !fir.array<2x2xi32>
-! CHECK: %[[TEMP5:.*]] = fir.array_load %[[TEMP4]]({{.*}}) : (!fir.heap<!fir.array<2x2xi32>>, !fir.shape<2>) -> !fir.array<2x2xi32>
-! CHECK: {{.*}} = fir.do_loop %[[I:.*]] = {{.*}} iter_args(%[[TEMP6:.*]] = %[[TEMP5]]) -> (!fir.array<2x2xi32>) {
-! CHECK: {{.*}} = fir.do_loop %[[J:.*]] = {{.*}} iter_args(%[[TEMP7:.*]] = %[[TEMP6]]) -> (!fir.array<2x2xi32>) {
-! CHECK: %[[YJI:.*]] = fir.array_fetch %[[Y]], %[[J]], %[[I]] : (!fir.array<2x2xi32>, index, index) -> i32
-! CHECK: {{.*}} = fir.array_update %[[TEMP7]], %[[YJI]], %[[J]], %[[I]] : (!fir.array<2x2xi32>, i32, index, index) -> !fir.array<2x2xi32>
-! CHECK: }
-! CHECK: }
-subroutine test20b(x, y, z)
- integer :: x(4), y(2, 2), z(4)
-
- z = (/x/) + (/y/)
-end subroutine
-
-! CHECK-LABEL: func @_QPtest20c(
-! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<4xi32>> {{.*}}, %[[ARG1:.*]]: !fir.ref<!fir.array<2x2xi32>> {{.*}}
-
-! (/x/)
-! CHECK: %[[X:.*]] = fir.array_load %[[ARG0]]({{.*}}) : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: %[[ACX_MEM:.*]] = fir.allocmem !fir.array<4xi32>
-! CHECK: %[[ACX:.*]] = fir.array_load %[[ACX_MEM]]({{.*}}) : (!fir.heap<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-! CHECK: {{.*}} = fir.do_loop %[[I:.*]] = {{.*}} iter_args(%[[TEMP:.*]] = %[[ACX]]) -> (!fir.array<4xi32>) {
-! CHECK: %[[XI:.*]] = fir.array_fetch %[[X]], %[[I]] : (!fir.array<4xi32>, index) -> i32
-! CHECK: {{.*}} = fir.array_update %[[TEMP]], %[[XI]], %[[I]] : (!fir.array<4xi32>, i32, index) -> !fir.array<4xi32>
-! CHECK: }
-! CHECK: %[[T:.*]] = fir.coordinate_of %[[ACX_MEM2:.*]], %{{.*}} : (!fir.heap<!fir.array<4xi32>>, index) -> !fir.ref<i32>
-! CHECK: %[[T1:.*]] = fir.convert %[[T]] : (!fir.ref<i32>) -> !fir.ref<i8>
-! CHECK: %[[T2:.*]] = fir.convert %[[ACX_MEM]] : (!fir.heap<!fir.array<4xi32>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memcpy.p0.p0.i64(%[[T1]], %[[T2]], {{.*}})
-! CHECK: %[[ACX2:.*]] = fir.array_load %[[ACX_MEM2]]({{.*}}) : (!fir.heap<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-
-! (/y/)
-! CHECK: %[[Y:.*]] = fir.array_load %[[ARG1]]({{.*}}) : (!fir.ref<!fir.array<2x2xi32>>, !fir.shape<2>) -> !fir.array<2x2xi32>
-! CHECK: %[[ACY_MEM:.*]] = fir.allocmem !fir.array<2x2xi32>
-! CHECK: %[[ACY:.*]] = fir.array_load %[[ACY_MEM]]({{.*}}) : (!fir.heap<!fir.array<2x2xi32>>, !fir.shape<2>) -> !fir.array<2x2xi32>
-! CHECK: {{.*}} = fir.do_loop %[[I:.*]] = {{.*}} iter_args(%[[TEMP:.*]] = %[[ACY]]) -> (!fir.array<2x2xi32>) {
-! CHECK: {{.*}} = fir.do_loop %[[J:.*]] = {{.*}} iter_args(%[[TEMP2:.*]] = %[[TEMP]]) -> (!fir.array<2x2xi32>) {
-! CHECK: %[[YJI:.*]] = fir.array_fetch %[[Y]], %[[J]], %[[I]] : (!fir.array<2x2xi32>, index, index) -> i32
-! CHECK: {{.*}} = fir.array_update %[[TEMP2]], %[[YJI]], %[[J]], %[[I]] : (!fir.array<2x2xi32>, i32, index, index) -> !fir.array<2x2xi32>
-! CHECK: }
-! CHECK: }
-! CHECK: %[[T:.*]] = fir.coordinate_of %[[ACY_MEM2:.*]], {{.*}} : (!fir.heap<!fir.array<4xi32>>, index) -> !fir.ref<i32>
-! CHECK: %[[T1:.*]] = fir.convert %[[T]] : (!fir.ref<i32>) -> !fir.ref<i8>
-! CHECK: %[[T2:.*]] = fir.convert %[[ACY_MEM]] : (!fir.heap<!fir.array<2x2xi32>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memcpy.p0.p0.i64(%[[T1]], %[[T2]], {{.*}})
-! CHECK: %[[ACY2:.*]] = fir.array_load %[[ACY_MEM2]]({{.*}}) : (!fir.heap<!fir.array<4xi32>>, !fir.shape<1>) -> !fir.array<4xi32>
-
-! (/x/) /= (/y/)
-! CHECK: %[[RES_MEM:.*]] = fir.allocmem !fir.array<4x!fir.logical<4>>
-! CHECK: %[[RES:.*]] = fir.array_load %[[RES_MEM]]({{.*}}) : (!fir.heap<!fir.array<4x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<4x!fir.logical<4>>
-! CHECK: %{{.*}} = fir.do_loop %[[I:.*]] = {{.*}} iter_args(%[[TEMP:.*]] = %[[RES]]) -> (!fir.array<4x!fir.logical<4>>) {
-! CHECK: %[[XI:.*]] = fir.array_fetch %[[ACX2]], %[[I]] : (!fir.array<4xi32>, index) -> i32
-! CHECK: %[[YI:.*]] = fir.array_fetch %[[ACY2]], %[[I]] : (!fir.array<4xi32>, index) -> i32
-! CHECK: %[[T1:.*]] = arith.cmpi ne, %[[XI]], %[[YI]] : i32
-! CHECK: %[[T2:.*]] = fir.convert %[[T1]] : (i1) -> !fir.logical<4>
-! CHECK: {{.*}} = fir.array_update %[[TEMP]], %[[T2]], %[[I]] : (!fir.array<4x!fir.logical<4>>, !fir.logical<4>, index) -> !fir.array<4x!fir.logical<4>>
-! CHECK: }
-
-! any((/x/) /= (/y/))
-! CHECK: %[[T1:.*]] = fir.embox %[[RES_MEM]]({{.*}}) : (!fir.heap<!fir.array<4x!fir.logical<4>>>, !fir.shape<1>) -> !fir.box<!fir.array<4x!fir.logical<4>>>
-! CHECK: %[[T2:.*]] = fir.convert %[[T1]] : (!fir.box<!fir.array<4x!fir.logical<4>>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAAny(%[[T2]], {{.*}}){{.*}} : (!fir.box<none>, !fir.ref<i8>, i32, i32) -> i1
-subroutine test20c(x, y)
- integer :: x(4), y(2, 2)
-
- if (any((/x/) /= (/y/))) print *, "different"
-end subroutine
-
-! CHECK: func private @_QPbar(
diff --git a/flang/test/Lower/call-by-value-attr.f90 b/flang/test/Lower/call-by-value-attr.f90
index 97028edfb8d77..c46d5ceaf282e 100644
--- a/flang/test/Lower/call-by-value-attr.f90
+++ b/flang/test/Lower/call-by-value-attr.f90
@@ -1,5 +1,7 @@
! Test for PassBy::BaseAddressValueAttribute
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
+
+!CHECK-LABEL: func @_QQmain()
program call_by_value_attr
interface
subroutine subri(val)
@@ -10,93 +12,43 @@ subroutine subra(val)
end subroutine subra
end interface
-!CHECK-LABEL: func @_QQmain()
integer :: v
integer, dimension(10) :: a
integer, dimension(15) :: b
+ ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare{{.*}}a"
+ ! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare{{.*}}b"
+ ! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare{{.*}}v"
v = 17
call subri(v)
- !CHECK: %[[ARRAY_A:.*]] = fir.address_of(@_QFEa)
- !CHECK: %[[CONST_10_1:.*]] = arith.constant 10 : index
- !CHECK: %[[ARRAY_B:.*]] = fir.address_of(@_QFEb)
- !CHECK: %[[CONST_15_1:.*]] = arith.constant 15 : index
- !CHECK: %[[VALUE:.*]] = fir.alloca i32 {bindc_name = "v", {{.*}}}
- !CHECK: %[[CONST:.*]] = arith.constant 17
- !CHECK: fir.store %[[CONST]] to %[[VALUE]]
- !CHECK: %[[LOAD:.*]] = fir.load %[[VALUE]]
- !CHECK: fir.call @_QPsubri(%[[LOAD]]) {{.*}}: {{.*}}
+ ! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<i32>
+ ! CHECK: fir.call @_QPsubri(%[[VAL_11]]) fastmath<contract> : (i32) -> ()
a = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 /)
- !CHECK: %[[SHAPE_1:.*]] = fir.shape %[[CONST_10_1]]
- !CHECK: %[[ARRAY_LOAD_1:.*]] = fir.array_load %[[ARRAY_A]](%[[SHAPE_1]]) : {{.*}}
- !CHECK: %[[ARRAY_INIT_A:.*]] = fir.address_of({{.*}})
- !CHECK: %[[CONST_10_2:.*]] = arith.constant 10 : index
- !CHECK: %[[SHAPE_2:.*]] = fir.shape %[[CONST_10_2]]
- !CHECK: %[[ARRAY_LOAD_2:.*]] = fir.array_load %[[ARRAY_INIT_A]](%[[SHAPE_2]]) : {{.*}}
- !CHECK: %[[DO_1:.*]] = fir.do_loop {{.*}} {
- !CHECK: }
- !CHECK: fir.array_merge_store %[[ARRAY_LOAD_1]], %[[DO_1]] to %[[ARRAY_A]]
- !CHECK: %[[ARRAY_COPY:.*]] = fir.allocmem !fir.array<10xi32>, %[[CONST_10_1]] {uniq_name = ".copy"}
- !CHECK: %[[SHAPE_3:.*]] = fir.shape %[[CONST_10_1]]
- !CHECK: %[[ARRAY_LOAD_3:.*]] = fir.array_load %[[ARRAY_COPY]](%[[SHAPE_3]]) : {{.*}}
- !CHECK: %[[SHAPE_4:.*]] = fir.shape %[[CONST_10_1]]
- !CHECK: %[[ARRAY_LOAD_4:.*]] = fir.array_load %[[ARRAY_A]](%[[SHAPE_4]]) : {{.*}}
- !CHECK: %[[DO_2:.*]] = fir.do_loop {{.*}} {
- !CHECK: }
- !CHECK: fir.array_merge_store %[[ARRAY_LOAD_3]], %[[DO_2]] to %[[ARRAY_COPY]]
- !CHECK: %[[CONVERT:.*]] = fir.convert %[[ARRAY_COPY]] : (!fir.heap<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
- !CHECK: fir.call @_QPsubra(%[[CONVERT]])
call subra(a)
+ ! CHECK: %[[VAL_16:.*]] = hlfir.as_expr %[[VAL_3]]#0 : (!fir.ref<!fir.array<10xi32>>) -> !hlfir.expr<10xi32>
+ ! CHECK: %[[VAL_17:.*]]:3 = hlfir.associate %[[VAL_16]](%{{.*}}) {adapt.valuebyref} : (!hlfir.expr<10xi32>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>, i1)
+ ! CHECK: fir.call @_QPsubra(%[[VAL_17]]#1) fastmath<contract> : (!fir.ref<!fir.array<10xi32>>) -> ()
+
b = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 /)
- !CHECK: %[[SHAPE_5:.*]] = fir.shape %[[CONST_15_1]]
- !CHECK: %[[ARRAY_LOAD_5:.*]] = fir.array_load %[[ARRAY_B]](%[[SHAPE_5]]) : {{.*}}
- !CHECK: %[[ARRAY_INIT_B:.*]] = fir.address_of({{.*}})
- !CHECK: %[[CONST_15_2:.*]] = arith.constant 15 : index
- !CHECK: %[[SHAPE_6:.*]] = fir.shape %[[CONST_15_2]] : (index) -> !fir.shape<1>
- !CHECK: %[[ARRAY_LOAD_6:.*]] = fir.array_load %[[ARRAY_INIT_B]](%[[SHAPE_6]]) : (!fir.ref<!fir.array<15xi32>>, !fir.shape<1>) -> !fir.array<15xi32>
- !CHECK: %[[DO_3:.*]] = fir.do_loop {{.*}} {
- !CHECK: }
- !CHECK: fir.array_merge_store %[[ARRAY_LOAD_5]], %[[DO_3]] to %[[ARRAY_B]]
- !CHECK: %[[CONST_5:.*]] = arith.constant 5 : i64
- !CHECK: %[[CONV_5:.*]] = fir.convert %[[CONST_5]] : (i64) -> index
- !CHECK: %[[CONST_1:.*]] = arith.constant 1 : i64
- !CHECK: %[[CONV_1:.*]] = fir.convert %[[CONST_1]] : (i64) -> index
- !CHECK: %[[CONST_15_3:.*]] = arith.constant 15 : i64
- !CHECK: %[[CONV_15:.*]] = fir.convert %[[CONST_15_3]] : (i64) -> index
- !CHECK: %[[SHAPE_7:.*]] = fir.shape %[[CONST_15_1]] : (index) -> !fir.shape<1>
- !CHECK: %[[SLICE:.*]] = fir.slice %[[CONV_5]], %[[CONV_15]], %[[CONV_1]] : (index, index, index) -> !fir.slice<1>
- !CHECK: %[[BOX:.*]] = fir.embox %[[ARRAY_B]](%[[SHAPE_7]]) [%[[SLICE]]] : (!fir.ref<!fir.array<15xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<11xi32>>
- !CHECK: %[[BOX_NONE:.*]] = fir.convert %[[BOX]] : (!fir.box<!fir.array<11xi32>>) -> !fir.box<none>
- !CHECK: %[[IS_CONTIGUOUS:.*]] = fir.call @_FortranAIsContiguous(%[[BOX_NONE]]) {{.*}}: (!fir.box<none>) -> i1
- !CHECK: %[[ADDR:.*]] = fir.if %[[IS_CONTIGUOUS]] -> (!fir.heap<!fir.array<11xi32>>) {
- !CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[BOX]] : (!fir.box<!fir.array<11xi32>>) -> !fir.heap<!fir.array<11xi32>>
- !CHECKL fir.result %[[BOXADDR]] : !fir.heap<!fir.array<11xi32>>
- !CHECK: %[[CONST_0:.*]] = arith.constant 0 : index
- !CHECK: %[[DIMS:.*]]:3 = fir.box_dims %[[BOX]], %[[CONST_0]] : (!fir.box<!fir.array<11xi32>>, index) -> (index, index, index)
- !CHECK: %[[ARRAY_COPY_2:.*]] = fir.allocmem !fir.array<11xi32>, %[[DIMS]]#1 {uniq_name = ".copy"}
- !CHECK: %[[SHAPE_8:.*]] = fir.shape %[[DIMS]]#1 : (index) -> !fir.shape<1>
- !CHECK: %[[TEMP_BOX:.*]] = fir.embox %[[ARRAY_COPY_2]](%[[SHAPE_8]]) : (!fir.heap<!fir.array<11xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<11xi32>>
- !CHECK: fir.store %[[TEMP_BOX]] to %[[TEMP_BOX_LOC:.*]] : !fir.ref<!fir.box<!fir.array<11xi32>>>
- !CHECK: %[[TEMP_BOX_ADDR:.*]] = fir.convert %[[TEMP_BOX_LOC]] : (!fir.ref<!fir.box<!fir.array<11xi32>>>) -> !fir.ref<!fir.box<none>>
- !CHECK: %[[BOX_ADDR:.*]] = fir.convert %[[BOX]] : (!fir.box<!fir.array<11xi32>>) -> !fir.box<none>
- !CHECK: fir.call @_FortranAAssignTemporary(%[[TEMP_BOX_ADDR]], %[[BOX_ADDR]], %{{.*}}, %{{.*}}){{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
- !CHECK: fir.result %[[ARRAY_COPY_2]] : !fir.heap<!fir.array<11xi32>>
- !CHECK: %[[CONVERT_B:.*]] = fir.convert %[[ADDR]] : (!fir.heap<!fir.array<11xi32>>) -> !fir.ref<!fir.array<10xi32>>
- !CHECK: fir.call @_QPsubra(%[[CONVERT_B]])
- call subra(b(5:15))
+ call subra(b(5:14))
+ ! CHECK: %[[VAL_27:.*]] = hlfir.designate %[[VAL_7]]#0
+ ! CHECK: %[[VAL_28:.*]] = hlfir.as_expr %[[VAL_27]] : (!fir.ref<!fir.array<10xi32>>) -> !hlfir.expr<10xi32>
+ ! CHECK: %[[VAL_29:.*]]:3 = hlfir.associate %[[VAL_28]](%{{.*}}) {adapt.valuebyref} : (!hlfir.expr<10xi32>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>, i1)
+ ! CHECK: fir.call @_QPsubra(%[[VAL_29]]#1) fastmath<contract> : (!fir.ref<!fir.array<10xi32>>) -> ()
end program call_by_value_attr
-! CHECK-LABEL: func.func @_QPsubri(
-! CHECK-SAME: %[[VAL_0:.*]]: i32 {fir.bindc_name = "val"}) {
-! CHECK: %[[VAL_1:.*]] = fir.alloca i32
-! CHECK: fir.store %[[VAL_0]] to %[[VAL_1]] : !fir.ref<i32>
-! CHECK: fir.call @_QPtest_numeric_scalar_value(%[[VAL_1]]) {{.*}}: (!fir.ref<i32>) -> ()
-! CHECK: return
-! CHECK: }
-
subroutine subri(val)
integer, value :: val
call test_numeric_scalar_value(val)
end subroutine subri
+! CHECK-LABEL: func.func @_QPsubri(
+! CHECK-SAME: %[[VAL_0:.*]]: i32 {fir.bindc_name = "val"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]] = fir.alloca i32
+! CHECK: fir.store %[[VAL_0]] to %[[VAL_2]] : !fir.ref<i32>
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<value>, uniq_name = "_QFsubriEval"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: fir.call @_QPtest_numeric_scalar_value(%[[VAL_3]]#1) fastmath<contract> : (!fir.ref<i32>) -> ()
+! CHECK: return
+! CHECK: }
! CHECK-LABEL: func @_QPtest_litteral_copies_1
subroutine test_litteral_copies_1
@@ -108,16 +60,12 @@ subroutine takes_array_value(v)
end subroutine
end interface
integer, parameter :: p(100) = 42
- ! CHECK: %[[VAL_0:.*]] = arith.constant 100 : index
- ! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.array<100xi32>>
- ! CHECK: %[[VAL_5:.*]] = fir.allocmem !fir.array<100xi32>
- ! CHECK: fir.do_loop %
- ! CHECK: }
- ! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %[[VAL_5]] : !fir.array<100xi32>, !fir.array<100xi32>, !fir.heap<!fir.array<100xi32>>
- ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_5]] : (!fir.heap<!fir.array<100xi32>>) -> !fir.ref<!fir.array<4xi32>>
- ! CHECK: fir.call @_QPtakes_array_value(%[[VAL_17]]) {{.*}}: (!fir.ref<!fir.array<4xi32>>) -> ()
call takes_array_value(p)
- ! CHECK: fir.freemem %[[VAL_5]] : !fir.heap<!fir.array<100xi32>>
+ ! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare {{.*}}"_QQro.100xi4.2"
+ ! CHECK: %[[VAL_8:.*]] = hlfir.as_expr %[[VAL_7]]#0 : (!fir.ref<!fir.array<100xi32>>) -> !hlfir.expr<100xi32>
+ ! CHECK: %[[VAL_9:.*]]:3 = hlfir.associate %[[VAL_8]](%{{.*}}) {adapt.valuebyref} : (!hlfir.expr<100xi32>, !fir.shape<1>) -> (!fir.ref<!fir.array<100xi32>>, !fir.ref<!fir.array<100xi32>>, i1)
+ ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]]#1 : (!fir.ref<!fir.array<100xi32>>) -> !fir.ref<!fir.array<4xi32>>
+ ! CHECK: fir.call @_QPtakes_array_value(%[[VAL_10]]) fastmath<contract> : (!fir.ref<!fir.array<4xi32>>) -> ()
end subroutine
! CHECK-LABEL: func @_QPtest_litteral_copies_2
@@ -127,17 +75,10 @@ subroutine takes_char_value(v)
character(*), value :: v
end subroutine
end interface
- ! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.char<1,71>>
- ! CHECK: %[[VAL_1:.*]] = arith.constant 71 : index
- ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.char<1,71> {bindc_name = ".chrtmp"}
- ! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i64
- ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_1]] : (index) -> i64
- ! CHECK: %[[VAL_5:.*]] = arith.muli %[[VAL_3]], %[[VAL_4]] : i64
- ! CHECK: %[[VAL_6:.*]] = arith.constant false
- ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.char<1,71>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.char<1,71>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_7]], %[[VAL_8]], %[[VAL_5]], %[[VAL_6]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_10:.*]] = fir.emboxchar %[[VAL_2]], %[[VAL_1]] : (!fir.ref<!fir.char<1,71>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.call @_QPtakes_char_value(%[[VAL_10]]) {{.*}}: (!fir.boxchar<1>) -> ()
call takes_char_value("a character string litteral that could be locally modfied by the callee")
+ ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare {{.*}}"_QQcl
+ ! CHECK: %[[VAL_3:.*]] = hlfir.as_expr %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,71>>) -> !hlfir.expr<!fir.char<1,71>>
+ ! CHECK: %[[VAL_4:.*]]:3 = hlfir.associate %[[VAL_3]] typeparams %{{.*}} {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,71>>, index) -> (!fir.ref<!fir.char<1,71>>, !fir.ref<!fir.char<1,71>>, i1)
+ ! CHECK: %[[VAL_5:.*]] = fir.emboxchar %[[VAL_4]]#1, %{{.*}} : (!fir.ref<!fir.char<1,71>>, index) -> !fir.boxchar<1>
+ ! CHECK: fir.call @_QPtakes_char_value(%[[VAL_5]]) fastmath<contract> : (!fir.boxchar<1>) -> ()
end subroutine
diff --git a/flang/test/Lower/call-parenthesized-arg.f90 b/flang/test/Lower/call-parenthesized-arg.f90
index 2940ecfceb444..025a64bce520d 100644
--- a/flang/test/Lower/call-parenthesized-arg.f90
+++ b/flang/test/Lower/call-parenthesized-arg.f90
@@ -1,158 +1,53 @@
! Test that temps are always created of parenthesized arguments in
! calls.
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPfoo_num_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}) {
subroutine foo_num_scalar(x)
integer :: x
-! CHECK: %[[VAL_1:.*]] = fir.alloca i32
call bar_num_scalar(x)
-! CHECK: fir.call @_QPbar_num_scalar(%[[VAL_0]]) {{.*}}: (!fir.ref<i32>) -> ()
+! CHECK-NOT: fir.load
+! CHECK: fir.call @_QPbar_num_scalar(
call bar_num_scalar((x))
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
-! CHECK: %[[VAL_3:.*]] = fir.no_reassoc %[[VAL_2]] : i32
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<i32>
-! CHECK: fir.call @_QPbar_num_scalar(%[[VAL_1]]) {{.*}}: (!fir.ref<i32>) -> ()
-! CHECK: return
-! CHECK: }
+! CHECK: fir.load
+! CHECK: fir.call @_QPbar_num_scalar(
end subroutine
! CHECK-LABEL: func @_QPfoo_char_scalar(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo_char_scalar(x)
character(5) :: x
-! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,5>>
-! CHECK: %[[VAL_2:.*]] = arith.constant 5 : index
-! CHECK: %[[VAL_5:.*]] = fir.emboxchar %[[VAL_3]], %[[VAL_2]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
-! CHECK: fir.call @_QPbar_char_scalar(%[[VAL_5]]) fastmath<contract> : (!fir.boxchar<1>) -> ()
+! CHECK-NOT: hlfir.as_expr
+! CHECK: fir.call @_QPbar_char_scalar(
call bar_char_scalar(x)
-! CHECK: %[[VAL_6:.*]] = fir.no_reassoc %[[VAL_3]] : !fir.ref<!fir.char<1,5>>
-! CHECK: %[[VAL_7:.*]] = fir.alloca !fir.char<1,5> {bindc_name = ".chrtmp"}
-! CHECK: %[[VAL_8:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_2]] : (index) -> i64
-! CHECK: %[[VAL_10:.*]] = arith.muli %[[VAL_8]], %[[VAL_9]] : i64
-! CHECK: %[[VAL_11:.*]] = arith.constant false
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_6]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_12]], %[[VAL_13]], %[[VAL_10]], %[[VAL_11]]) fastmath<contract> : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_15:.*]] = fir.emboxchar %[[VAL_7]], %[[VAL_2]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
-! CHECK: fir.call @_QPbar_char_scalar(%[[VAL_15]]) fastmath<contract> : (!fir.boxchar<1>) -> ()
-! CHECK: return
-! CHECK: }
+! CHECK: hlfir.as_expr
+! CHECK: fir.call @_QPbar_char_scalar(
call bar_char_scalar((x))
end subroutine
! CHECK-LABEL: func @_QPfoo_num_array(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}) {
subroutine foo_num_array(x)
integer :: x(100)
call bar_num_array(x)
-! CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
-! CHECK: fir.call @_QPbar_num_array(%[[VAL_0]]) {{.*}}: (!fir.ref<!fir.array<100xi32>>) -> ()
+! CHECK-NOT: hlfir.elemental
+! CHECK: fir.call @_QPbar_num_array(
call bar_num_array((x))
-! CHECK: %[[VAL_3:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_5:.*]] = fir.array_load %[[VAL_0]](%[[VAL_4]]) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
-! CHECK: %[[VAL_6:.*]] = fir.allocmem !fir.array<100xi32>
-! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_6]](%[[VAL_7]]) : (!fir.heap<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
-! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_3]], %[[VAL_9]] : index
-! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_10]] to %[[VAL_11]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_8]]) -> (!fir.array<100xi32>) {
-! CHECK: %[[VAL_15:.*]] = fir.array_fetch %[[VAL_5]], %[[VAL_13]] : (!fir.array<100xi32>, index) -> i32
-! CHECK: %[[VAL_16:.*]] = fir.no_reassoc %[[VAL_15]] : i32
-! CHECK: %[[VAL_17:.*]] = fir.array_update %[[VAL_14]], %[[VAL_16]], %[[VAL_13]] : (!fir.array<100xi32>, i32, index) -> !fir.array<100xi32>
-! CHECK: fir.result %[[VAL_17]] : !fir.array<100xi32>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_8]], %[[VAL_18:.*]] to %[[VAL_6]] : !fir.array<100xi32>, !fir.array<100xi32>, !fir.heap<!fir.array<100xi32>>
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_6]] : (!fir.heap<!fir.array<100xi32>>) -> !fir.ref<!fir.array<100xi32>>
-! CHECK: fir.call @_QPbar_num_array(%[[VAL_19]]) {{.*}}: (!fir.ref<!fir.array<100xi32>>) -> ()
-! CHECK: fir.freemem %[[VAL_6]] : !fir.heap<!fir.array<100xi32>>
-! CHECK: return
-! CHECK: }
+! CHECK: hlfir.elemental
+! CHECK: fir.call @_QPbar_num_array(
end subroutine
! CHECK-LABEL: func @_QPfoo_char_array(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine foo_char_array(x)
- ! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,10>>>
- ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
- ! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index
- ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.array<100x!fir.char<1,10>>>) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_6:.*]] = fir.emboxchar %[[VAL_5]], %[[VAL_2]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.call @_QPbar_char_array(%[[VAL_6]]) {{.*}}: (!fir.boxchar<1>) -> ()
- ! CHECK: %[[VAL_8:.*]] = arith.constant 100 : index
- ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_3]](%[[VAL_9]]) : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<100x!fir.char<1,10>>
- ! CHECK: %[[VAL_11:.*]] = fir.allocmem !fir.array<100x!fir.char<1,10>>
- ! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_11]](%[[VAL_12]]) : (!fir.heap<!fir.array<100x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<100x!fir.char<1,10>>
- ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
- ! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_8]], %[[VAL_14]] : index
- ! CHECK: %[[VAL_17:.*]] = fir.do_loop %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_14]] unordered iter_args(%[[VAL_19:.*]] = %[[VAL_13]]) -> (!fir.array<100x!fir.char<1,10>>) {
- ! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_10]], %[[VAL_18]] : (!fir.array<100x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_21:.*]] = fir.no_reassoc %[[VAL_20]] : !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_22:.*]] = fir.array_access %[[VAL_19]], %[[VAL_18]] : (!fir.array<100x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_23:.*]] = arith.constant 10 : index
- ! CHECK: %[[VAL_24:.*]] = arith.constant 1 : i64
- ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_23]] : (index) -> i64
- ! CHECK: %[[VAL_26:.*]] = arith.muli %[[VAL_24]], %[[VAL_25]] : i64
- ! CHECK: %[[VAL_27:.*]] = arith.constant false
- ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_21]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_28]], %[[VAL_29]], %[[VAL_26]], %[[VAL_27]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_30:.*]] = fir.array_amend %[[VAL_19]], %[[VAL_22]] : (!fir.array<100x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<100x!fir.char<1,10>>
- ! CHECK: fir.result %[[VAL_30]] : !fir.array<100x!fir.char<1,10>>
- ! CHECK: }
- ! CHECK: fir.array_merge_store %[[VAL_13]], %[[VAL_31:.*]] to %[[VAL_11]] : !fir.array<100x!fir.char<1,10>>, !fir.array<100x!fir.char<1,10>>, !fir.heap<!fir.array<100x!fir.char<1,10>>>
- ! CHECK: %[[VAL_32:.*]] = arith.constant 10 : index
- ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_11]] : (!fir.heap<!fir.array<100x!fir.char<1,10>>>) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_34:.*]] = fir.emboxchar %[[VAL_33]], %[[VAL_32]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.call @_QPbar_char_array(%[[VAL_34]]) {{.*}}: (!fir.boxchar<1>) -> ()
- ! CHECK: fir.freemem %[[VAL_11]] : !fir.heap<!fir.array<100x!fir.char<1,10>>>
-
character(10) :: x(100)
call bar_char_array(x)
+! CHECK-NOT: hlfir.elemental
+! CHECK: fir.call @_QPbar_char_array(
call bar_char_array((x))
- ! CHECK: return
- ! CHECK: }
+! CHECK: hlfir.elemental
+! CHECK: fir.call @_QPbar_char_array(
end subroutine
! CHECK-LABEL: func @_QPfoo_num_array_box(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}) {
subroutine foo_num_array_box(x)
- ! CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
- ! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_3:.*]] = fir.embox %[[VAL_0]](%[[VAL_2]]) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<100xi32>>
- ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.box<!fir.array<100xi32>>) -> !fir.box<!fir.array<?xi32>>
- ! CHECK: fir.call @_QPbar_num_array_box(%[[VAL_4]]) {{.*}}: (!fir.box<!fir.array<?xi32>>) -> ()
- ! CHECK: %[[VAL_6:.*]] = arith.constant 100 : index
- ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_0]](%[[VAL_7]]) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
- ! CHECK: %[[VAL_9:.*]] = fir.allocmem !fir.array<100xi32>
- ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_9]](%[[VAL_10]]) : (!fir.heap<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
- ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
- ! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_6]], %[[VAL_12]] : index
- ! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_13]] to %[[VAL_14]] step %[[VAL_12]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_11]]) -> (!fir.array<100xi32>) {
- ! CHECK: %[[VAL_18:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_16]] : (!fir.array<100xi32>, index) -> i32
- ! CHECK: %[[VAL_19:.*]] = fir.no_reassoc %[[VAL_18]] : i32
- ! CHECK: %[[VAL_20:.*]] = fir.array_update %[[VAL_17]], %[[VAL_19]], %[[VAL_16]] : (!fir.array<100xi32>, i32, index) -> !fir.array<100xi32>
- ! CHECK: fir.result %[[VAL_20]] : !fir.array<100xi32>
- ! CHECK: }
- ! CHECK: fir.array_merge_store %[[VAL_11]], %[[VAL_21:.*]] to %[[VAL_9]] : !fir.array<100xi32>, !fir.array<100xi32>, !fir.heap<!fir.array<100xi32>>
- ! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_23:.*]] = fir.embox %[[VAL_9]](%[[VAL_22]]) : (!fir.heap<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<100xi32>>
- ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (!fir.box<!fir.array<100xi32>>) -> !fir.box<!fir.array<?xi32>>
- ! CHECK: fir.call @_QPbar_num_array_box(%[[VAL_24]]) {{.*}}: (!fir.box<!fir.array<?xi32>>) -> ()
- ! CHECK: fir.freemem %[[VAL_9]] : !fir.heap<!fir.array<100xi32>>
-
integer :: x(100)
interface
subroutine bar_num_array_box(x)
@@ -160,55 +55,15 @@ subroutine bar_num_array_box(x)
end subroutine
end interface
call bar_num_array_box(x)
+! CHECK-NOT: hlfir.elemental
+! CHECK: fir.call @_QPbar_num_array_box(
call bar_num_array_box((x))
-! CHECK: return
-! CHECK: }
+! CHECK: hlfir.elemental
+! CHECK: fir.call @_QPbar_num_array_box(
end subroutine
! CHECK-LABEL: func @_QPfoo_char_array_box(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}) {
subroutine foo_char_array_box(x, n)
- ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1,10>>>
- ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
- ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> i64
- ! CHECK: %[[VAL_6A:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
- ! CHECK: %[[C0:.*]] = arith.constant 0 : index
- ! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_6A]], %[[C0]] : index
- ! CHECK: %[[VAL_6:.*]] = arith.select %[[CMP]], %[[VAL_6A]], %[[C0]] : index
- ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_3]](%[[VAL_7]]) : (!fir.ref<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.box<!fir.array<?x!fir.char<1,10>>>
- ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.box<!fir.array<?x!fir.char<1,10>>>) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
- ! CHECK: fir.call @_QPbar_char_array_box(%[[VAL_9]]) {{.*}}: (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> ()
- ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_3]](%[[VAL_10]]) : (!fir.ref<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
- ! CHECK: %[[VAL_12:.*]] = fir.allocmem !fir.array<?x!fir.char<1,10>>, %[[VAL_6]] {uniq_name = ".array.expr"}
- ! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_14:.*]] = fir.array_load %[[VAL_12]](%[[VAL_13]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
- ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
- ! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_6]], %[[VAL_15]] : index
- ! CHECK: %[[VAL_18:.*]] = fir.do_loop %[[VAL_19:.*]] = %[[VAL_16]] to %[[VAL_17]] step %[[VAL_15]] unordered iter_args(%[[VAL_20:.*]] = %[[VAL_14]]) -> (!fir.array<?x!fir.char<1,10>>) {
- ! CHECK: %[[VAL_21:.*]] = fir.array_access %[[VAL_11]], %[[VAL_19]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_22:.*]] = fir.no_reassoc %[[VAL_21]] : !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_23:.*]] = fir.array_access %[[VAL_20]], %[[VAL_19]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_24:.*]] = arith.constant 10 : index
- ! CHECK: %[[VAL_25:.*]] = arith.constant 1 : i64
- ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_24]] : (index) -> i64
- ! CHECK: %[[VAL_27:.*]] = arith.muli %[[VAL_25]], %[[VAL_26]] : i64
- ! CHECK: %[[VAL_28:.*]] = arith.constant false
- ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_23]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_29]], %[[VAL_30]], %[[VAL_27]], %[[VAL_28]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_31:.*]] = fir.array_amend %[[VAL_20]], %[[VAL_23]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
- ! CHECK: fir.result %[[VAL_31]] : !fir.array<?x!fir.char<1,10>>
- ! CHECK: }
- ! CHECK: fir.array_merge_store %[[VAL_14]], %[[VAL_32:.*]] to %[[VAL_12]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
- ! CHECK: %[[VAL_33:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_34:.*]] = fir.embox %[[VAL_12]](%[[VAL_33]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.box<!fir.array<?x!fir.char<1,10>>>
- ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_34]] : (!fir.box<!fir.array<?x!fir.char<1,10>>>) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
- ! CHECK: fir.call @_QPbar_char_array_box(%[[VAL_35]]) {{.*}}: (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> ()
- ! CHECK: fir.freemem %[[VAL_12]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
integer :: n
character(10) :: x(n)
@@ -218,7 +73,9 @@ subroutine bar_char_array_box(x)
end subroutine
end interface
call bar_char_array_box(x)
+! CHECK-NOT: hlfir.elemental
+! CHECK: fir.call @_QPbar_char_array_box(
call bar_char_array_box((x))
- ! CHECK: return
- ! CHECK: }
+! CHECK: hlfir.elemental
+! CHECK: fir.call @_QPbar_char_array_box(
end subroutine
diff --git a/flang/test/Lower/character-assignment.f90 b/flang/test/Lower/character-assignment.f90
index 1d873c0cfd02a..2746a02fadde0 100644
--- a/flang/test/Lower/character-assignment.f90
+++ b/flang/test/Lower/character-assignment.f90
@@ -1,108 +1,45 @@
-! RUN: bbc --use-desc-for-alloc=false %s -o - -emit-fir -hlfir=false | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
! Simple character assignment tests
-! CHECK-LABEL: _QPassign1
subroutine assign1(lhs, rhs)
character(*, 1) :: lhs, rhs
- ! CHECK: %[[lhs:.*]]:2 = fir.unboxchar %arg0
- ! CHECK: %[[rhs:.*]]:2 = fir.unboxchar %arg1
lhs = rhs
- ! Compute minimum length
- ! CHECK: %[[cmp_len:[0-9]+]] = arith.cmpi slt, %[[lhs:.*]]#1, %[[rhs:.*]]#1
- ! CHECK-NEXT: %[[min_len:[0-9]+]] = arith.select %[[cmp_len]], %[[lhs]]#1, %[[rhs]]#1
-
- ! Copy of rhs into lhs
- ! CHECK: %[[count:.*]] = arith.muli %{{.*}}, %{{.*}} : i64
- ! CHECK-DAG: %[[bug:.*]] = fir.convert %[[lhs]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK-DAG: %[[src:.*]] = fir.convert %[[rhs]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%{{.*}}, %[[src]], %[[count]], %false) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-
- ! Padding
- ! CHECK-DAG: %[[blank:.*]] = fir.insert_value %{{.*}}, %c32{{.*}}, [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
- ! CHECK: fir.do_loop %[[ij:.*]] =
- ! CHECK-DAG: %[[lhs_cast:.*]] = fir.convert %[[lhs]]#0
- ! CHECK: %[[lhs_addr:.*]] = fir.coordinate_of %[[lhs_cast]], %[[ij]]
- ! CHECK: fir.store %[[blank]] to %[[lhs_addr]]
- ! CHECK-NEXT: }
end subroutine
+! CHECK-LABEL: func.func @_QPassign1(
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare{{.*}}"_QFassign1Elhs"
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare{{.*}}"_QFassign1Erhs"
+! CHECK: hlfir.assign %[[VAL_6]]#0 to %[[VAL_4]]#0 : !fir.boxchar<1>, !fir.boxchar<1>
+! CHECK: return
+! CHECK: }
! Test substring assignment
-! CHECK-LABEL: _QPassign_substring1
subroutine assign_substring1(str, rhs, lb, ub)
character(*, 1) :: rhs, str
integer(8) :: lb, ub
str(lb:ub) = rhs
- ! CHECK-DAG: %[[lb:.*]] = fir.load %arg2
- ! CHECK-DAG: %[[ub:.*]] = fir.load %arg3
- ! CHECK-DAG: %[[str:.*]]:2 = fir.unboxchar %arg0
-
- ! Compute substring offset
- ! CHECK-DAG: %[[lbi:.*]] = fir.convert %[[lb]] : (i64) -> index
- ! CHECK-DAG: %[[c1:.*]] = arith.constant 1
- ! CHECK-DAG: %[[offset:.*]] = arith.subi %[[lbi]], %[[c1]]
- ! CHECK-DAG: %[[str_cast:.*]] = fir.convert %[[str]]#0
- ! CHECK-DAG: %[[str_addr:.*]] = fir.coordinate_of %[[str_cast]], %[[offset]]
- ! CHECK-DAG: %[[lhs_addr:.*]] = fir.convert %[[str_addr]]
-
- ! Compute substring length
- ! CHECK-DAG: %[[ubi:.*]] = fir.convert %[[ub]] : (i64) -> index
- ! CHECK-DAG: %[[diff:.*]] = arith.subi %[[ubi]], %[[lbi]]
- ! CHECK-DAG: %[[pre_lhs_len:.*]] = arith.addi %[[diff]], %[[c1]]
- ! CHECK-DAG: %[[c0:.*]] = arith.constant 0
- ! CHECK-DAG: %[[cmp_len:.*]] = arith.cmpi slt, %[[pre_lhs_len]], %[[c0]]
-
- ! CHECK-DAG: %[[lhs_len:.*]] = arith.select %[[cmp_len]], %[[c0]], %[[pre_lhs_len]]
-
- ! The rest of the assignment is just as the one above, only test that the
- ! substring is the one used as lhs.
- ! ...
- ! CHECK: fir.do_loop %arg4 =
- ! CHECK: %[[lhs_addr3:.*]] = fir.convert %[[lhs_addr]]
- ! CHECK: fir.coordinate_of %[[lhs_addr3]], %arg4
- ! ...
end subroutine
+! CHECK-LABEL: func.func @_QPassign_substring1(
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare{{.*}}"_QFassign_substring1Erhs"
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare{{.*}}"_QFassign_substring1Estr"
+! CHECK: %[[VAL_21:.*]] = hlfir.designate %[[VAL_9]]#0 substr {{.*}}
+! CHECK: hlfir.assign %[[VAL_7]]#0 to %[[VAL_21]] : !fir.boxchar<1>, !fir.boxchar<1>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: _QPassign_constant
-! CHECK-SAME: (%[[ARG:.*]]:
subroutine assign_constant(lhs)
character(*, 1) :: lhs
- ! CHECK: %[[lhs:.*]]:2 = fir.unboxchar %arg0
- ! CHECK: %[[cst:.*]] = fir.address_of(@{{.*}}) :
lhs = "Hello World"
- ! CHECK-DAG: %[[dst:.*]] = fir.convert %[[lhs]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK-DAG: %[[src:.*]] = fir.convert %[[cst]] : (!fir.ref<!fir.char<1,11>>) -> !fir.ref<i8>
- ! CHECK-DAG: %[[count:.*]] = arith.muli %{{.*}}, %{{.*}} : i64
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[dst]], %[[src]], %[[count]], %false) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-
- ! Padding
- ! CHECK-DAG: %[[blank:.*]] = fir.insert_value %{{.*}}, %c32{{.*}}, [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
- ! CHECK: fir.do_loop %[[j:.*]] = %{{.*}} to %{{.*}} {
- ! CHECK-DAG: %[[jhs_cast:.*]] = fir.convert %[[lhs]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
- ! CHECK: %[[jhs_addr:.*]] = fir.coordinate_of %[[jhs_cast]], %[[j]]
- ! CHECK: fir.store %[[blank]] to %[[jhs_addr]]
- ! CHECK: }
end subroutine
-
- ! CHECK: func @_QPassign_zero_size_array
- subroutine assign_zero_size_array(n)
- ! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.heap<!fir.array<?x!fir.char<1,?>>> {uniq_name = "_QFassign_zero_size_arrayEa.addr"}
- character(n), allocatable :: a(:)
- ! CHECK: fir.store %{{.*}} to %[[VAL_0]] : !fir.ref<!fir.heap<!fir.array<?x!fir.char<1,?>>>>
- ! CHECK: %{{.*}} = fir.load %[[VAL_0]] : !fir.ref<!fir.heap<!fir.array<?x!fir.char<1,?>>>>
- ! CHECK: %[[VAL_1:.*]] = arith.cmpi ne, %{{.*}}, %c0{{.*}} : i64
- ! CHECK: %[[VAL_2:.*]]:2 = fir.if %[[VAL_1]] -> (i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>) {
- ! CHECK: %{{.*}} = fir.if %{{.*}} -> (!fir.heap<!fir.array<?x!fir.char<1,?>>>) {
- ! CHECK: %{{.*}} = fir.do_loop %{{.*}} = %c0{{.*}} to %{{.*}} step %c1{{.*}} unordered iter_args(%{{.*}} = %{{.*}}) -> (!fir.array<?x!fir.char<1,?>>) {
- ! CHECK: fir.do_loop %[[ARG_0:.*]] = %{{.*}} to {{.*}} step %c1{{.*}} {
- ! CHECK: %{{.*}} = fir.coordinate_of %{{.*}}, %[[ARG_0]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
- ! CHECK: fir.if %[[VAL_2]]#0 {
- ! CHECK: fir.if %[[VAL_1]] {
- ! CHECK: fir.store %[[VAL_2]]#1 to %[[VAL_0]] : !fir.ref<!fir.heap<!fir.array<?x!fir.char<1,?>>>>
- a = [character(n)::]
- ! CHECK: return
- end subroutine
-
-! CHECK-LABEL: fir.global linkonce @_QQclX48656C6C6F20576F726C64
-! CHECK: %[[lit:.*]] = fir.string_lit "Hello World"(11) : !fir.char<1,11>
-! CHECK: fir.has_value %[[lit]] : !fir.char<1,11>
-! CHECK: }
+! CHECK-LABEL: func.func @_QPassign_constant(
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare{{.*}}"_QFassign_constantElhs"
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare{{.*}}"_QQclX48656C6C6F20576F726C64"
+! CHECK: hlfir.assign %[[VAL_6]]#0 to %[[VAL_3]]#0 : !fir.ref<!fir.char<1,11>>, !fir.boxchar<1>
+
+subroutine assign_zero_size_array(n)
+ character(n), allocatable :: a(:)
+ a = [character(n)::]
+end subroutine
+! CHECK-LABEL: func.func @_QPassign_zero_size_array(
+! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare{{.*}}"_QFassign_zero_size_arrayEa"
+! CHECK: %[[VAL_24:.*]] = hlfir.as_expr %{{.*}}
+! CHECK: hlfir.assign %[[VAL_24]] to %[[VAL_12]]#0 realloc keep_lhs_len : !hlfir.expr<0x!fir.char<1,?>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
diff --git a/flang/test/Lower/character-concatenation.f90 b/flang/test/Lower/character-concatenation.f90
deleted file mode 100644
index ae55b93902bb0..0000000000000
--- a/flang/test/Lower/character-concatenation.f90
+++ /dev/null
@@ -1,42 +0,0 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-
-! Test character scalar concatenation lowering
-
-! CHECK-LABEL: concat_1
-subroutine concat_1(a, b)
- ! CHECK-DAG: %[[a:.*]]:2 = fir.unboxchar %arg0
- ! CHECK-DAG: %[[b:.*]]:2 = fir.unboxchar %arg1
- character(*) :: a, b
-
- ! CHECK: call @{{.*}}BeginExternalListOutput
- print *, a // b
- ! Concatenation
-
- ! CHECK: %[[len:.*]] = arith.addi %[[a]]#1, %[[b]]#1
- ! CHECK: %[[temp:.*]] = fir.alloca !fir.char<1,?>(%[[len]] : index)
-
- ! CHECK-DAG: %[[c1:.*]] = arith.constant 1
- ! CHECK-DAG: %[[a2:.*]] = fir.convert %[[a]]#1
- ! CHECK: %[[count:.*]] = arith.muli %[[c1]], %[[a2]]
- ! CHECK-DAG: constant false
- ! CHECK-DAG: %[[to:.*]] = fir.convert %[[temp]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK-DAG: %[[from:.*]] = fir.convert %[[a]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[to]], %[[from]], %[[count]], %false) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-
- ! CHECK: %[[c1_0:.*]] = arith.constant 1
- ! CHECK: %[[count2:.*]] = arith.subi %[[len]], %[[c1_0]]
- ! CHECK: fir.do_loop %[[index2:.*]] = %[[a]]#1 to %[[count2]] step %[[c1_0]] {
- ! CHECK: %[[b_index:.*]] = arith.subi %[[index2]], %[[a]]#1
- ! CHECK: %[[b_cast:.*]] = fir.convert %[[b]]#0
- ! CHECK: %[[b_addr:.*]] = fir.coordinate_of %[[b_cast]], %[[b_index]]
- ! CHECK-DAG: %[[b_elt:.*]] = fir.load %[[b_addr]]
- ! CHECK: %[[temp_cast2:.*]] = fir.convert %[[temp]]
- ! CHECK: %[[temp_addr2:.*]] = fir.coordinate_of %[[temp_cast2]], %[[index2]]
- ! CHECK: fir.store %[[b_elt]] to %[[temp_addr2]]
- ! CHECK: }
-
- ! IO runtime call
- ! CHECK-DAG: %[[raddr:.*]] = fir.convert %[[temp]]
- ! CHECK-DAG: %[[rlen:.*]] = fir.convert %[[len]]
- ! CHECK: call @{{.*}}OutputAscii(%{{.*}}, %[[raddr]], %[[rlen]])
-end subroutine
diff --git a/flang/test/Lower/character-substrings.f90 b/flang/test/Lower/character-substrings.f90
index 874f2944cff19..38343112c5c47 100644
--- a/flang/test/Lower/character-substrings.f90
+++ b/flang/test/Lower/character-substrings.f90
@@ -1,58 +1,38 @@
! Test character substring lowering
-! RUN: bbc %s -o - -emit-fir -hlfir=false | FileCheck %s
+! RUN: bbc %s -o - -emit-hlfir | FileCheck %s
! Test substring lower where the parent is a scalar-char-literal-constant
-! CHECK-LABEL: func @_QPscalar_substring_embox(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i64>{{.*}}) {
subroutine scalar_substring_embox(i, j)
- ! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,18>>
- ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
- ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<i64>
- ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]] : (i64) -> index
- ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
- ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_5]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.char<1,18>>) -> !fir.ref<!fir.array<18x!fir.char<1>>>
- ! CHECK: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_8]] : (!fir.ref<!fir.array<18x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
- ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
- ! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_6]], %[[VAL_5]] : index
- ! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_12]], %[[VAL_7]] : index
- ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
- ! CHECK: %[[VAL_15:.*]] = arith.cmpi slt, %[[VAL_13]], %[[VAL_14]] : index
- ! CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_14]], %[[VAL_13]] : index
- ! CHECK: %[[VAL_17:.*]] = fir.emboxchar %[[VAL_11]], %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.call @_QPbar(%[[VAL_17]]) {{.*}}: (!fir.boxchar<1>) -> ()
integer(8) :: i, j
call bar("abcHello World!dfg"(i:j))
- ! CHECK: return
- ! CHECK: }
end subroutine scalar_substring_embox
+! CHECK-LABEL: func.func @_QPscalar_substring_embox(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i64> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QFscalar_substring_emboxEi"} : (!fir.ref<i64>, !fir.dscope) -> (!fir.ref<i64>, !fir.ref<i64>)
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QFscalar_substring_emboxEj"} : (!fir.ref<i64>, !fir.dscope) -> (!fir.ref<i64>, !fir.ref<i64>)
+! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QQclX61626348656C6C6F20576F726C6421646667) : !fir.ref<!fir.char<1,18>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 18 : index
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]] typeparams %[[VAL_6]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = ".stringlit"} : (!fir.ref<!fir.char<1,18>>, index) -> (!fir.ref<!fir.char<1,18>>, !fir.ref<!fir.char<1,18>>)
+! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
+! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<i64>
+! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_8]] : (i64) -> index
+! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
+! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_13:.*]] = arith.subi %[[VAL_11]], %[[VAL_10]] : index
+! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_13]], %[[VAL_12]] : index
+! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_16:.*]] = arith.cmpi sgt, %[[VAL_14]], %[[VAL_15]] : index
+! CHECK: %[[VAL_17:.*]] = arith.select %[[VAL_16]], %[[VAL_14]], %[[VAL_15]] : index
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_7]]#0 substr %[[VAL_10]], %[[VAL_11]] typeparams %[[VAL_17]] : (!fir.ref<!fir.char<1,18>>, index, index, index) -> !fir.boxchar<1>
+! CHECK: %[[VAL_19:.*]] = hlfir.as_expr %[[VAL_18]] : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
+! CHECK: %[[VAL_20:.*]]:3 = hlfir.associate %[[VAL_19]] typeparams %[[VAL_17]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>, i1)
+! CHECK: fir.call @_QPbar(%[[VAL_20]]#0) fastmath<contract> : (!fir.boxchar<1>) -> ()
+! CHECK: hlfir.end_associate %[[VAL_20]]#1, %[[VAL_20]]#2 : !fir.ref<!fir.char<1,?>>, i1
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QParray_substring_embox(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
-! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<4x!fir.char<1,7>>>
-! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
-! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
-! CHECK: %[[VAL_7:.*]] = arith.addi %[[VAL_4]], %[[VAL_3]] : index
-! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_7]], %[[VAL_4]] : index
-! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_10:.*]] = arith.constant 5 : i64
-! CHECK: %[[VAL_11:.*]] = arith.constant 5 : i64
-! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_13:.*]] = arith.subi %[[VAL_10]], %[[VAL_12]] : i64
-! CHECK: %[[VAL_14:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_11]], %[[VAL_13]] : i64
-! CHECK: %[[VAL_16:.*]] = arith.cmpi sgt, %[[VAL_15]], %[[VAL_14]] : i64
-! CHECK: %[[VAL_17:.*]] = arith.select %[[VAL_16]], %[[VAL_15]], %[[VAL_14]] : i64
-! CHECK: %[[VAL_18:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] substr %[[VAL_13]], %[[VAL_17]] : (index, index, index, i64, i64) -> !fir.slice<1>
-! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_2]](%[[VAL_9]]) {{\[}}%[[VAL_18]]] : (!fir.ref<!fir.array<4x!fir.char<1,7>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
-! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.box<!fir.array<?x!fir.char<1>>>
-! CHECK: fir.call @_QPs(%[[VAL_20]]) {{.*}}: (!fir.box<!fir.array<?x!fir.char<1>>>) -> ()
-! CHECK: return
-! CHECK: }
subroutine array_substring_embox(arr)
interface
@@ -65,244 +45,86 @@ end subroutine s
call s(arr(:)(5:5))
end subroutine array_substring_embox
-
-! CHECK-LABEL: func @_QPsubstring_assignment(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
-subroutine substring_assignment(a,b)
+! CHECK-LABEL: func.func @_QParray_substring_embox(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "arr"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,4>>
-! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,4>>
-! CHECK: %[[VAL_6:.*]] = arith.constant 3 : i64
-! CHECK: %[[VAL_7:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
-! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_8]], %[[VAL_10]] : index
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<4x!fir.char<1>>>
-! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_11]] : (!fir.ref<!fir.array<4x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_9]], %[[VAL_8]] : index
-! CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_10]] : index
-! CHECK: %[[VAL_17:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_18:.*]] = arith.cmpi slt, %[[VAL_16]], %[[VAL_17]] : index
-! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_17]], %[[VAL_16]] : index
-! CHECK: %[[VAL_20:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_21:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (i64) -> index
-! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
-! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_22]], %[[VAL_24]] : index
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<4x!fir.char<1>>>
-! CHECK: %[[VAL_27:.*]] = fir.coordinate_of %[[VAL_26]], %[[VAL_25]] : (!fir.ref<!fir.array<4x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_23]], %[[VAL_22]] : index
-! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_29]], %[[VAL_24]] : index
-! CHECK: %[[VAL_31:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_32:.*]] = arith.cmpi slt, %[[VAL_30]], %[[VAL_31]] : index
-! CHECK: %[[VAL_33:.*]] = arith.select %[[VAL_32]], %[[VAL_31]], %[[VAL_30]] : index
-! CHECK: %[[VAL_34:.*]] = arith.cmpi slt, %[[VAL_33]], %[[VAL_19]] : index
-! CHECK: %[[VAL_35:.*]] = arith.select %[[VAL_34]], %[[VAL_33]], %[[VAL_19]] : index
-! CHECK: %[[VAL_36:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
-! CHECK: %[[VAL_38:.*]] = arith.muli %[[VAL_36]], %[[VAL_37]] : i64
-! CHECK: %[[VAL_39:.*]] = arith.constant false
-! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_40]], %[[VAL_41]], %[[VAL_38]], %[[VAL_39]]) fastmath<contract> : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_43:.*]] = arith.subi %[[VAL_33]], %[[VAL_42]] : index
-! CHECK: %[[VAL_44:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_45:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_46:.*]] = fir.insert_value %[[VAL_45]], %[[VAL_44]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_48:.*]] = %[[VAL_35]] to %[[VAL_43]] step %[[VAL_47]] {
-! CHECK: %[[VAL_49:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_50:.*]] = fir.coordinate_of %[[VAL_49]], %[[VAL_48]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_46]] to %[[VAL_50]] : !fir.ref<!fir.char<1>>
-! CHECK: }
+! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<4x!fir.char<1,7>>>
+! CHECK: %[[VAL_4:.*]] = arith.constant 7 : index
+! CHECK: %[[VAL_5:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_6]]) typeparams %[[VAL_4]] dummy_scope %[[VAL_1]] {uniq_name = "_QFarray_substring_emboxEarr"} : (!fir.ref<!fir.array<4x!fir.char<1,7>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.ref<!fir.array<4x!fir.char<1,7>>>, !fir.ref<!fir.array<4x!fir.char<1,7>>>)
+! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_10:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_12:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_13:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_8]]:%[[VAL_5]]:%[[VAL_9]]) substr %[[VAL_12]], %[[VAL_13]] shape %[[VAL_11]] typeparams %[[VAL_14]] : (!fir.ref<!fir.array<4x!fir.char<1,7>>>, index, index, index, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<4x!fir.char<1>>>
+! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (!fir.box<!fir.array<4x!fir.char<1>>>) -> !fir.box<!fir.array<?x!fir.char<1>>>
+! CHECK: fir.call @_QPs(%[[VAL_16]]) fastmath<contract> : (!fir.box<!fir.array<?x!fir.char<1>>>) -> ()
! CHECK: return
! CHECK: }
-
+
+subroutine substring_assignment(a,b)
+
character(4) :: a, b
a(1:2) = b(3:4)
end subroutine substring_assignment
-
-! CHECK-LABEL: func @_QParray_substring_assignment(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
-! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
-! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<6x!fir.char<1,5>>>
-! CHECK: %[[VAL_3:.*]] = arith.constant 6 : index
-! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
-! CHECK: %[[VAL_7:.*]] = arith.addi %[[VAL_4]], %[[VAL_3]] : index
-! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_7]], %[[VAL_4]] : index
-! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_8]], %[[VAL_4]] : index
-! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_10]], %[[VAL_6]] : index
-! CHECK: %[[VAL_12:.*]] = arith.divsi %[[VAL_11]], %[[VAL_6]] : index
-! CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_9]] : index
-! CHECK: %[[VAL_14:.*]] = arith.select %[[VAL_13]], %[[VAL_12]], %[[VAL_9]] : index
-! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_16:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] : (index, index, index) -> !fir.slice<1>
-! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_2]](%[[VAL_15]]) {{\[}}%[[VAL_16]]] : (!fir.ref<!fir.array<6x!fir.char<1,5>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<6x!fir.char<1,5>>
-! CHECK: %[[VAL_18:.*]] = fir.address_of(@_QQclX424144) : !fir.ref<!fir.char<1,3>>
-! CHECK: %[[VAL_19:.*]] = arith.constant 3 : index
-! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_22:.*]] = arith.subi %[[VAL_14]], %[[VAL_20]] : index
-! CHECK: %[[VAL_23:.*]] = fir.do_loop %[[VAL_24:.*]] = %[[VAL_21]] to %[[VAL_22]] step %[[VAL_20]] unordered iter_args(%[[VAL_25:.*]] = %[[VAL_17]]) -> (!fir.array<6x!fir.char<1,5>>) {
-! CHECK: %[[VAL_26:.*]] = fir.array_access %[[VAL_25]], %[[VAL_24]] : (!fir.array<6x!fir.char<1,5>>, index) -> !fir.ref<!fir.char<1,5>>
-! CHECK: %[[VAL_27:.*]] = arith.constant 3 : i64
-! CHECK: %[[VAL_28:.*]] = arith.constant 5 : i64
-! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_27]] : (i64) -> index
-! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_28]] : (i64) -> index
-! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_29]], %[[VAL_31]] : index
-! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<!fir.array<5x!fir.char<1>>>
-! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_32]] : (!fir.ref<!fir.array<5x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_30]], %[[VAL_29]] : index
-! CHECK: %[[VAL_37:.*]] = arith.addi %[[VAL_36]], %[[VAL_31]] : index
-! CHECK: %[[VAL_38:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_39:.*]] = arith.cmpi slt, %[[VAL_37]], %[[VAL_38]] : index
-! CHECK: %[[VAL_40:.*]] = arith.select %[[VAL_39]], %[[VAL_38]], %[[VAL_37]] : index
-! CHECK: %[[VAL_41:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_40]] : (index) -> index
-! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_43]], %[[VAL_42]] : index
-! CHECK: fir.do_loop %[[VAL_45:.*]] = %[[VAL_41]] to %[[VAL_44]] step %[[VAL_42]] {
-! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_19]] : (index) -> index
-! CHECK: %[[VAL_47:.*]] = arith.cmpi slt, %[[VAL_45]], %[[VAL_46]] : index
-! CHECK: fir.if %[[VAL_47]] {
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_50:.*]] = fir.load %[[VAL_49]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_52:.*]] = fir.coordinate_of %[[VAL_51]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_50]] to %[[VAL_52]] : !fir.ref<!fir.char<1>>
-! CHECK: } else {
-! CHECK: %[[VAL_53:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
-! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_53]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: }
-! CHECK: %[[VAL_56:.*]] = arith.cmpi slt, %[[VAL_40]], %[[VAL_19]] : index
-! CHECK: %[[VAL_57:.*]] = arith.select %[[VAL_56]], %[[VAL_40]], %[[VAL_19]] : index
-! CHECK: %[[VAL_58:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_59:.*]] = fir.convert %[[VAL_57]] : (index) -> i64
-! CHECK: %[[VAL_60:.*]] = arith.muli %[[VAL_58]], %[[VAL_59]] : i64
-! CHECK: %[[VAL_61:.*]] = arith.constant false
-! CHECK: %[[VAL_62:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_62]], %[[VAL_63]], %[[VAL_60]], %[[VAL_61]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_64:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_65:.*]] = arith.subi %[[VAL_40]], %[[VAL_64]] : index
-! CHECK: %[[VAL_66:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_67:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_68:.*]] = fir.insert_value %[[VAL_67]], %[[VAL_66]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_69:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_70:.*]] = %[[VAL_57]] to %[[VAL_65]] step %[[VAL_69]] {
-! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_72:.*]] = fir.coordinate_of %[[VAL_71]], %[[VAL_70]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_68]] to %[[VAL_72]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_73:.*]] = fir.array_amend %[[VAL_25]], %[[VAL_26]] : (!fir.array<6x!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>) -> !fir.array<6x!fir.char<1,5>>
-! CHECK: fir.result %[[VAL_73]] : !fir.array<6x!fir.char<1,5>>
+! CHECK-LABEL: func.func @_QPsubstring_assignment(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "a"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "b"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,4>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_4]] typeparams %[[VAL_5]] dummy_scope %[[VAL_2]] {uniq_name = "_QFsubstring_assignmentEa"} : (!fir.ref<!fir.char<1,4>>, index, !fir.dscope) -> (!fir.ref<!fir.char<1,4>>, !fir.ref<!fir.char<1,4>>)
+! CHECK: %[[VAL_7:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,4>>
+! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]] typeparams %[[VAL_9]] dummy_scope %[[VAL_2]] {uniq_name = "_QFsubstring_assignmentEb"} : (!fir.ref<!fir.char<1,4>>, index, !fir.dscope) -> (!fir.ref<!fir.char<1,4>>, !fir.ref<!fir.char<1,4>>)
+! CHECK: %[[VAL_11:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_12:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_13:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_10]]#0 substr %[[VAL_11]], %[[VAL_12]] typeparams %[[VAL_13]] : (!fir.ref<!fir.char<1,4>>, index, index, index) -> !fir.ref<!fir.char<1,2>>
+! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_16:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_17:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_6]]#0 substr %[[VAL_15]], %[[VAL_16]] typeparams %[[VAL_17]] : (!fir.ref<!fir.char<1,4>>, index, index, index) -> !fir.ref<!fir.char<1,2>>
+! CHECK: hlfir.assign %[[VAL_14]] to %[[VAL_18]] : !fir.ref<!fir.char<1,2>>, !fir.ref<!fir.char<1,2>>
+! CHECK: return
! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_17]], %[[VAL_74:.*]] to %[[VAL_2]]{{\[}}%[[VAL_16]]] : !fir.array<6x!fir.char<1,5>>, !fir.array<6x!fir.char<1,5>>, !fir.ref<!fir.array<6x!fir.char<1,5>>>, !fir.slice<1>
-! CHECK: return
-! CHECK: }
+
subroutine array_substring_assignment(a)
character(5) :: a(6)
a(:)(3:5) = "BAD"
end subroutine array_substring_assignment
-
-! CHECK-LABEL: func @_QParray_substring_assignment2(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>{{.*}}) {
-! CHECK: %[[VAL_1:.*]] = arith.constant 8 : index
-! CHECK: %[[VAL_2:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>
-! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_4]], %[[VAL_1]], %[[VAL_4]] path %[[VAL_2]] : (index, index, index, !fir.field) -> !fir.slice<1>
-! CHECK: %[[c0:.*]] = arith.constant 0 : index
-! CHECK: %[[sub:.*]] = arith.subi %[[VAL_1]], %[[VAL_4]] : index
-! CHECK: %[[add:.*]] = arith.addi %[[sub]], %[[VAL_4]] : index
-! CHECK: %[[div:.*]] = arith.divsi %{{[0-9]+}}, %[[VAL_4]] : index
-! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[div]], %[[c0]] : index
-! CHECK: %[[select:.*]] = arith.select %[[cmp]], %[[div]], %[[c0]] : index
-! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) {{\[}}%[[VAL_5]]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<8x!fir.char<1,7>>
-! CHECK: %[[VAL_7:.*]] = fir.address_of(@_QQclX6E696365) : !fir.ref<!fir.char<1,4>>
-! CHECK: %[[VAL_8:.*]] = arith.constant 4 : index
-! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_11:.*]] = arith.subi %[[select]], %[[VAL_9]] : index
-! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_10]] to %[[VAL_11]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_6]]) -> (!fir.array<8x!fir.char<1,7>>) {
-! CHECK: %[[VAL_15:.*]] = fir.array_access %[[VAL_14]], %[[VAL_13]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
-! CHECK: %[[VAL_16:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_17:.*]] = arith.constant 7 : i64
-! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (i64) -> index
-! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_18]], %[[VAL_20]] : index
-! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_15]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
-! CHECK: %[[VAL_23:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_21]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_19]], %[[VAL_18]] : index
-! CHECK: %[[VAL_26:.*]] = arith.addi %[[VAL_25]], %[[VAL_20]] : index
-! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_28:.*]] = arith.cmpi slt, %[[VAL_26]], %[[VAL_27]] : index
-! CHECK: %[[VAL_29:.*]] = arith.select %[[VAL_28]], %[[VAL_27]], %[[VAL_26]] : index
-! CHECK: %[[VAL_30:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_29]] : (index) -> index
-! CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_32]], %[[VAL_31]] : index
-! CHECK: fir.do_loop %[[VAL_34:.*]] = %[[VAL_30]] to %[[VAL_33]] step %[[VAL_31]] {
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_8]] : (index) -> index
-! CHECK: %[[VAL_36:.*]] = arith.cmpi slt, %[[VAL_34]], %[[VAL_35]] : index
-! CHECK: fir.if %[[VAL_36]] {
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_38:.*]] = fir.coordinate_of %[[VAL_37]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_38]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_41:.*]] = fir.coordinate_of %[[VAL_40]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_39]] to %[[VAL_41]] : !fir.ref<!fir.char<1>>
-! CHECK: } else {
-! CHECK: %[[VAL_42:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
-! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_44:.*]] = fir.coordinate_of %[[VAL_43]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_42]] to %[[VAL_44]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: }
-! CHECK: %[[VAL_45:.*]] = arith.cmpi slt, %[[VAL_29]], %[[VAL_8]] : index
-! CHECK: %[[VAL_46:.*]] = arith.select %[[VAL_45]], %[[VAL_29]], %[[VAL_8]] : index
-! CHECK: %[[VAL_47:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_46]] : (index) -> i64
-! CHECK: %[[VAL_49:.*]] = arith.muli %[[VAL_47]], %[[VAL_48]] : i64
-! CHECK: %[[VAL_50:.*]] = arith.constant false
-! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_51]], %[[VAL_52]], %[[VAL_49]], %[[VAL_50]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_53:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_54:.*]] = arith.subi %[[VAL_29]], %[[VAL_53]] : index
-! CHECK: %[[VAL_55:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_56:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_57:.*]] = fir.insert_value %[[VAL_56]], %[[VAL_55]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_58:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_59:.*]] = %[[VAL_46]] to %[[VAL_54]] step %[[VAL_58]] {
-! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_61:.*]] = fir.coordinate_of %[[VAL_60]], %[[VAL_59]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_57]] to %[[VAL_61]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_62:.*]] = fir.array_amend %[[VAL_14]], %[[VAL_15]] : (!fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.char<1,7>>) -> !fir.array<8x!fir.char<1,7>>
-! CHECK: fir.result %[[VAL_62]] : !fir.array<8x!fir.char<1,7>>
+! CHECK-LABEL: func.func @_QParray_substring_assignment(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "a"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<6x!fir.char<1,5>>>
+! CHECK: %[[VAL_4:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_5:.*]] = arith.constant 6 : index
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_6]]) typeparams %[[VAL_4]] dummy_scope %[[VAL_1]] {uniq_name = "_QFarray_substring_assignmentEa"} : (!fir.ref<!fir.array<6x!fir.char<1,5>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.ref<!fir.array<6x!fir.char<1,5>>>, !fir.ref<!fir.array<6x!fir.char<1,5>>>)
+! CHECK: %[[VAL_8:.*]] = fir.address_of(@_QQclX424144) : !fir.ref<!fir.char<1,3>>
+! CHECK: %[[VAL_9:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]] typeparams %[[VAL_9]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX424144"} : (!fir.ref<!fir.char<1,3>>, index) -> (!fir.ref<!fir.char<1,3>>, !fir.ref<!fir.char<1,3>>)
+! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_13:.*]] = arith.constant 6 : index
+! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_15:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_16:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_17:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_11]]:%[[VAL_5]]:%[[VAL_12]]) substr %[[VAL_15]], %[[VAL_16]] shape %[[VAL_14]] typeparams %[[VAL_17]] : (!fir.ref<!fir.array<6x!fir.char<1,5>>>, index, index, index, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<6x!fir.char<1,3>>>
+! CHECK: hlfir.assign %[[VAL_10]]#0 to %[[VAL_18]] : !fir.ref<!fir.char<1,3>>, !fir.box<!fir.array<6x!fir.char<1,3>>>
+! CHECK: return
! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_63:.*]] to %[[VAL_0]]{{\[}}%[[VAL_5]]] : !fir.array<8x!fir.char<1,7>>, !fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, !fir.slice<1>
-! CHECK: return
-! CHECK: }
+
subroutine array_substring_assignment2(a)
type t
@@ -311,108 +133,22 @@ subroutine array_substring_assignment2(a)
type(t) :: a(8)
a%ch(4:7) = "nice"
end subroutine array_substring_assignment2
-
-! CHECK-LABEL: func @_QParray_substring_assignment3(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>{{.*}}) {
-! CHECK: %[[VAL_2:.*]] = arith.constant 8 : index
-! CHECK: %[[VAL_3:.*]] = arith.constant 8 : index
-! CHECK: %[[VAL_4:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>
-! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_7:.*]] = fir.slice %[[VAL_6]], %[[VAL_2]], %[[VAL_6]] path %[[VAL_4]] : (index, index, index, !fir.field) -> !fir.slice<1>
-! CHECK: %[[c0:.*]] = arith.constant 0 : index
-! CHECK: %[[sub:.*]] = arith.subi %[[VAL_2]], %[[VAL_6]] : index
-! CHECK: %[[add:.*]] = arith.addi %[[sub]], %[[VAL_6]] : index
-! CHECK: %[[div:.*]] = arith.divsi %[[add]], %[[VAL_6]] : index
-! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[div]], %[[c0]] : index
-! CHECK: %[[select:.*]] = arith.select %[[cmp]], %[[div]], %[[c0]] : index
-! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_0]](%[[VAL_5]]) {{\[}}%[[VAL_7]]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<8x!fir.char<1,7>>
-! CHECK: %[[VAL_9:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>
-! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_12:.*]] = fir.slice %[[VAL_11]], %[[VAL_3]], %[[VAL_11]] path %[[VAL_9]] : (index, index, index, !fir.field) -> !fir.slice<1>
-! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_1]](%[[VAL_10]]) {{\[}}%[[VAL_12]]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<8x!fir.char<1,7>>
-! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_16:.*]] = arith.subi %[[select]], %[[VAL_14]] : index
-! CHECK: %[[VAL_17:.*]] = fir.do_loop %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_14]] unordered iter_args(%[[VAL_19:.*]] = %[[VAL_8]]) -> (!fir.array<8x!fir.char<1,7>>) {
-! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_13]], %[[VAL_18]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
-! CHECK: %[[VAL_21:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_22:.*]] = arith.constant 5 : i64
-! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
-! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
-! CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_23]], %[[VAL_25]] : index
-! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
-! CHECK: %[[VAL_28:.*]] = fir.coordinate_of %[[VAL_27]], %[[VAL_26]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_24]], %[[VAL_23]] : index
-! CHECK: %[[VAL_31:.*]] = arith.addi %[[VAL_30]], %[[VAL_25]] : index
-! CHECK: %[[VAL_32:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_33:.*]] = arith.cmpi slt, %[[VAL_31]], %[[VAL_32]] : index
-! CHECK: %[[VAL_34:.*]] = arith.select %[[VAL_33]], %[[VAL_32]], %[[VAL_31]] : index
-! CHECK: %[[VAL_35:.*]] = fir.array_access %[[VAL_19]], %[[VAL_18]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
-! CHECK: %[[VAL_36:.*]] = arith.constant 4 : i64
-! CHECK: %[[VAL_37:.*]] = arith.constant 7 : i64
-! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_37]] : (i64) -> index
-! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_38]], %[[VAL_40]] : index
-! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
-! CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[VAL_41]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_44:.*]] = fir.convert %[[VAL_43]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_39]], %[[VAL_38]] : index
-! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_45]], %[[VAL_40]] : index
-! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_48:.*]] = arith.cmpi slt, %[[VAL_46]], %[[VAL_47]] : index
-! CHECK: %[[VAL_49:.*]] = arith.select %[[VAL_48]], %[[VAL_47]], %[[VAL_46]] : index
-! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_51:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_49]] : (index) -> index
-! CHECK: %[[VAL_53:.*]] = arith.subi %[[VAL_52]], %[[VAL_51]] : index
-! CHECK: fir.do_loop %[[VAL_54:.*]] = %[[VAL_50]] to %[[VAL_53]] step %[[VAL_51]] {
-! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_34]] : (index) -> index
-! CHECK: %[[VAL_56:.*]] = arith.cmpi slt, %[[VAL_54]], %[[VAL_55]] : index
-! CHECK: fir.if %[[VAL_56]] {
-! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_58:.*]] = fir.coordinate_of %[[VAL_57]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_59:.*]] = fir.load %[[VAL_58]] : !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_61:.*]] = fir.coordinate_of %[[VAL_60]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_59]] to %[[VAL_61]] : !fir.ref<!fir.char<1>>
-! CHECK: } else {
-! CHECK: %[[VAL_62:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
-! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_64:.*]] = fir.coordinate_of %[[VAL_63]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_62]] to %[[VAL_64]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: }
-! CHECK: %[[VAL_65:.*]] = arith.cmpi slt, %[[VAL_49]], %[[VAL_34]] : index
-! CHECK: %[[VAL_66:.*]] = arith.select %[[VAL_65]], %[[VAL_49]], %[[VAL_34]] : index
-! CHECK: %[[VAL_67:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_66]] : (index) -> i64
-! CHECK: %[[VAL_69:.*]] = arith.muli %[[VAL_67]], %[[VAL_68]] : i64
-! CHECK: %[[VAL_70:.*]] = arith.constant false
-! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_71]], %[[VAL_72]], %[[VAL_69]], %[[VAL_70]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_73:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_74:.*]] = arith.subi %[[VAL_49]], %[[VAL_73]] : index
-! CHECK: %[[VAL_75:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_76:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_77:.*]] = fir.insert_value %[[VAL_76]], %[[VAL_75]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_78:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_79:.*]] = %[[VAL_66]] to %[[VAL_74]] step %[[VAL_78]] {
-! CHECK: %[[VAL_80:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_81:.*]] = fir.coordinate_of %[[VAL_80]], %[[VAL_79]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_77]] to %[[VAL_81]] : !fir.ref<!fir.char<1>>
-! CHECK: }
-! CHECK: %[[VAL_82:.*]] = fir.array_amend %[[VAL_19]], %[[VAL_35]] : (!fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.char<1,7>>) -> !fir.array<8x!fir.char<1,7>>
-! CHECK: fir.result %[[VAL_82]] : !fir.array<8x!fir.char<1,7>>
+! CHECK-LABEL: func.func @_QParray_substring_assignment2(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>> {fir.bindc_name = "a"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_8:.*]] = arith.constant 8 : index
+! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_9]]) dummy_scope %[[VAL_1]] {uniq_name = "_QFarray_substring_assignment2Ea"} : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>)
+! CHECK: %[[VAL_18:.*]] = fir.address_of(@_QQclX6E696365) : !fir.ref<!fir.char<1,4>>
+! CHECK: %[[VAL_19:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_18]] typeparams %[[VAL_19]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX6E696365"} : (!fir.ref<!fir.char<1,4>>, index) -> (!fir.ref<!fir.char<1,4>>, !fir.ref<!fir.char<1,4>>)
+! CHECK: %[[VAL_21:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_22:.*]] = arith.constant 7 : index
+! CHECK: %[[VAL_23:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_24:.*]] = hlfir.designate %[[VAL_10]]#0{"ch"} substr %[[VAL_21]], %[[VAL_22]] shape %[[VAL_9]] typeparams %[[VAL_23]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<8x!fir.char<1,4>>>
+! CHECK: hlfir.assign %[[VAL_20]]#0 to %[[VAL_24]] : !fir.ref<!fir.char<1,4>>, !fir.box<!fir.array<8x!fir.char<1,4>>>
+! CHECK: return
! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_8]], %[[VAL_83:.*]] to %[[VAL_0]]{{\[}}%[[VAL_7]]] : !fir.array<8x!fir.char<1,7>>, !fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.slice<1>
-! CHECK: return
-! CHECK: }
subroutine array_substring_assignment3(a,b)
@@ -422,3 +158,24 @@ subroutine array_substring_assignment3(a,b)
type(t) :: a(8), b(8)
a%ch(4:7) = b%ch(2:5)
end subroutine array_substring_assignment3
+! CHECK-LABEL: func.func @_QParray_substring_assignment3(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>> {fir.bindc_name = "a"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>> {fir.bindc_name = "b"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_9:.*]] = arith.constant 8 : index
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_10]]) dummy_scope %[[VAL_2]] {uniq_name = "_QFarray_substring_assignment3Ea"} : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>)
+! CHECK: %[[VAL_12:.*]] = arith.constant 8 : index
+! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_13]]) dummy_scope %[[VAL_2]] {uniq_name = "_QFarray_substring_assignment3Eb"} : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>)
+! CHECK: %[[VAL_22:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_23:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_24:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_25:.*]] = hlfir.designate %[[VAL_14]]#0{"ch"} substr %[[VAL_22]], %[[VAL_23]] shape %[[VAL_13]] typeparams %[[VAL_24]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<8x!fir.char<1,4>>>
+! CHECK: %[[VAL_26:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_27:.*]] = arith.constant 7 : index
+! CHECK: %[[VAL_28:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_11]]#0{"ch"} substr %[[VAL_26]], %[[VAL_27]] shape %[[VAL_10]] typeparams %[[VAL_28]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<8x!fir.char<1,4>>>
+! CHECK: hlfir.assign %[[VAL_25]] to %[[VAL_29]] : !fir.box<!fir.array<8x!fir.char<1,4>>>, !fir.box<!fir.array<8x!fir.char<1,4>>>
+! CHECK: return
+! CHECK: }
diff --git a/flang/test/Lower/components.f90 b/flang/test/Lower/components.f90
index f9297fcfed4ff..da77630df1d96 100644
--- a/flang/test/Lower/components.f90
+++ b/flang/test/Lower/components.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -hlfir=false -fwrapv %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir -I nw %s -o - | FileCheck %s
module components_test
type t1
@@ -20,70 +20,41 @@ module components_test
contains
- ! CHECK-LABEL: func @_QMcomponents_testPs1(
subroutine s1(i,j)
- ! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 1 : i32
- ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 6 : i32
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : i64
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : i64
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 2 : i64
- ! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QMcomponents_testEinstance) : !fir.ref<!fir.type<_QMcomponents_testTt3{h1:!fir.array<3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,h2:!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>}>>
- ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_7:.*]] : !fir.ref<i32>
- ! CHECK: %[[VAL_8:.*]] = arith.cmpi sge, %[[VAL_6]], %[[VAL_0]] : i32
- ! CHECK: %[[VAL_9:.*]] = arith.cmpi sle, %[[VAL_6]], %[[VAL_1]] : i32
- ! CHECK: %[[VAL_10:.*]] = arith.andi %[[VAL_8]], %[[VAL_9]] : i1
- ! CHECK: cond_br %[[VAL_10]], ^bb1, ^bb2
- ! CHECK: ^bb1:
- ! CHECK: %[[VAL_11:.*]] = fir.field_index h2, !fir.type<_QMcomponents_testTt3{h1:!fir.array<3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,h2:!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>}>
- ! CHECK: %[[VAL_12:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_11]] : (!fir.ref<!fir.type<_QMcomponents_testTt3{h1:!fir.array<3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,h2:!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>}>>, !fir.field) -> !fir.ref<!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>>
- ! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_3]] : (!fir.ref<!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>>, i64) -> !fir.ref<!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>
- ! CHECK: %[[VAL_14:.*]] = fir.field_index g2, !fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>
- ! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_14]] : (!fir.ref<!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>, !fir.field) -> !fir.ref<!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>>
- ! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_15]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]] : (!fir.ref<!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>>, i64, i64, i64) -> !fir.ref<!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>
- ! CHECK: %[[VAL_17:.*]] = fir.field_index i, !fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>
- ! CHECK: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_16]], %[[VAL_17]] : (!fir.ref<!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>, !fir.field) -> !fir.ref<!fir.array<6xi32>>
- ! CHECK: %[[VAL_19:.*]] = fir.load %[[VAL_7]] : !fir.ref<i32>
- ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i32) -> i64
- ! CHECK: %[[VAL_20_ADJ:.*]] = arith.subi %[[VAL_20]], %[[VAL_3]] : i64
- ! CHECK: %[[VAL_21:.*]] = fir.coordinate_of %[[VAL_18]], %[[VAL_20_ADJ]] : (!fir.ref<!fir.array<6xi32>>, i64) -> !fir.ref<i32>
- ! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_21]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_22]] to %[[VAL_23:.*]] : !fir.ref<i32>
- ! CHECK: br ^bb2
- ! CHECK: ^bb2:
- ! CHECK: return
- if (j >= 1 .and. j <= 6) then
- i = instance%h2(2)%g2(1,2,3)%i(j)
- end if
+ i = instance%h2(2)%g2(1,2,3)%i(j)
end subroutine s1
+! CHECK-LABEL: func.func @_QMcomponents_testPs1(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "i"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "j"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]] = fir.address_of(@_QMcomponents_testEinstance) : !fir.ref<!fir.type<_QMcomponents_testTt3
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QMcomponents_testEinstance"} : (!fir.ref<!fir.type<_QMcomponents_testTt3
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QMcomponents_testFs1Ei"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QMcomponents_testFs1Ej"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_7:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_4]]#0{"h2"} <%[[VAL_8]]> (%[[VAL_9]]) : (!fir.ref<!fir.type<_QMcomponents_testTt3
+! CHECK: %[[VAL_11:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_12:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_13:.*]] = arith.constant 4 : index
+! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_11]], %[[VAL_12]], %[[VAL_13]] : (index, index, index) -> !fir.shape<3>
+! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_16:.*]] = arith.constant 2 : index
+! CHECK: %[[VAL_17:.*]] = arith.constant 3 : index
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_10]]{"g2"} <%[[VAL_14]]> (%[[VAL_15]], %[[VAL_16]], %[[VAL_17]]) : (!fir.ref<!fir.type<_QMcomponents_testTt2
+! CHECK: %[[VAL_19:.*]] = arith.constant 6 : index
+! CHECK: %[[VAL_20:.*]] = fir.shape %[[VAL_19]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_6]]#0 : !fir.ref<i32>
+! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i32) -> i64
+! CHECK: %[[VAL_23:.*]] = hlfir.designate %[[VAL_18]]{"i"} <%[[VAL_20]]> (%[[VAL_22]]) : (!fir.ref<!fir.type<_QMcomponents_testTt1
+! CHECK: %[[VAL_24:.*]] = fir.load %[[VAL_23]] : !fir.ref<i32>
+! CHECK: hlfir.assign %[[VAL_24]] to %[[VAL_5]]#0 : i32, !fir.ref<i32>
+! CHECK: return
+! CHECK: }
end module components_test
-! CHECK-LABEL: func @_QPsliced_base() {
-! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 50 : index
-! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 1 : index
-! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 42 : i32
-! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 100 : index
-! CHECK: %[[VAL_5:.*]] = fir.alloca !fir.array<100x!fir.type<_QFsliced_baseTt{x:f32,y:i32}>> {bindc_name = "a", uniq_name = "_QFsliced_baseEa"}
-! CHECK: %[[VAL_6:.*]] = fir.field_index y, !fir.type<_QFsliced_baseTt{x:f32,y:i32}>
-! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_8:.*]] = fir.slice %[[VAL_1]], %[[VAL_0]], %[[VAL_1]] path %[[VAL_6]] : (index, index, index, !fir.field) -> !fir.slice<1>
-! CHECK: br ^bb1(%[[VAL_3]], %[[VAL_0]] : index, index)
-! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
-! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_3]] : index
-! CHECK: cond_br %[[VAL_11]], ^bb2, ^bb3
-! CHECK: ^bb2:
-! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_9]], %[[VAL_1]] : index
-! CHECK: %[[VAL_13:.*]] = fir.array_coor %[[VAL_5]](%[[VAL_7]]) {{\[}}%[[VAL_8]]] %[[VAL_12]] : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt{x:f32,y:i32}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<i32>
-! CHECK: fir.store %[[VAL_2]] to %[[VAL_13]] : !fir.ref<i32>
-! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_10]], %[[VAL_1]] : index
-! CHECK: br ^bb1(%[[VAL_12]], %[[VAL_14]] : index, index)
-! CHECK: ^bb3:
-! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_5]](%[[VAL_7]]) {{\[}}%[[VAL_8]]] : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt{x:f32,y:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<50xi32>>
-! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (!fir.box<!fir.array<50xi32>>) -> !fir.box<!fir.array<?xi32>>
-! CHECK: fir.call @_QPtakes_int_array(%[[VAL_16]]) {{.*}}: (!fir.box<!fir.array<?xi32>>) -> ()
-! CHECK: return
-! CHECK: }
subroutine sliced_base()
interface
@@ -99,8 +70,32 @@ subroutine takes_int_array(i)
a(1:50)%y = 42
call takes_int_array(a(1:50)%y)
end subroutine
+! CHECK-LABEL: func.func @_QPsliced_base() {
+! CHECK: %[[VAL_0:.*]] = arith.constant 100 : index
+! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.array<100x!fir.type<_QFsliced_baseTt
+! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_2]]) {uniq_name = "_QFsliced_baseEa"} : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt
+! CHECK: %[[VAL_4:.*]] = arith.constant 42 : i32
+! CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_6:.*]] = arith.constant 50 : index
+! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_8:.*]] = arith.constant 50 : index
+! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_5]]:%[[VAL_6]]:%[[VAL_7]]) shape %[[VAL_9]] : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt
+! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_10]]{"y"} shape %[[VAL_9]] : (!fir.ref<!fir.array<50x!fir.type<_QFsliced_baseTt
+! CHECK: hlfir.assign %[[VAL_4]] to %[[VAL_11]] : i32, !fir.box<!fir.array<50xi32>>
+! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_13:.*]] = arith.constant 50 : index
+! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_15:.*]] = arith.constant 50 : index
+! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_12]]:%[[VAL_13]]:%[[VAL_14]]) shape %[[VAL_16]] : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_17]]{"y"} shape %[[VAL_16]] : (!fir.ref<!fir.array<50x!fir.type<_QFsliced_baseTt
+! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (!fir.box<!fir.array<50xi32>>) -> !fir.box<!fir.array<?xi32>>
+! CHECK: fir.call @_QPtakes_int_array(%[[VAL_19]]) fastmath<contract> : (!fir.box<!fir.array<?xi32>>) -> ()
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: issue772
subroutine issue772(a, x)
! Verify that sub-expressions inside a component reference are
! only evaluated once.
@@ -109,209 +104,216 @@ subroutine issue772(a, x)
end type
real :: x(100)
type(t) :: a(100)
- ! CHECK: fir.call @_QPifoo()
- ! CHECK-NOT: fir.call @_QPifoo()
x = a(ifoo())%b(1:100:1)
- ! CHECK: fir.call @_QPibar()
- ! CHECK-NOT: fir.call @_QPibar()
print *, a(20)%b(1:ibar():1)
- ! CHECK: return
end subroutine
+! CHECK-LABEL: func.func @_QPissue772(
+! CHECK: fir.call @_QPifoo()
+! CHECK-NOT: fir.call @_QPifoo()
+! CHECK: fir.call @_QPibar()
+! CHECK-NOT: fir.call @_QPibar()
+! CHECK: return
! -----------------------------------------------------------------------------
! Test array%character array sections
! -----------------------------------------------------------------------------
-! CHECK-LABEL: func @_QPlhs_char_section(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt{c:!fir.char<1,5>}>>>{{.*}}) {
subroutine lhs_char_section(a)
- ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 5 : index
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_6:.*]] = fir.field_index c, !fir.type<_QFlhs_char_sectionTt{c:!fir.char<1,5>}>
- ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_8:.*]] = fir.slice %[[VAL_5]], %[[VAL_3]], %[[VAL_5]] path %[[VAL_6]] : (index, index, index, !fir.field) -> !fir.slice<1>
- ! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,5>>
- ! CHECK: br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index)
- ! CHECK: ^bb1(%[[VAL_10:.*]]: index, %[[VAL_11:.*]]: index):
- ! CHECK: %[[VAL_12:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_4]] : index
- ! CHECK: cond_br %[[VAL_12]], ^bb2, ^bb3
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_10]], %[[VAL_5]] : index
- ! CHECK: %[[VAL_14:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_7]]) {{\[}}%[[VAL_8]]] %[[VAL_13]] : (!fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt{c:!fir.char<1,5>}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_1]] : (index) -> i64
- ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_9]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_16]], %[[VAL_17]], %[[VAL_15]], %[[VAL_2]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_11]], %[[VAL_5]] : index
- ! CHECK: br ^bb1(%[[VAL_13]], %[[VAL_18]] : index, index)
-
type t
character(5) :: c
end type
type(t) :: a(10)
a%c = "hello"
- ! CHECK: return
- ! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QPlhs_char_section(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_3]]) dummy_scope %[[VAL_1]] {uniq_name = "_QFlhs_char_sectionEa"} : (!fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt
+! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QQclX68656C6C6F) : !fir.ref<!fir.char<1,5>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]] typeparams %[[VAL_6]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX68656C6C6F"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_8:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_4]]#0{"c"} shape %[[VAL_3]] typeparams %[[VAL_8]] : (!fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt
+! CHECK: hlfir.assign %[[VAL_7]]#0 to %[[VAL_9]] : !fir.ref<!fir.char<1,5>>, !fir.box<!fir.array<10x!fir.char<1,5>>>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPrhs_char_section(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt{c:!fir.char<1,10>}>>>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
subroutine rhs_char_section(a, c)
- ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
- ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_9:.*]] = fir.field_index c, !fir.type<_QFrhs_char_sectionTt{c:!fir.char<1,10>}>
- ! CHECK: %[[VAL_10:.*]] = fir.slice %[[VAL_5]], %[[VAL_3]], %[[VAL_5]] path %[[VAL_9]] : (index, index, index, !fir.field) -> !fir.slice<1>
- ! CHECK: br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index)
- ! CHECK: ^bb1(%[[VAL_11:.*]]: index, %[[VAL_12:.*]]: index):
- ! CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_4]] : index
- ! CHECK: cond_br %[[VAL_13]], ^bb2, ^bb3
- ! CHECK: ^bb2:
- ! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_11]], %[[VAL_5]] : index
- ! CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_8]]) {{\[}}%[[VAL_10]]] %[[VAL_14]] : (!fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt{c:!fir.char<1,10>}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_16:.*]] = fir.array_coor %[[VAL_7]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
- ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_15]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_18]], %[[VAL_19]], %[[VAL_17]], %[[VAL_2]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_12]], %[[VAL_5]] : index
- ! CHECK: br ^bb1(%[[VAL_14]], %[[VAL_20]] : index, index)
-
type t
character(10) :: c
end type
type(t) :: a(10)
character(10) :: c(10)
c = a%c
- ! CHECK: return
- ! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QPrhs_char_section(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_4]]) dummy_scope %[[VAL_2]] {uniq_name = "_QFrhs_char_sectionEa"} : (!fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt
+! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
+! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_7]](%[[VAL_10]]) typeparams %[[VAL_8]] dummy_scope %[[VAL_2]] {uniq_name = "_QFrhs_char_sectionEc"} : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.ref<!fir.array<10x!fir.char<1,10>>>)
+! CHECK: %[[VAL_12:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_5]]#0{"c"} shape %[[VAL_4]] typeparams %[[VAL_12]] : (!fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt
+! CHECK: hlfir.assign %[[VAL_13]] to %[[VAL_11]]#0 : !fir.box<!fir.array<10x!fir.char<1,10>>>, !fir.ref<!fir.array<10x!fir.char<1,10>>>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPelemental_char_section(
-! CHECK-SAME: %[[A:.*]]: !fir.ref<!fir.array<{{.*}}>>{{.*}}, %[[I:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}) {
subroutine elemental_char_section(a, i)
type t
character(10) :: c
end type
type(t) :: a(10)
integer :: i(10)
- ! CHECK-DAG: %[[VAL_34:.*]] = arith.constant 5 : index
- ! CHECK-DAG: %[[VAL_35:.*]] = arith.constant false
- ! CHECK-DAG: %[[VAL_36:.*]] = arith.constant 10 : index
- ! CHECK-DAG: %[[VAL_37:.*]] = arith.constant 0 : index
- ! CHECK-DAG: %[[VAL_38:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_39:.*]] = fir.shape %[[VAL_36]] : (index) -> !fir.shape<1>
- ! CHECK: %[[VAL_40:.*]] = fir.field_index c, !fir.type<_QFelemental_char_sectionTt{c:!fir.char<1,10>}>
- ! CHECK: %[[VAL_41:.*]] = fir.slice %[[VAL_38]], %[[VAL_36]], %[[VAL_38]] path %[[VAL_40]] : (index, index, index, !fir.field) -> !fir.slice<1>
- ! CHECK: %[[VAL_42:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>>
- ! CHECK: br ^bb1(%[[VAL_37]], %[[VAL_36]] : index, index)
- ! CHECK:^bb1(%[[VAL_43:.*]]: index, %[[VAL_44:.*]]: index):
- ! CHECK: %[[VAL_45:.*]] = arith.cmpi sgt, %[[VAL_44]], %[[VAL_37]] : index
- ! CHECK: cond_br %[[VAL_45]], ^bb2, ^bb3
- ! CHECK:^bb2:
- ! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_43]], %[[VAL_38]] : index
- ! CHECK: %[[VAL_47:.*]] = fir.array_coor %[[A]](%[[VAL_39]]) {{\[}}%[[VAL_41]]] %[[VAL_46]] : (!fir.ref<!fir.array<10x!fir.type<_QFelemental_char_sectionTt{c:!fir.char<1,10>}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,10>>
- ! CHECK: %[[VAL_49:.*]] = fir.convert %[[VAL_47]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_50:.*]] = fir.convert %[[VAL_36]] : (index) -> i64
- ! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_42]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_34]] : (index) -> i64
- ! CHECK: %[[VAL_53:.*]] = fir.call @_FortranAScan1(%[[VAL_49]], %[[VAL_50]], %[[VAL_51]], %[[VAL_52]], %[[VAL_35]]) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i8>, i64, i1) -> i64
- ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i32
- ! CHECK: %[[VAL_55:.*]] = fir.array_coor %[[I]](%[[VAL_39]]) %[[VAL_46]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_54]] to %[[VAL_55]] : !fir.ref<i32>
- ! CHECK: %[[VAL_57:.*]] = arith.subi %[[VAL_44]], %[[VAL_38]] : index
- ! CHECK: br ^bb1(%[[VAL_46]], %[[VAL_57]] : index, index)
i = scan(a%c, "hello")
end subroutine
+! CHECK-LABEL: func.func @_QPelemental_char_section(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFelemental_char_sectionTt
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "i"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_4]]) dummy_scope %[[VAL_2]] {uniq_name = "_QFelemental_char_sectionEa"} : (!fir.ref<!fir.array<10x!fir.type<_QFelemental_char_sectionTt
+! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_7]]) dummy_scope %[[VAL_2]] {uniq_name = "_QFelemental_char_sectionEi"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_5]]#0{"c"} shape %[[VAL_4]] typeparams %[[VAL_9]] : (!fir.ref<!fir.array<10x!fir.type<_QFelemental_char_sectionTt
+! CHECK: %[[VAL_11:.*]] = fir.address_of(@_QQclX68656C6C6F) : !fir.ref<!fir.char<1,5>>
+! CHECK: %[[VAL_12:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_11]] typeparams %[[VAL_12]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX68656C6C6F"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_14:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<10xi32> {
+! CHECK: ^bb0(%[[VAL_15:.*]]: index):
+! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_10]] (%[[VAL_15]]) typeparams %[[VAL_9]] : (!fir.box<!fir.array<10x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
+! CHECK: %[[VAL_17:.*]] = arith.constant false
+! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
+! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_9]] : (index) -> i64
+! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_13]]#1 : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
+! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_12]] : (index) -> i64
+! CHECK: %[[VAL_22:.*]] = fir.call @_FortranAScan1(%[[VAL_18]], %[[VAL_19]], %[[VAL_20]], %[[VAL_21]], %[[VAL_17]]) fastmath<contract> : (!fir.ref<i8>, i64, !fir.ref<i8>, i64, i1) -> i64
+! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> i32
+! CHECK: hlfir.yield_element %[[VAL_23]] : i32
+! CHECK: }
+! CHECK: hlfir.assign %[[VAL_14]] to %[[VAL_8]]#0 : !hlfir.expr<10xi32>, !fir.ref<!fir.array<10xi32>>
+! CHECK: hlfir.destroy %[[VAL_14]] : !hlfir.expr<10xi32>
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: extended_type_components
+! CHECK-LABEL: func.func @_QPextended_type_components() {
subroutine extended_type_components
type t1
- integer :: t1i = 1
+ integer :: t1i
end type t1
type, extends(t1) :: t2
- integer :: t2i = 2
+ integer :: t2i
end type t2
type, extends(t2) :: t3
- integer :: t3i = 3
+ integer :: t3i
end type t3
type, extends(t3) :: t4
- integer :: t4i = 4
+ integer :: t4i
end type t4
+! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<5xi32>>>
+! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<5xi32>>>
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<5xi32>>>
+! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<5xi32>>>
+! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFextended_type_componentsEu3v"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_6:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_7:.*]] = fir.alloca !fir.array<5x!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_7]](%[[VAL_8]]) {uniq_name = "_QFextended_type_componentsEu3va"} : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3
type u1
- integer :: u1i = 11
+ integer :: u1i
end type u1
type, extends(u1) :: u2
- integer :: u2i = 22
+ integer :: u2i
type(t3) :: u2t3
type(t3) :: u2t4
end type u2
type, extends(u2) :: u3
- integer :: u3i = 33
+ integer :: u3i
end type u3
- ! CHECK: %[[u3v:.*]] = fir.alloca !fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}> {bindc_name = "u3v", uniq_name = "_QFextended_type_componentsEu3v"}
type(u3) :: u3v
- ! CHECK: %[[u3va:.*]] = fir.alloca !fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>> {bindc_name = "u3va", uniq_name = "_QFextended_type_componentsEu3va"}
type(u3) :: u3va(5)
- ! CHECK: %[[VAL_10:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_11:.*]] = fir.field_index u2t3, !fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>
- ! CHECK: %[[VAL_12:.*]] = fir.field_index t1i, !fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>
- ! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[u3v]], %[[VAL_11]], %[[VAL_12]] : (!fir.ref<!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>, !fir.field, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_13]] : !fir.ref<i32>
- ! CHECK: %[[VAL_15:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_10]], %[[VAL_14]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
- print*, u3v%u2t3%t1i
+ call foo1(u3v%u2t3%t1i)
+! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_5]]#0{"u2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_10]]{"u2t3"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_11]]{"t2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_12]]{"t1"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_13]]{"t1i"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt1
+! CHECK: fir.call @_QPfoo1(%[[VAL_14]]) fastmath<contract> : (!fir.ref<i32>) -> ()
- ! CHECK: %[[VAL_20:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_13]] : !fir.ref<i32>
- ! CHECK: %[[VAL_22:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_20]], %[[VAL_21]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
- print*, u3v%u2%u2t3%t2%t1%t1i ! different syntax for the previous value
+ call foo2(u3v%u2%u2t3%t2%t1%t1i) ! different syntax for the previous value
+! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_5]]#0{"u2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_15]]{"u2t3"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_16]]{"t2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_17]]{"t1"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_19:.*]] = hlfir.designate %[[VAL_18]]{"t1i"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt1
+! CHECK: fir.call @_QPfoo2(%[[VAL_19]]) fastmath<contract> : (!fir.ref<i32>) -> ()
- ! CHECK: %[[VAL_30:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_31:.*]] = fir.field_index u2t4, !fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>
- ! CHECK: %[[VAL_32:.*]] = fir.coordinate_of %[[u3v]], %[[VAL_31]], %[[VAL_12]] : (!fir.ref<!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>, !fir.field, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_32]] : !fir.ref<i32>
- ! CHECK: %[[VAL_34:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_30]], %[[VAL_33]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
- print*, u3v%u2t4%t1i
+ call foo3(u3v%u2t4%t1i)
+! CHECK: %[[VAL_20:.*]] = hlfir.designate %[[VAL_5]]#0{"u2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_21:.*]] = hlfir.designate %[[VAL_20]]{"u2t4"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_22:.*]] = hlfir.designate %[[VAL_21]]{"t2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_23:.*]] = hlfir.designate %[[VAL_22]]{"t1"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_24:.*]] = hlfir.designate %[[VAL_23]]{"t1i"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt1
+! CHECK: fir.call @_QPfoo3(%[[VAL_24]]) fastmath<contract> : (!fir.ref<i32>) -> ()
- ! CHECK: %[[VAL_40:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_41:.*]] = fir.field_index t2i, !fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>
- ! CHECK: %[[VAL_42:.*]] = fir.coordinate_of %[[u3v]], %[[VAL_31]], %[[VAL_41]] : (!fir.ref<!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>, !fir.field, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_43:.*]] = fir.load %[[VAL_42]] : !fir.ref<i32>
- ! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_40]], %[[VAL_43]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
- print*, u3v%u2t4%t2i
+ call foo4(u3v%u2t4%t2i)
+! CHECK: %[[VAL_25:.*]] = hlfir.designate %[[VAL_5]]#0{"u2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_26:.*]] = hlfir.designate %[[VAL_25]]{"u2t4"} : (!fir.ref<!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_27:.*]] = hlfir.designate %[[VAL_26]]{"t2"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_28:.*]] = hlfir.designate %[[VAL_27]]{"t2i"} : (!fir.ref<!fir.type<_QFextended_type_componentsTt2
+! CHECK: fir.call @_QPfoo4(%[[VAL_28]]) fastmath<contract> : (!fir.ref<i32>) -> ()
- ! CHECK: %[[VAL_50:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_51:.*]] = fir.slice %c1{{.*}}, %c5{{.*}}, %c1{{.*}} path %{{.*}}, %{{.*}} : (index, index, index, !fir.field, !fir.field) -> !fir.slice<1>
- ! CHECK: %[[VAL_52:.*]] = fir.embox %[[u3va]](%{{.*}}) [%[[VAL_51]]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>>,
- ! CHECK: %[[VAL_53:.*]] = fir.convert %[[VAL_52]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
- ! CHECK: %[[VAL_54:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_50]], %[[VAL_53]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- print*, u3va%u2t3%t1i
+ call foo5(u3va%u2t3%t1i)
+! CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_9]]#0{"u2"} shape %[[VAL_8]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_30:.*]] = hlfir.designate %[[VAL_29]]{"u2t3"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_31:.*]] = hlfir.designate %[[VAL_30]]{"t2"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_32:.*]] = hlfir.designate %[[VAL_31]]{"t1"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_33:.*]] = hlfir.designate %[[VAL_32]]{"t1i"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt1
+! CHECK: %[[VAL_34:.*]]:2 = hlfir.copy_in %[[VAL_33]] to %[[VAL_3]] : (!fir.box<!fir.array<5xi32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<5xi32>>>>) -> (!fir.box<!fir.array<5xi32>>, i1)
+! CHECK: %[[VAL_35:.*]] = fir.box_addr %[[VAL_34]]#0 : (!fir.box<!fir.array<5xi32>>) -> !fir.ref<!fir.array<5xi32>>
+! CHECK: fir.call @_QPfoo5(%[[VAL_35]]) fastmath<contract> : (!fir.ref<!fir.array<5xi32>>) -> ()
- ! CHECK: %[[VAL_60:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_61:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_60]], %[[VAL_53]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- print*, u3va%u2%u2t3%t2%t1%t1i ! different syntax for the previous value
+ call foo6(u3va%u2%u2t3%t2%t1%t1i) ! different syntax for the previous value
+! CHECK: %[[VAL_36:.*]] = hlfir.designate %[[VAL_9]]#0{"u2"} shape %[[VAL_8]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_37:.*]] = hlfir.designate %[[VAL_36]]{"u2t3"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_38:.*]] = hlfir.designate %[[VAL_37]]{"t2"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_39:.*]] = hlfir.designate %[[VAL_38]]{"t1"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_40:.*]] = hlfir.designate %[[VAL_39]]{"t1i"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt1
+! CHECK: %[[VAL_41:.*]]:2 = hlfir.copy_in %[[VAL_40]] to %[[VAL_2]] : (!fir.box<!fir.array<5xi32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<5xi32>>>>) -> (!fir.box<!fir.array<5xi32>>, i1)
+! CHECK: %[[VAL_42:.*]] = fir.box_addr %[[VAL_41]]#0 : (!fir.box<!fir.array<5xi32>>) -> !fir.ref<!fir.array<5xi32>>
+! CHECK: fir.call @_QPfoo6(%[[VAL_42]]) fastmath<contract> : (!fir.ref<!fir.array<5xi32>>) -> ()
- ! CHECK: %[[VAL_70:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_71:.*]] = fir.slice %c1{{.*}}, %c5{{.*}}, %c1{{.*}} path %{{.*}}, %{{.*}} : (index, index, index, !fir.field, !fir.field) -> !fir.slice<1>
- ! CHECK: %[[VAL_72:.*]] = fir.embox %[[u3va]](%{{.*}}) [%[[VAL_71]]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<5xi32>>
- ! CHECK: %[[VAL_73:.*]] = fir.convert %[[VAL_72]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
- ! CHECK: %[[VAL_74:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_70]], %[[VAL_73]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- print*, u3va%u2t4%t1i
+ call foo7(u3va%u2t4%t1i)
+! CHECK: %[[VAL_43:.*]] = hlfir.designate %[[VAL_9]]#0{"u2"} shape %[[VAL_8]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_44:.*]] = hlfir.designate %[[VAL_43]]{"u2t4"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_45:.*]] = hlfir.designate %[[VAL_44]]{"t2"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_46:.*]] = hlfir.designate %[[VAL_45]]{"t1"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_47:.*]] = hlfir.designate %[[VAL_46]]{"t1i"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt1
+! CHECK: %[[VAL_48:.*]]:2 = hlfir.copy_in %[[VAL_47]] to %[[VAL_1]] : (!fir.box<!fir.array<5xi32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<5xi32>>>>) -> (!fir.box<!fir.array<5xi32>>, i1)
+! CHECK: %[[VAL_49:.*]] = fir.box_addr %[[VAL_48]]#0 : (!fir.box<!fir.array<5xi32>>) -> !fir.ref<!fir.array<5xi32>>
+! CHECK: fir.call @_QPfoo7(%[[VAL_49]]) fastmath<contract> : (!fir.ref<!fir.array<5xi32>>) -> ()
- ! CHECK: %[[VAL_80:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
- ! CHECK: %[[VAL_81:.*]] = fir.slice %c1{{.*}}, %c5{{.*}}, %c1{{.*}} path %{{.*}}, %{{.*}} : (index, index, index, !fir.field, !fir.field) -> !fir.slice<1>
- ! CHECK: %[[VAL_82:.*]] = fir.embox %[[u3va]](%{{.*}}) [%[[VAL_81]]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<5xi32>>
- ! CHECK: %[[VAL_83:.*]] = fir.convert %[[VAL_82]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
- ! CHECK: %[[VAL_84:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_80]], %[[VAL_83]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
- print*, u3va%u2t4%t2i
- end subroutine extended_type_components
+ call foo8(u3va%u2t4%t2i)
+! CHECK: %[[VAL_50:.*]] = hlfir.designate %[[VAL_9]]#0{"u2"} shape %[[VAL_8]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3
+! CHECK: %[[VAL_51:.*]] = hlfir.designate %[[VAL_50]]{"u2t4"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTu2
+! CHECK: %[[VAL_52:.*]] = hlfir.designate %[[VAL_51]]{"t2"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt3
+! CHECK: %[[VAL_53:.*]] = hlfir.designate %[[VAL_52]]{"t2i"} shape %[[VAL_8]] : (!fir.box<!fir.array<5x!fir.type<_QFextended_type_componentsTt2
+! CHECK: %[[VAL_54:.*]]:2 = hlfir.copy_in %[[VAL_53]] to %[[VAL_0]] : (!fir.box<!fir.array<5xi32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<5xi32>>>>) -> (!fir.box<!fir.array<5xi32>>, i1)
+! CHECK: %[[VAL_55:.*]] = fir.box_addr %[[VAL_54]]#0 : (!fir.box<!fir.array<5xi32>>) -> !fir.ref<!fir.array<5xi32>>
+! CHECK: fir.call @_QPfoo8(%[[VAL_55]]) fastmath<contract> : (!fir.ref<!fir.array<5xi32>>) -> ()
+end subroutine extended_type_components
diff --git a/flang/test/Lower/derived-assignments.f90 b/flang/test/Lower/derived-assignments.f90
index 90c360978fd2a..5870ea11fc496 100644
--- a/flang/test/Lower/derived-assignments.f90
+++ b/flang/test/Lower/derived-assignments.f90
@@ -1,30 +1,23 @@
! Test lowering of derived type assignments
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir -I nw %s -o - | FileCheck %s
! Assignment of simple "struct" with trivial intrinsic members.
-! CHECK-LABEL: func @_QPtest1
subroutine test1
type t
integer a
integer b
end type t
type(t) :: t1, t2
- ! CHECK-DAG: %[[VAL_0:.*]] = fir.alloca !fir.type<_QFtest1Tt{a:i32,b:i32}> {{{.*}}uniq_name = "_QFtest1Et1"}
- ! CHECK-DAG: %[[VAL_1:.*]] = fir.alloca !fir.type<_QFtest1Tt{a:i32,b:i32}> {{{.*}}uniq_name = "_QFtest1Et2"}
- ! CHECK: %[[VAL_2:.*]] = fir.field_index a, !fir.type<_QFtest1Tt{a:i32,b:i32}>
- ! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.type<_QFtest1Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_2b:.*]] = fir.field_index a, !fir.type<_QFtest1Tt{a:i32,b:i32}>
- ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2b]] : (!fir.ref<!fir.type<_QFtest1Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_5]] to %[[VAL_4]] : !fir.ref<i32>
- ! CHECK: %[[VAL_6:.*]] = fir.field_index b, !fir.type<_QFtest1Tt{a:i32,b:i32}>
- ! CHECK: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_6]] : (!fir.ref<!fir.type<_QFtest1Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_6b:.*]] = fir.field_index b, !fir.type<_QFtest1Tt{a:i32,b:i32}>
- ! CHECK: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_6b]] : (!fir.ref<!fir.type<_QFtest1Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_7]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_9]] to %[[VAL_8]] : !fir.ref<i32>
t1 = t2
end subroutine test1
+! CHECK-LABEL: func.func @_QPtest1() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.type<_QFtest1Tt
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest1Et1"} : (!fir.ref<!fir.type<_QFtest1Tt
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.type<_QFtest1Tt
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFtest1Et2"} : (!fir.ref<!fir.type<_QFtest1Tt
+! CHECK: hlfir.assign %[[VAL_3]]#0 to %[[VAL_1]]#0 : !fir.ref<!fir.type<_QFtest1Tt
+! CHECK: return
+! CHECK: }
! Test a defined assignment on a simple struct.
module m2
@@ -36,71 +29,65 @@ module m2
module procedure t_to_t
end interface assignment (=)
contains
- ! CHECK-LABEL: func @_QMm2Ptest2
subroutine test2
type(t) :: t1, t2
- ! CHECK: fir.call @_QMm2Pt_to_t(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>, !fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>) -> ()
t1 = t2
- ! CHECK: return
end subroutine test2
+! CHECK-LABEL: func.func @_QMm2Ptest2() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.type<_QMm2Tt
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QMm2Ftest2Et1"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.type<_QMm2Tt
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QMm2Ftest2Et2"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: hlfir.region_assign {
+! CHECK: hlfir.yield %[[VAL_3]]#0 : !fir.ref<!fir.type<_QMm2Tt
+! CHECK: } to {
+! CHECK: hlfir.yield %[[VAL_1]]#0 : !fir.ref<!fir.type<_QMm2Tt
+! CHECK: } user_defined_assign (%[[VAL_4:.*]]: !fir.ref<!fir.type<_QMm2Tt{{.*}}) to (%[[VAL_5:.*]]: !fir.ref<!fir.type<_QMm2Tt
+! CHECK: fir.call @_QMm2Pt_to_t(%[[VAL_5]], %[[VAL_4]]) fastmath<contract> : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: }
+! CHECK: return
+! CHECK: }
! Swap elements on assignment.
- ! CHECK-LABEL: func @_QMm2Pt_to_t(
- ! CHECK-SAME: %[[a1:[^:]*]]: !fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>{{.*}}, %[[b1:[^:]*]]: !fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>{{.*}}) {
subroutine t_to_t(a1,b1)
type(t), intent(out) :: a1
type(t), intent(in) :: b1
- ! CHECK: %[[b:.*]] = fir.field_index b, !fir.type<_QMm2Tt{a:i32,b:i32}>
- ! CHECK: %[[b1b:.*]] = fir.coordinate_of %[[b1]], %[[b]] : (!fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[v:.*]] = fir.load %[[b1b]] : !fir.ref<i32>
- ! CHECK: %[[a:.*]] = fir.field_index a, !fir.type<_QMm2Tt{a:i32,b:i32}>
- ! CHECK: %[[a1a:.*]] = fir.coordinate_of %[[a1]], %[[a]] : (!fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: fir.store %[[v]] to %[[a1a]] : !fir.ref<i32>
- ! CHECK: %[[a:.*]] = fir.field_index a, !fir.type<_QMm2Tt{a:i32,b:i32}>
- ! CHECK: %[[b1a:.*]] = fir.coordinate_of %[[b1]], %[[a]] : (!fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[v:.*]] = fir.load %[[b1a]] : !fir.ref<i32>
- ! CHECK: %[[b:.*]] = fir.field_index b, !fir.type<_QMm2Tt{a:i32,b:i32}>
- ! CHECK: %[[a1b:.*]] = fir.coordinate_of %[[a1]], %[[b]] : (!fir.ref<!fir.type<_QMm2Tt{a:i32,b:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: fir.store %[[v]] to %[[a1b]] : !fir.ref<i32>
a1%a = b1%b
a1%b = b1%a
- ! CHECK: return
end subroutine t_to_t
+! CHECK-LABEL: func.func @_QMm2Pt_to_t(
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare {{.*}} dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<intent_out>, uniq_name = "_QMm2Ft_to_tEa1"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QMm2Ft_to_tEb1"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: %[[VAL_5:.*]] = hlfir.designate %[[VAL_4]]#0{"b"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_5]] : !fir.ref<i32>
+! CHECK: %[[VAL_7:.*]] = hlfir.designate %[[VAL_3]]#0{"a"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_7]] : i32, !fir.ref<i32>
+! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_4]]#0{"a"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_8]] : !fir.ref<i32>
+! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_3]]#0{"b"} : (!fir.ref<!fir.type<_QMm2Tt
+! CHECK: hlfir.assign %[[VAL_9]] to %[[VAL_10]] : i32, !fir.ref<i32>
+! CHECK: return
+! CHECK: }
end module m2
-! CHECK-LABEL: func @_QPtest3
subroutine test3
type t
character(LEN=20) :: m_c
integer :: m_i
end type t
type(t) :: t1, t2
- ! CHECK-DAG: %[[VAL_0:.*]] = fir.alloca !fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}> {{{.*}}uniq_name = "_QFtest3Et1"}
- ! CHECK-DAG: %[[VAL_1:.*]] = fir.alloca !fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}> {{{.*}}uniq_name = "_QFtest3Et2"}
- ! CHECK: %[[VAL_2:.*]] = fir.field_index m_c, !fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>
- ! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>>, !fir.field) -> !fir.ref<!fir.char<1,20>>
- ! CHECK: %[[VAL_2b:.*]] = fir.field_index m_c, !fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>
- ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2b]] : (!fir.ref<!fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>>, !fir.field) -> !fir.ref<!fir.char<1,20>>
- ! CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
- ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i64
- ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_5]] : (index) -> i64
- ! CHECK: %[[VAL_8:.*]] = arith.muli %[[VAL_6]], %[[VAL_7]] : i64
- ! CHECK: %[[VAL_9:.*]] = arith.constant false
- ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<i8>
- ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_10]], %[[VAL_11]], %[[VAL_8]], %[[VAL_9]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[VAL_12:.*]] = fir.field_index m_i, !fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>
- ! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_12]] : (!fir.ref<!fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_12b:.*]] = fir.field_index m_i, !fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>
- ! CHECK: %[[VAL_14:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_12b]] : (!fir.ref<!fir.type<_QFtest3Tt{m_c:!fir.char<1,20>,m_i:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_13]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_15]] to %[[VAL_14]] : !fir.ref<i32>
t1 = t2
- ! CHECK: return
end subroutine test3
+! CHECK-LABEL: func.func @_QPtest3() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.type<_QFtest3Tt
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest3Et1"} : (!fir.ref<!fir.type<_QFtest3Tt
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.type<_QFtest3Tt
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFtest3Et2"} : (!fir.ref<!fir.type<_QFtest3Tt
+! CHECK: hlfir.assign %[[VAL_3]]#0 to %[[VAL_1]]#0 : !fir.ref<!fir.type<_QFtest3Tt
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPtest_array_comp(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>>{{.*}}) {
subroutine test_array_comp(t1, t2)
type t
real :: m_x(10)
@@ -108,30 +95,16 @@ subroutine test_array_comp(t1, t2)
end type t
type(t) :: t1, t2
- ! CHECK: %[[VAL_2:.*]] = fir.field_index m_x, !fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>
- ! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>>, !fir.field) -> !fir.ref<!fir.array<10xf32>>
- ! CHECK: %[[VAL_2b:.*]] = fir.field_index m_x, !fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>
- ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2b]] : (!fir.ref<!fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>>, !fir.field) -> !fir.ref<!fir.array<10xf32>>
- ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index
- ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
- ! CHECK: %[[VAL_7:.*]] = arith.constant 9 : index
- ! CHECK: fir.do_loop %[[VAL_8:.*]] = %[[VAL_5]] to %[[VAL_7]] step %[[VAL_6]] {
- ! CHECK: %[[VAL_9:.*]] = fir.coordinate_of %[[VAL_4]], %[[VAL_8]] : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
- ! CHECK: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_8]] : (!fir.ref<!fir.array<10xf32>>, index) -> !fir.ref<f32>
- ! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_10]] : !fir.ref<f32>
- ! CHECK: fir.store %[[VAL_11]] to %[[VAL_9]] : !fir.ref<f32>
- ! CHECK: }
- ! CHECK: %[[VAL_12:.*]] = fir.field_index m_i, !fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>
- ! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_12]] : (!fir.ref<!fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_12b:.*]] = fir.field_index m_i, !fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>
- ! CHECK: %[[VAL_14:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_12b]] : (!fir.ref<!fir.type<_QFtest_array_compTt{m_x:!fir.array<10xf32>,m_i:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_13]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_15]] to %[[VAL_14]] : !fir.ref<i32>
t1 = t2
end subroutine
+! CHECK-LABEL: func.func @_QPtest_array_comp(
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_array_compEt1"} : (!fir.ref<!fir.type<_QFtest_array_compTt
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_array_compEt2"} : (!fir.ref<!fir.type<_QFtest_array_compTt
+! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_3]]#0 : !fir.ref<!fir.type<_QFtest_array_compTt
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPtest_ptr_comp(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>>{{.*}}, %[[VAL_1]]: !fir.ref<!fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>>{{.*}}) {
subroutine test_ptr_comp(t1, t2)
type t
complex, pointer :: ptr(:)
@@ -139,23 +112,16 @@ subroutine test_ptr_comp(t1, t2)
end type t
type(t) :: t1, t2
- ! CHECK: %[[VAL_2:.*]] = fir.field_index ptr, !fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>
- ! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>>, !fir.field) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>>
- ! CHECK: %[[VAL_2b:.*]] = fir.field_index ptr, !fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>
- ! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2b]] : (!fir.ref<!fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>>, !fir.field) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>>
- ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>>
- ! CHECK: fir.store %[[VAL_5]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>>
- ! CHECK: %[[VAL_6:.*]] = fir.field_index m_i, !fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>
- ! CHECK: %[[VAL_7:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_6]] : (!fir.ref<!fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_6b:.*]] = fir.field_index m_i, !fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>
- ! CHECK: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_6b]] : (!fir.ref<!fir.type<_QFtest_ptr_compTt{ptr:!fir.box<!fir.ptr<!fir.array<?xcomplex<f32>>>>,m_i:i32}>>, !fir.field) -> !fir.ref<i32>
- ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_7]] : !fir.ref<i32>
- ! CHECK: fir.store %[[VAL_9]] to %[[VAL_8]] : !fir.ref<i32>
t1 = t2
end subroutine
+! CHECK-LABEL: func.func @_QPtest_ptr_comp(
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_ptr_compEt1"} : (!fir.ref<!fir.type<_QFtest_ptr_compTt
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_ptr_compEt2"} : (!fir.ref<!fir.type<_QFtest_ptr_compTt
+! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_3]]#0 : !fir.ref<!fir.type<_QFtest_ptr_compTt
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPtest_box_assign(
-! CHECK-SAME: %[[t1:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>>{{.*}}, %[[t2:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>>{{.*}}) {
subroutine test_box_assign(t1, t2)
type t
integer :: i
@@ -164,18 +130,20 @@ subroutine test_box_assign(t1, t2)
! lowering is conservative with derived type pointers because it does not make a difference between the
! polymorphic and non polymorphic ones at the FIR level.
type(t), pointer :: t1, t2
- ! CHECK: %[[tmpBox:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>
- ! CHECK: %[[t2Load:.*]] = fir.load %[[t2]] : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>>
- ! CHECK: %[[t1Load:.*]] = fir.load %[[t1]] : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>>
- ! CHECK: fir.store %[[t1Load]] to %[[tmpBox]] : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>>
- ! CHECK: %[[lhs:.*]] = fir.convert %[[tmpBox]] : (!fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>>) -> !fir.ref<!fir.box<none>>
- ! CHECK: %[[rhs:.*]] = fir.convert %[[t2Load]] : (!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt{i:i32}>>>) -> !fir.box<none>
- ! CHECK: fir.call @_FortranAAssign(%[[lhs]], %[[rhs]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
t1 = t2
end subroutine
+! CHECK-LABEL: func.func @_QPtest_box_assign(
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFtest_box_assignEt1"} : (!fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFtest_box_assignEt2"} : (!fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: %[[VAL_6:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box<!fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_8]] : !fir.ptr<!fir.type<_QFtest_box_assignTt
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPtest_alloc_comp(
-! CHECK-SAME: %[[t1:.*]]: !fir.ref<!fir.type<_QFtest_alloc_compTt{x:!fir.box<!fir.heap<!fir.array<?x?xf32>>>,i:i32}>>{{.*}}, %[[t2:.*]]: !fir.ref<!fir.type<_QFtest_alloc_compTt{x:!fir.box<!fir.heap<!fir.array<?x?xf32>>>,i:i32}>>{{.*}}) {
subroutine test_alloc_comp(t1, t2)
! Test that derived type assignment with allocatable components are using the
! runtime to handle the deep copy.
@@ -184,53 +152,49 @@ subroutine test_alloc_comp(t1, t2)
integer :: i
end type
type(t) :: t1, t2
- ! CHECK: %[[tmpBox:.*]] = fir.alloca !fir.box<!fir.type<_QFtest_alloc_compTt{{.*}}>>
- ! CHECK: %[[t1Box:.*]] = fir.embox %[[t1]] : (!fir.ref<!fir.type<_QFtest_alloc_compTt{{.*}}>>) -> !fir.box<!fir.type<_QFtest_alloc_compTt{{.*}}>>
- ! CHECK: %[[t2Box:.*]] = fir.embox %[[t2]] : (!fir.ref<!fir.type<_QFtest_alloc_compTt{{.*}}>>) -> !fir.box<!fir.type<_QFtest_alloc_compTt{{.*}}>>
- ! CHECK: fir.store %[[t1Box]] to %[[tmpBox]] : !fir.ref<!fir.box<!fir.type<_QFtest_alloc_compTt{{.*}}>>>
- ! CHECK: %[[lhs:.*]] = fir.convert %[[tmpBox]] : (!fir.ref<!fir.box<!fir.type<_QFtest_alloc_compTt{{.*}}>>>) -> !fir.ref<!fir.box<none>>
- ! CHECK: %[[rhs:.*]] = fir.convert %[[t2Box]] : (!fir.box<!fir.type<_QFtest_alloc_compTt{{.*}}>>) -> !fir.box<none>
- ! CHECK: fir.call @_FortranAAssign(%[[lhs]], %[[rhs]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
t1 = t2
end subroutine
+! CHECK-LABEL: func.func @_QPtest_alloc_comp(
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_alloc_compEt1"} : (!fir.ref<!fir.type<_QFtest_alloc_compTt
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_alloc_compEt2"} : (!fir.ref<!fir.type<_QFtest_alloc_compTt
+! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_3]]#0 : !fir.ref<!fir.type<_QFtest_alloc_compTt
+! CHECK: return
+! CHECK: }
-! Reinstate this test when polymorphic types are more fully supported.
-!
-!module component_with_user_def_assign
-! type t0
-! integer :: i
-! integer :: j
-! contains
-! procedure :: user_def
-! generic :: assignment(=) => user_def
-! end type
-! interface
-! subroutine user_def(other, self)
-! import t0
-! class(t0), intent(out) :: other
-! class(t0), intent(in) :: self
-! end subroutine
-! end interface
+module component_with_user_def_assign
+ type t0
+ integer :: i
+ integer :: j
+ contains
+ procedure :: user_def
+ generic :: assignment(=) => user_def
+ end type
+ interface
+ subroutine user_def(other, self)
+ import t0
+ class(t0), intent(out) :: other
+ class(t0), intent(in) :: self
+ end subroutine
+ end interface
-! ! Assignments of type(t) must call the user defined assignment for component a.
-! ! Currently this is delegated to the runtime.
-! type t
-! type(t0) :: a
-! integer :: i
-! end type
+ ! Assignments of type(t) must call the user defined assignment for component a.
+ ! Currently this is delegated to the runtime.
+ type t
+ type(t0) :: a
+ integer :: i
+ end type
-!contains
-! COM: CHECK-LABEL: func @_QMcomponent_with_user_def_assignPtest(
-! COM: CHECK-SAME: %[[t1:.*]]: !fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt{a:!fir.type<_QMcomponent_with_user_def_assignTt0{i:i32,j:i32}>,i:i32}>>{{.*}}, %[[t2:.*]]: !fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt{a:!fir.type<_QMcomponent_with_user_def_assignTt0{i:i32,j:i32}>,i:i32}>>{{.*}}) {
-! subroutine test(t1, t2)
-! type(t) :: t1, t2
-! COM: CHECK: %[[tmpBox:.*]] = fir.alloca !fir.box<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>
-! COM: CHECK: %[[t1Box:.*]] = fir.embox %[[t1]] : (!fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>) -> !fir.box<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>
-! COM: CHECK: %[[t2Box:.*]] = fir.embox %[[t2]] : (!fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>) -> !fir.box<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>
-! COM: CHECK: fir.store %[[t1Box]] to %[[tmpBox]] : !fir.ref<!fir.box<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>>
-! COM: CHECK: %[[lhs:.*]] = fir.convert %[[tmpBox]] : (!fir.ref<!fir.box<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>>) -> !fir.ref<!fir.box<none>>
-! COM: CHECK: %[[rhs:.*]] = fir.convert %[[t2Box]] : (!fir.box<!fir.type<_QMcomponent_with_user_def_assignTt{{.*}}>>) -> !fir.box<none>
-! COM: CHECK: fir.call @_FortranAAssign(%[[lhs]], %[[rhs]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
-! t1 = t2
-! end subroutine
-!end module
+contains
+ subroutine test(t1, t2)
+ type(t) :: t1, t2
+ t1 = t2
+ end subroutine
+! CHECK-LABEL: func.func @_QMcomponent_with_user_def_assignPtest(
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QMcomponent_with_user_def_assignFtestEt1"} : (!fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}} dummy_scope %[[VAL_2]] {uniq_name = "_QMcomponent_with_user_def_assignFtestEt2"} : (!fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt
+! CHECK: hlfir.assign %[[VAL_4]]#0 to %[[VAL_3]]#0 : !fir.ref<!fir.type<_QMcomponent_with_user_def_assignTt
+! CHECK: return
+! CHECK: }
+end module
diff --git a/flang/test/Lower/entry-statement.f90 b/flang/test/Lower/entry-statement.f90
index bf706d2d84000..5f31a0265151f 100644
--- a/flang/test/Lower/entry-statement.f90
+++ b/flang/test/Lower/entry-statement.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false -o - %s | FileCheck %s
+! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
! CHECK-LABEL: func @_QPcompare1(
@@ -134,97 +134,183 @@ function char_array()
entry char_array_entry(c)
end
-! CHECK-LABEL: func @_QPdd1()
subroutine dd1
- ! CHECK: %[[kk:[0-9]*]] = fir.alloca i32 {bindc_name = "kk", uniq_name = "_QFdd1Ekk"}
- ! CHECK: br ^bb1
- ! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: %[[ten:.*]] = arith.constant 10 : i32
- ! CHECK: fir.store %[[ten:.*]] to %[[kk]] : !fir.ref<i32>
- ! CHECK: br ^bb2
- ! CHECK: ^bb2: // pred: ^bb1
- ! CHECK: %[[twenty:.*]] = arith.constant 20 : i32
- ! CHECK: fir.store %[[twenty:.*]] to %[[kk]] : !fir.ref<i32>
- ! CHECK: br ^bb3
- ! CHECK: ^bb3: // pred: ^bb2
- ! CHECK: return
+! CHECK-LABEL: func.func @_QPdd1() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "kk", uniq_name = "_QFdd1Ekk"}
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFdd1Ekk"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_2:.*]] = arith.constant 10 : i32
+! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_1]]#0 : i32, !fir.ref<i32>
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: %[[VAL_3:.*]] = arith.constant 20 : i32
+! CHECK: hlfir.assign %[[VAL_3]] to %[[VAL_1]]#0 : i32, !fir.ref<i32>
+! CHECK: cf.br ^bb3
+! CHECK: ^bb3:
+! CHECK: return
+! CHECK: }
kk = 10
- ! CHECK-LABEL: func @_QPdd2()
- ! CHECK: %[[kk:[0-9]*]] = fir.alloca i32 {bindc_name = "kk", uniq_name = "_QFdd1Ekk"}
- ! CHECK: br ^bb1
- ! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: %[[twenty:.*]] = arith.constant 20 : i32
- ! CHECK: fir.store %[[twenty:.*]] to %[[kk]] : !fir.ref<i32>
- ! CHECK: br ^bb2
- ! CHECK: ^bb2: // pred: ^bb1
- ! CHECK: return
entry dd2
+! CHECK-LABEL: func.func @_QPdd2() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "kk", uniq_name = "_QFdd1Ekk"}
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFdd1Ekk"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_2:.*]] = arith.constant 20 : i32
+! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_1]]#0 : i32, !fir.ref<i32>
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: return
+! CHECK: }
kk = 20
return
- ! CHECK-LABEL: func @_QPdd3
- ! CHECK: %[[dd3:[0-9]*]] = fir.alloca index {bindc_name = "dd3"}
- ! CHECK: %[[kk:[0-9]*]] = fir.alloca i32 {bindc_name = "kk", uniq_name = "_QFdd1Ekk"}
- ! CHECK: %[[zero:.*]] = arith.constant 0 : index
- ! CHECK: fir.store %[[zero:.*]] to %[[dd3]] : !fir.ref<index>
- ! CHECK: br ^bb1
- ! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: %[[thirty:.*]] = arith.constant 30 : i32
- ! CHECK: fir.store %[[thirty:.*]] to %[[kk:[0-9]*]] : !fir.ref<i32>
- ! CHECK: br ^bb2
- ! CHECK: ^bb2: // pred: ^bb1
- ! CHECK: %[[altret:[0-9]*]] = fir.load %[[dd3]] : !fir.ref<index>
- ! CHECK: return %[[altret:[0-9]*]] : index
entry dd3(*)
+! CHECK-LABEL: func.func @_QPdd3() -> index {
+! CHECK: %[[VAL_0:.*]] = fir.alloca index {bindc_name = "dd3"}
+! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "kk", uniq_name = "_QFdd1Ekk"}
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_1]] {uniq_name = "_QFdd1Ekk"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
+! CHECK: fir.store %[[VAL_3]] to %[[VAL_0]] : !fir.ref<index>
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_4:.*]] = arith.constant 30 : i32
+! CHECK: hlfir.assign %[[VAL_4]] to %[[VAL_2]]#0 : i32, !fir.ref<i32>
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_0]] : !fir.ref<index>
+! CHECK: return %[[VAL_5]] : index
+! CHECK: }
kk = 30
end
-! CHECK-LABEL: func @_QPashapec(
subroutine ashapec(asc)
- ! CHECK: %[[asx:[0-9]*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
- ! CHECK: %[[asi:[0-9]*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
- ! CHECK: %[[zeroi:[0-9]*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
- ! CHECK: %[[shapei:[0-9]*]] = fir.shape %c0{{.*}} : (index) -> !fir.shape<1>
- ! CHECK: %[[boxi:[0-9]*]] = fir.embox %[[zeroi]](%[[shapei]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
- ! CHECK: fir.store %[[boxi]] to %[[asi]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
- ! CHECK: %[[zerox:[0-9]*]] = fir.zero_bits !fir.heap<!fir.array<?xcomplex<f32>>>
- ! CHECK: %[[shapex:[0-9]*]] = fir.shape %c0{{.*}} : (index) -> !fir.shape<1>
- ! CHECK: %[[boxx:[0-9].*]] = fir.embox %[[zerox]](%[[shapex]]) : (!fir.heap<!fir.array<?xcomplex<f32>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
- ! CHECK: fir.store %[[boxx]] to %[[asx]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>>
character asc(:)
integer asi(:)
complex asx(:)
asc = '?'
return
-! CHECK-LABEL: func @_QPashapei(
+! CHECK-LABEL: func.func @_QPashapec(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.char<1>>> {fir.bindc_name = "asc"}) {
+! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_4]] dummy_scope %[[VAL_3]] {uniq_name = "_QFashapecEasc"} : (!fir.box<!fir.array<?x!fir.char<1>>>, index, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.char<1>>>, !fir.box<!fir.array<?x!fir.char<1>>>)
+! CHECK: %[[VAL_6:.*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
+! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_9:.*]] = fir.embox %[[VAL_6]](%[[VAL_8]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
+! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+! CHECK: %[[VAL_11:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_12:.*]]:3 = fir.box_dims %[[VAL_10]], %[[VAL_11]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_13:.*]] = fir.box_addr %[[VAL_10]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
+! CHECK: %[[VAL_14:.*]] = fir.shape_shift %[[VAL_12]]#0, %[[VAL_12]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_13]](%[[VAL_14]]) {uniq_name = "_QFashapecEasi"} : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>) -> (!fir.box<!fir.array<?xi32>>, !fir.heap<!fir.array<?xi32>>)
+! CHECK: %[[VAL_16:.*]] = fir.zero_bits !fir.heap<!fir.array<?xcomplex<f32>>>
+! CHECK: %[[VAL_17:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_17]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_16]](%[[VAL_18]]) : (!fir.heap<!fir.array<?xcomplex<f32>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
+! CHECK: fir.store %[[VAL_19]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>>
+! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>>
+! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_20]], %[[VAL_21]] : (!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_23:.*]] = fir.box_addr %[[VAL_20]] : (!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>) -> !fir.heap<!fir.array<?xcomplex<f32>>>
+! CHECK: %[[VAL_24:.*]] = fir.shape_shift %[[VAL_22]]#0, %[[VAL_22]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_25:.*]]:2 = hlfir.declare %[[VAL_23]](%[[VAL_24]]) {uniq_name = "_QFashapecEasx"} : (!fir.heap<!fir.array<?xcomplex<f32>>>, !fir.shapeshift<1>) -> (!fir.box<!fir.array<?xcomplex<f32>>>, !fir.heap<!fir.array<?xcomplex<f32>>>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_26:.*]] = fir.address_of(@_QQclX3F) : !fir.ref<!fir.char<1>>
+! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_26]] typeparams %[[VAL_27]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX3F"} : (!fir.ref<!fir.char<1>>, index) -> (!fir.ref<!fir.char<1>>, !fir.ref<!fir.char<1>>)
+! CHECK: hlfir.assign %[[VAL_28]]#0 to %[[VAL_5]]#0 : !fir.ref<!fir.char<1>>, !fir.box<!fir.array<?x!fir.char<1>>>
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: return
+! CHECK: }
+
entry ashapei(asi)
- ! CHECK: %[[asx:[0-9]*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
- ! CHECK: %[[asc:[0-9]*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
- ! CHECK: %[[zeroc:[0-9]*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.char<1>>>
- ! CHECK: %[[shapec:[0-9]*]] = fir.shape %c0{{.*}} : (index) -> !fir.shape<1>
- ! CHECK: %[[boxc:[0-9]*]] = fir.embox %[[zeroc]](%[[shapec]]) : (!fir.heap<!fir.array<?x!fir.char<1>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
- ! CHECK: fir.store %[[boxc]] to %[[asc]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>>
- ! CHECK: %[[zerox:[0-9]*]] = fir.zero_bits !fir.heap<!fir.array<?xcomplex<f32>>>
- ! CHECK: %[[shapex:[0-9]*]] = fir.shape %c0{{.*}} : (index) -> !fir.shape<1>
- ! CHECK: %[[boxx:[0-9].*]] = fir.embox %[[zerox]](%[[shapex]]) : (!fir.heap<!fir.array<?xcomplex<f32>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
- ! CHECK: fir.store %[[boxx]] to %[[asx]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>>
asi = 3
return
-! CHECK-LABEL: func @_QPashapex(
+! CHECK-LABEL: func.func @_QPashapei(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "asi"}) {
+! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.char<1>>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_4]](%[[VAL_6]]) : (!fir.heap<!fir.array<?x!fir.char<1>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
+! CHECK: fir.store %[[VAL_7]] to %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>>
+! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>>
+! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_9]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_11:.*]] = fir.box_elesize %[[VAL_8]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>) -> index
+! CHECK: %[[VAL_12:.*]] = fir.box_addr %[[VAL_8]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>) -> !fir.heap<!fir.array<?x!fir.char<1>>>
+! CHECK: %[[VAL_13:.*]] = fir.shape_shift %[[VAL_10]]#0, %[[VAL_10]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_12]](%[[VAL_13]]) typeparams %[[VAL_11]] {uniq_name = "_QFashapecEasc"} : (!fir.heap<!fir.array<?x!fir.char<1>>>, !fir.shapeshift<1>, index) -> (!fir.box<!fir.array<?x!fir.char<1>>>, !fir.heap<!fir.array<?x!fir.char<1>>>)
+! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_3]] {uniq_name = "_QFashapecEasi"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
+! CHECK: %[[VAL_16:.*]] = fir.zero_bits !fir.heap<!fir.array<?xcomplex<f32>>>
+! CHECK: %[[VAL_17:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_17]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_16]](%[[VAL_18]]) : (!fir.heap<!fir.array<?xcomplex<f32>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>
+! CHECK: fir.store %[[VAL_19]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>>
+! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>>
+! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_20]], %[[VAL_21]] : (!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_23:.*]] = fir.box_addr %[[VAL_20]] : (!fir.box<!fir.heap<!fir.array<?xcomplex<f32>>>>) -> !fir.heap<!fir.array<?xcomplex<f32>>>
+! CHECK: %[[VAL_24:.*]] = fir.shape_shift %[[VAL_22]]#0, %[[VAL_22]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_25:.*]]:2 = hlfir.declare %[[VAL_23]](%[[VAL_24]]) {uniq_name = "_QFashapecEasx"} : (!fir.heap<!fir.array<?xcomplex<f32>>>, !fir.shapeshift<1>) -> (!fir.box<!fir.array<?xcomplex<f32>>>, !fir.heap<!fir.array<?xcomplex<f32>>>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_26:.*]] = arith.constant 3 : i32
+! CHECK: hlfir.assign %[[VAL_26]] to %[[VAL_15]]#0 : i32, !fir.box<!fir.array<?xi32>>
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: return
+! CHECK: }
entry ashapex(asx)
- ! CHECK: %[[asi:[0-9]*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
- ! CHECK: %[[asc:[0-9]*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
- ! CHECK: %[[zeroc:[0-9]*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.char<1>>>
- ! CHECK: %[[shapec:[0-9]*]] = fir.shape %c0{{.*}} : (index) -> !fir.shape<1>
- ! CHECK: %[[boxc:[0-9]*]] = fir.embox %[[zeroc]](%[[shapec]]) : (!fir.heap<!fir.array<?x!fir.char<1>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
- ! CHECK: fir.store %[[boxc]] to %[[asc]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>>
- ! CHECK: %[[zeroi:[0-9]*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
- ! CHECK: %[[shapei:[0-9]*]] = fir.shape %c0{{.*}} : (index) -> !fir.shape<1>
- ! CHECK: %[[boxi:[0-9].*]] = fir.embox %[[zeroi]](%[[shapei]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
- ! CHECK: fir.store %[[boxi]] to %[[asi]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
asx = (2.0,-2.0)
end
+! CHECK-LABEL: func.func @_QPashapex(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xcomplex<f32>>> {fir.bindc_name = "asx"}) {
+! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
+! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.char<1>>>
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_4]](%[[VAL_6]]) : (!fir.heap<!fir.array<?x!fir.char<1>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>
+! CHECK: fir.store %[[VAL_7]] to %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>>
+! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>>
+! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_9]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_11:.*]] = fir.box_elesize %[[VAL_8]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>) -> index
+! CHECK: %[[VAL_12:.*]] = fir.box_addr %[[VAL_8]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1>>>>) -> !fir.heap<!fir.array<?x!fir.char<1>>>
+! CHECK: %[[VAL_13:.*]] = fir.shape_shift %[[VAL_10]]#0, %[[VAL_10]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_12]](%[[VAL_13]]) typeparams %[[VAL_11]] {uniq_name = "_QFashapecEasc"} : (!fir.heap<!fir.array<?x!fir.char<1>>>, !fir.shapeshift<1>, index) -> (!fir.box<!fir.array<?x!fir.char<1>>>, !fir.heap<!fir.array<?x!fir.char<1>>>)
+! CHECK: %[[VAL_15:.*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
+! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_16]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_18:.*]] = fir.embox %[[VAL_15]](%[[VAL_17]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
+! CHECK: fir.store %[[VAL_18]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+! CHECK: %[[VAL_19:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+! CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_21:.*]]:3 = fir.box_dims %[[VAL_19]], %[[VAL_20]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_22:.*]] = fir.box_addr %[[VAL_19]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
+! CHECK: %[[VAL_23:.*]] = fir.shape_shift %[[VAL_21]]#0, %[[VAL_21]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_24:.*]]:2 = hlfir.declare %[[VAL_22]](%[[VAL_23]]) {uniq_name = "_QFashapecEasi"} : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>) -> (!fir.box<!fir.array<?xi32>>, !fir.heap<!fir.array<?xi32>>)
+! CHECK: %[[VAL_25:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_3]] {uniq_name = "_QFashapecEasx"} : (!fir.box<!fir.array<?xcomplex<f32>>>, !fir.dscope) -> (!fir.box<!fir.array<?xcomplex<f32>>>, !fir.box<!fir.array<?xcomplex<f32>>>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: hlfir.assign %{{.*}} to %[[VAL_25]]#0 : complex<f32>, !fir.box<!fir.array<?xcomplex<f32>>>
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: return
+! CHECK: }
! CHECK-LABEL: func @_QPlevel3a(
subroutine level3a(a, b, m)
@@ -248,190 +334,167 @@ subroutine level3a(a, b, m)
if (n /= 3) goto 1
end
-! CHECK-LABEL: @_QPf1
-! CHECK-SAME: %[[V_0:.*]]: !fir.ref<!fir.char<1,5>>
function f1(n1) result(res1)
- ! CHECK: %[[V_1:[0-9]+]] = fir.alloca i32 {bindc_name = "n2", uniq_name = "_QFf1En2"}
- ! CHECK: %[[V_2:[0-9]+]] = fir.alloca tuple<!fir.boxchar<1>, !fir.boxchar<1>>
- ! CHECK: %[[V_3:[0-9]+]] = fir.coordinate_of %[[V_2]], %c0{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_4:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.store %[[V_4]] to %[[V_3]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_5:[0-9]+]] = fir.coordinate_of %[[V_2]], %c1{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_6:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.store %[[V_6]] to %[[V_5]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: br ^bb1
- ! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: %[[V_7:[0-9]+]] = fir.address_of(@_QQclX6120612061) : !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[V_10:[0-9]+]] = fir.convert %c5{{.*}} : (index) -> i64
- ! CHECK: %[[V_11:[0-9]+]] = arith.muli %c1{{.*}}_i64, %[[V_10]] : i64
- ! CHECK: %[[V_12:[0-9]+]] = fir.convert %[[V_0]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: %[[V_13:[0-9]+]] = fir.convert %[[V_7]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[V_12]], %[[V_13]], %[[V_11]], %false{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[V_17:[0-9]+]] = fir.load %arg2 : !fir.ref<i32>
- ! CHECK: %[[V_18:[0-9]+]] = arith.cmpi eq, %[[V_17]], %c1{{.*}} : i32
- ! CHECK: cond_br %[[V_18]], ^bb2, ^bb3
- ! CHECK: ^bb2: // pred: ^bb1
- ! CHECK: br ^bb6
- ! CHECK: ^bb3: // pred: ^bb1
- ! CHECK: fir.call @_QFf1Ps2(%[[V_2]]) {{.*}}: (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>) -> ()
- ! CHECK: %[[V_19:[0-9]+]] = fir.load %[[V_1]] : !fir.ref<i32>
- ! CHECK: %[[V_20:[0-9]+]] = arith.cmpi eq, %[[V_19]], %c2{{.*}}_i32 : i32
- ! CHECK: cond_br %[[V_20]], ^bb4, ^bb5
- ! CHECK: ^bb4: // pred: ^bb3
- ! CHECK: cf.br ^bb6
- ! CHECK: ^bb5: // pred: ^bb3
- ! CHECK: %[[V_21:[0-9]+]] = fir.address_of(@_QQclX4320432043) : !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[V_24:[0-9]+]] = fir.convert %c5{{.*}} : (index) -> i64
- ! CHECK: %[[V_25:[0-9]+]] = arith.muli %c1{{.*}}, %[[V_24]] : i64
- ! CHECK: %[[V_26:[0-9]+]] = fir.convert %[[V_0]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: %[[V_27:[0-9]+]] = fir.convert %[[V_21]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[V_26]], %[[V_27]], %[[V_25]], %false{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: fir.call @_QFf1Ps3(%[[V_2]]) {{.*}}: (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>) -> ()
- ! CHECK: br ^bb6
- ! CHECK: ^bb6: // 3 preds: ^bb2, ^bb4, ^bb5
- ! CHECK: %[[V_31:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: return %[[V_31]] : !fir.boxchar<1>
- ! CHECK: }
character(5) res1, f2, f3
res1 = 'a a a'
if (n1 == 1) return
+! CHECK-LABEL: func.func @_QPf1(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.char<1,5>>,
+! CHECK-SAME: %[[VAL_1:.*]]: index,
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i32> {fir.bindc_name = "n1"}) -> !fir.boxchar<1> {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %[[VAL_3]] {uniq_name = "_QFf1En1"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_5:.*]] = fir.alloca i32 {bindc_name = "n2", uniq_name = "_QFf1En2"}
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]] {uniq_name = "_QFf1En2"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_7:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_7]] {uniq_name = "_QFf1Eres1"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_9]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFf1Ef2"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_11:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_11]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFf1Ef3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_13:.*]] = fir.alloca tuple<!fir.boxchar<1>, !fir.boxchar<1>>
+! CHECK: %[[VAL_14:.*]] = arith.constant 0 : i32
+! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_14]] : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_10]]#1, %[[VAL_9]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: fir.store %[[VAL_16]] to %[[VAL_15]] : !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_17:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_17]] : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_19:.*]] = fir.emboxchar %[[VAL_12]]#1, %[[VAL_11]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: fir.store %[[VAL_19]] to %[[VAL_18]] : !fir.ref<!fir.boxchar<1>>
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: hlfir.assign %{{.*}}#0 to %[[VAL_8]]#0 : !fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>
+! CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<i32>
+! CHECK: %[[VAL_24:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_25:.*]] = arith.cmpi eq, %[[VAL_23]], %[[VAL_24]] : i32
+! CHECK: cf.cond_br %[[VAL_25]], ^bb2, ^bb3
+! CHECK: ^bb2:
+! CHECK: cf.br ^bb6
+! CHECK: ^bb3:
+! CHECK: fir.call @_QFf1Ps2(
+! CHECK: cf.cond_br %{{.*}}, ^bb4, ^bb5
+! CHECK: ^bb4:
+! CHECK: cf.br ^bb6
+! CHECK: ^bb5:
+! CHECK: fir.call @_QFf1Ps3(
+! CHECK: cf.br ^bb6
+! CHECK: ^bb6:
+! CHECK: %[[VAL_32:.*]] = fir.emboxchar %[[VAL_8]]#1, %[[VAL_7]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: return %[[VAL_32]] : !fir.boxchar<1>
+! CHECK: }
-! CHECK-LABEL: @_QPf2
-! CHECK-SAME: %[[V_0:.*]]: !fir.ref<!fir.char<1,5>>
entry f2(n2)
- ! CHECK: %[[V_1:[0-9]+]] = fir.alloca i32 {bindc_name = "n1", uniq_name = "_QFf1En1"}
- ! CHECK: %[[V_2:[0-9]+]] = fir.alloca tuple<!fir.boxchar<1>, !fir.boxchar<1>>
- ! CHECK: %[[V_3:[0-9]+]] = fir.coordinate_of %[[V_2]], %c0{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_4:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.store %[[V_4]] to %[[V_3]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_5:[0-9]+]] = fir.coordinate_of %[[V_2]], %c1{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_6:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.store %[[V_6]] to %[[V_5]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: br ^bb1
- ! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: fir.call @_QFf1Ps2(%[[V_2]]) {{.*}}: (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>) -> ()
- ! CHECK: %[[V_7:[0-9]+]] = fir.load %arg2 : !fir.ref<i32>
- ! CHECK: %[[V_8:[0-9]+]] = arith.cmpi eq, %[[V_7]], %c2{{.*}}_i32 : i32
- ! CHECK: cond_br %[[V_8]], ^bb2, ^bb3
- ! CHECK: ^bb2: // pred: ^bb1
- ! CHECK: br ^bb4
- ! CHECK: ^bb3: // pred: ^bb1
- ! CHECK: %[[V_9:[0-9]+]] = fir.address_of(@_QQclX4320432043) : !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[V_12:[0-9]+]] = fir.convert %c5{{.*}} : (index) -> i64
- ! CHECK: %[[V_13:[0-9]+]] = arith.muli %c1{{.*}}, %[[V_12]] : i64
- ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_0]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: %[[V_15:[0-9]+]] = fir.convert %[[V_9]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[V_14]], %[[V_15]], %[[V_13]], %false{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: fir.call @_QFf1Ps3(%[[V_2]]) {{.*}}: (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>) -> ()
- ! CHECK: br ^bb4
- ! CHECK: ^bb4: // 2 preds: ^bb2, ^bb3
- ! CHECK: %[[V_19:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: return %[[V_19]] : !fir.boxchar<1>
- ! CHECK: }
+! CHECK-LABEL: func.func @_QPf2(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.char<1,5>>,
+! CHECK-SAME: %[[VAL_1:.*]]: index,
+! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i32> {fir.bindc_name = "n2"}) -> !fir.boxchar<1> {
+! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_4:.*]] = fir.alloca i32 {bindc_name = "n1", uniq_name = "_QFf1En1"}
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFf1En1"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %[[VAL_3]] {uniq_name = "_QFf1En2"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_7:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_7]] {uniq_name = "_QFf1Eres1"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_9]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFf1Ef2"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_11:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_11]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFf1Ef3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_13:.*]] = fir.alloca tuple<!fir.boxchar<1>, !fir.boxchar<1>>
+! CHECK: %[[VAL_14:.*]] = arith.constant 0 : i32
+! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_14]] : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_10]]#1, %[[VAL_9]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: fir.store %[[VAL_16]] to %[[VAL_15]] : !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_17:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_17]] : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_19:.*]] = fir.emboxchar %[[VAL_12]]#1, %[[VAL_11]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: fir.store %[[VAL_19]] to %[[VAL_18]] : !fir.ref<!fir.boxchar<1>>
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: fir.call @_QFf1Ps2(%
+! CHECK: cf.cond_br %{{.*}}, ^bb2, ^bb3
+! CHECK: ^bb2:
+! CHECK: cf.br ^bb4
+! CHECK: ^bb3:
+! CHECK: fir.call @_QFf1Ps3(
+! CHECK: cf.br ^bb4
+! CHECK: ^bb4:
+! CHECK: %[[VAL_26:.*]] = fir.emboxchar %[[VAL_10]]#1, %[[VAL_9]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: return %[[VAL_26]] : !fir.boxchar<1>
+! CHECK: }
call s2
if (n2 == 2) return
-! CHECK-LABEL: @_QPf3
-! CHECK-SAME: %[[V_0:.*]]: !fir.ref<!fir.char<1,5>>
entry f3
- ! CHECK: %[[V_1:[0-9]+]] = fir.alloca i32 {bindc_name = "n1", uniq_name = "_QFf1En1"}
- ! CHECK: %[[V_2:[0-9]+]] = fir.alloca i32 {bindc_name = "n2", uniq_name = "_QFf1En2"}
- ! CHECK: %[[V_3:[0-9]+]] = fir.alloca tuple<!fir.boxchar<1>, !fir.boxchar<1>>
- ! CHECK: %[[V_4:[0-9]+]] = fir.coordinate_of %[[V_3]], %c0{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_5:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.store %[[V_5]] to %[[V_4]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_6:[0-9]+]] = fir.coordinate_of %[[V_3]], %c1{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_7:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: fir.store %[[V_7]] to %[[V_6]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: br ^bb1
- ! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: %[[V_8:[0-9]+]] = fir.address_of(@_QQclX4320432043) : !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[V_11:[0-9]+]] = fir.convert %c5{{.*}} : (index) -> i64
- ! CHECK: %[[V_12:[0-9]+]] = arith.muli %c1{{.*}}_i64, %[[V_11]] : i64
- ! CHECK: %[[V_13:[0-9]+]] = fir.convert %[[V_0]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_8]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[V_13]], %[[V_14]], %[[V_12]], %false{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: fir.call @_QFf1Ps3(%[[V_3]]) {{.*}}: (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>) -> ()
- ! CHECK: br ^bb2
- ! CHECK: ^bb2: // pred: ^bb1
- ! CHECK: %[[V_18:[0-9]+]] = fir.emboxchar %[[V_0]], %c5{{.*}} : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
- ! CHECK: return %[[V_18]] : !fir.boxchar<1>
- ! CHECK: }
+! CHECK-LABEL: func.func @_QPf3(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.char<1,5>>,
+! CHECK-SAME: %[[VAL_1:.*]]: index) -> !fir.boxchar<1> {
+! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "n1", uniq_name = "_QFf1En1"}
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFf1En1"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_4:.*]] = fir.alloca i32 {bindc_name = "n2", uniq_name = "_QFf1En2"}
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFf1En2"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[VAL_6:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_6]] {uniq_name = "_QFf1Eres1"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_8:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_8]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFf1Ef2"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_10:.*]] = arith.constant 5 : index
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_10]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFf1Ef3"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
+! CHECK: %[[VAL_12:.*]] = fir.alloca tuple<!fir.boxchar<1>, !fir.boxchar<1>>
+! CHECK: %[[VAL_13:.*]] = arith.constant 0 : i32
+! CHECK: %[[VAL_14:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_13]] : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_15:.*]] = fir.emboxchar %[[VAL_9]]#1, %[[VAL_8]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: fir.store %[[VAL_15]] to %[[VAL_14]] : !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_16:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_17:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_16]] : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
+! CHECK: %[[VAL_18:.*]] = fir.emboxchar %[[VAL_11]]#1, %[[VAL_10]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: fir.store %[[VAL_18]] to %[[VAL_17]] : !fir.ref<!fir.boxchar<1>>
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: fir.call @_QFf1Ps3(
+! CHECK: cf.br ^bb2
+! CHECK: ^bb2:
+! CHECK: %[[VAL_22:.*]] = fir.emboxchar %[[VAL_11]]#1, %[[VAL_10]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
+! CHECK: return %[[VAL_22]] : !fir.boxchar<1>
+! CHECK: }
f3 = "C C C"
call s3
contains
- ! CHECK-LABEL: @_QFf1Ps2
subroutine s2
- ! CHECK: %[[V_0:[0-9]+]] = fir.coordinate_of %arg0, %c0{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_1:[0-9]+]] = fir.load %[[V_0]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_2:[0-9]+]]:2 = fir.unboxchar %[[V_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[V_3:[0-9]+]] = fir.address_of(@_QQclX6220622062) : !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[V_4:[0-9]+]] = arith.cmpi slt, %[[V_2]]#1, %c5{{.*}} : index
- ! CHECK: %[[V_5:[0-9]+]] = arith.select %[[V_4]], %[[V_2]]#1, %c5{{.*}} : index
- ! CHECK: %[[V_6:[0-9]+]] = fir.convert %[[V_5]] : (index) -> i64
- ! CHECK: %[[V_7:[0-9]+]] = arith.muli %c1{{.*}}_i64, %[[V_6]] : i64
- ! CHECK: %[[V_8:[0-9]+]] = fir.convert %[[V_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: %[[V_9:[0-9]+]] = fir.convert %[[V_3]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[V_8]], %[[V_9]], %[[V_7]], %false{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[V_10:[0-9]+]] = arith.subi %[[V_2]]#1, %c1{{.*}} : index
- ! CHECK: %[[V_11:[0-9]+]] = fir.undefined !fir.char<1>
- ! CHECK: %[[V_12:[0-9]+]] = fir.insert_value %[[V_11]], %c32{{.*}}_i8, [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
- ! CHECK: fir.do_loop %arg1 = %[[V_5]] to %[[V_10]] step %c1{{.*}} {
- ! CHECK: %[[V_13:[0-9]+]] = fir.convert %[[V_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
- ! CHECK: %[[V_14:[0-9]+]] = fir.coordinate_of %[[V_13]], %arg1 : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
- ! CHECK: fir.store %[[V_12]] to %[[V_14]] : !fir.ref<!fir.char<1>>
- ! CHECK: }
- ! CHECK: return
- ! CHECK: }
f2 = 'b b b'
end
- ! CHECK-LABEL: @_QFf1Ps3
subroutine s3
- ! CHECK: %[[V_0:[0-9]+]] = fir.coordinate_of %arg0, %c1{{.*}}_i32 : (!fir.ref<tuple<!fir.boxchar<1>, !fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_1:[0-9]+]] = fir.load %[[V_0]] : !fir.ref<!fir.boxchar<1>>
- ! CHECK: %[[V_2:[0-9]+]]:2 = fir.unboxchar %[[V_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK: %[[V_3:[0-9]+]] = fir.address_of(@_QQclX6320632063) : !fir.ref<!fir.char<1,5>>
- ! CHECK: %[[V_4:[0-9]+]] = arith.cmpi slt, %[[V_2]]#1, %c5{{.*}} : index
- ! CHECK: %[[V_5:[0-9]+]] = arith.select %[[V_4]], %[[V_2]]#1, %c5{{.*}} : index
- ! CHECK: %[[V_6:[0-9]+]] = fir.convert %[[V_5]] : (index) -> i64
- ! CHECK: %[[V_7:[0-9]+]] = arith.muli %c1{{.*}}_i64, %[[V_6]] : i64
- ! CHECK: %[[V_8:[0-9]+]] = fir.convert %[[V_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
- ! CHECK: %[[V_9:[0-9]+]] = fir.convert %[[V_3]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
- ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[V_8]], %[[V_9]], %[[V_7]], %false{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
- ! CHECK: %[[V_10:[0-9]+]] = arith.subi %[[V_2]]#1, %c1{{.*}} : index
- ! CHECK: %[[V_11:[0-9]+]] = fir.undefined !fir.char<1>
- ! CHECK: %[[V_12:[0-9]+]] = fir.insert_value %[[V_11]], %c32{{.*}}_i8, [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
- ! CHECK: fir.do_loop %arg1 = %[[V_5]] to %[[V_10]] step %c1{{.*}} {
- ! CHECK: %[[V_13:[0-9]+]] = fir.convert %[[V_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
- ! CHECK: %[[V_14:[0-9]+]] = fir.coordinate_of %[[V_13]], %arg1 : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
- ! CHECK: fir.store %[[V_12]] to %[[V_14]] : !fir.ref<!fir.char<1>>
- ! CHECK: }
- ! CHECK: return
- ! CHECK: }
f3 = 'c c c'
end
end
-! CHECK-LABEL: func @_QPassumed_size() {
subroutine assumed_size()
real :: x(*)
-! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>>
-! CHECK: %[[VAL_1:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
-! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_4:.*]] = fir.embox %[[VAL_1]](%[[VAL_3]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xf32>>>
-! CHECK: fir.store %[[VAL_4]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-! CHECK: br ^bb1
-! CHECK: ^bb1:
-! CHECK: return
-! CHECK: }
+! CHECK-LABEL: func.func @_QPassumed_size() {
+! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>>
+! CHECK: %[[VAL_1:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
+! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_4:.*]] = fir.embox %[[VAL_1]](%[[VAL_3]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xf32>>>
+! CHECK: fir.store %[[VAL_4]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_5]], %[[VAL_6]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
+! CHECK: %[[VAL_9:.*]] = fir.shape_shift %[[VAL_7]]#0, %[[VAL_7]]#1 : (index, index) -> !fir.shapeshift<1>
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]](%[[VAL_9]]) {uniq_name = "_QFassumed_sizeEx"} : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.heap<!fir.array<?xf32>>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: return
+! CHECK: }
-! CHECK-LABEL: func @_QPentry_with_assumed_size(
entry entry_with_assumed_size(x)
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
-! CHECK: br ^bb1
-! CHECK: ^bb1:
-! CHECK: return
-! CHECK: }
end subroutine
+! CHECK-LABEL: func.func @_QPentry_with_assumed_size(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]] = arith.constant -1 : index
+! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_3]]) dummy_scope %[[VAL_1]] {uniq_name = "_QFassumed_sizeEx"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
+! CHECK: cf.br ^bb1
+! CHECK: ^bb1:
+! CHECK: return
+! CHECK: }
diff --git a/flang/test/Lower/forall/scalar-substring.f90 b/flang/test/Lower/forall/scalar-substring.f90
index 0608efe7f0d49..f70221a9b31ee 100644
--- a/flang/test/Lower/forall/scalar-substring.f90
+++ b/flang/test/Lower/forall/scalar-substring.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
subroutine s(ch)
character(10) :: ch
@@ -6,75 +6,55 @@ subroutine s(ch)
ch(i:i) = ch(i+1:i+1)
end forall
end subroutine s
-
! CHECK-LABEL: func.func @_QPs(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "ch"}) {
-! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,10>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
-! CHECK: %[[VAL_6:.*]] = arith.constant 4 : i32
-! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
-! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_9:.*]] = %[[VAL_5]] to %[[VAL_7]] step %[[VAL_8]] unordered {
-! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (index) -> i32
-! CHECK: fir.store %[[VAL_10]] to %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_11]], %[[VAL_12]] : i32
-! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
-! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[VAL_16:.*]] = arith.constant 1 : i32
-! CHECK: %[[VAL_17:.*]] = arith.addi %[[VAL_15]], %[[VAL_16]] : i32
-! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i32) -> i64
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
-! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
-! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_22:.*]] = arith.subi %[[VAL_19]], %[[VAL_21]] : index
-! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
-! CHECK: %[[VAL_24:.*]] = fir.coordinate_of %[[VAL_23]], %[[VAL_22]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_20]], %[[VAL_19]] : index
-! CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_26]], %[[VAL_21]] : index
-! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_29:.*]] = arith.cmpi slt, %[[VAL_27]], %[[VAL_28]] : index
-! CHECK: %[[VAL_30:.*]] = arith.select %[[VAL_29]], %[[VAL_28]], %[[VAL_27]] : index
-! CHECK: %[[VAL_31:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_31]] : (i32) -> i64
-! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
-! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i32) -> i64
-! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_32]] : (i64) -> index
-! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_34]] : (i64) -> index
-! CHECK: %[[VAL_37:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_38:.*]] = arith.subi %[[VAL_35]], %[[VAL_37]] : index
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
-! CHECK: %[[VAL_40:.*]] = fir.coordinate_of %[[VAL_39]], %[[VAL_38]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_40]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
-! CHECK: %[[VAL_42:.*]] = arith.subi %[[VAL_36]], %[[VAL_35]] : index
-! CHECK: %[[VAL_43:.*]] = arith.addi %[[VAL_42]], %[[VAL_37]] : index
-! CHECK: %[[VAL_44:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_45:.*]] = arith.cmpi slt, %[[VAL_43]], %[[VAL_44]] : index
-! CHECK: %[[VAL_46:.*]] = arith.select %[[VAL_45]], %[[VAL_44]], %[[VAL_43]] : index
-! CHECK: %[[VAL_47:.*]] = arith.cmpi slt, %[[VAL_46]], %[[VAL_30]] : index
-! CHECK: %[[VAL_48:.*]] = arith.select %[[VAL_47]], %[[VAL_46]], %[[VAL_30]] : index
-! CHECK: %[[VAL_49:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_50:.*]] = fir.convert %[[VAL_48]] : (index) -> i64
-! CHECK: %[[VAL_51:.*]] = arith.muli %[[VAL_49]], %[[VAL_50]] : i64
-! CHECK: %[[VAL_52:.*]] = arith.constant false
-! CHECK: %[[VAL_53:.*]] = fir.convert %[[VAL_41]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
-! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_53]], %[[VAL_54]], %[[VAL_51]], %[[VAL_52]]) fastmath<contract> : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
-! CHECK: %[[VAL_55:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_56:.*]] = arith.subi %[[VAL_46]], %[[VAL_55]] : index
-! CHECK: %[[VAL_57:.*]] = arith.constant 32 : i8
-! CHECK: %[[VAL_58:.*]] = fir.undefined !fir.char<1>
-! CHECK: %[[VAL_59:.*]] = fir.insert_value %[[VAL_58]], %[[VAL_57]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
-! CHECK: %[[VAL_60:.*]] = arith.constant 1 : index
-! CHECK: fir.do_loop %[[VAL_61:.*]] = %[[VAL_48]] to %[[VAL_56]] step %[[VAL_60]] {
-! CHECK: %[[VAL_62:.*]] = fir.convert %[[VAL_41]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
-! CHECK: %[[VAL_63:.*]] = fir.coordinate_of %[[VAL_62]], %[[VAL_61]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
-! CHECK: fir.store %[[VAL_59]] to %[[VAL_63]] : !fir.ref<!fir.char<1>>
+! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_3]] typeparams %[[VAL_4]] dummy_scope %[[VAL_1]] {uniq_name = "_QFsEch"} : (!fir.ref<!fir.char<1,10>>, index, !fir.dscope) -> (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>)
+! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_7:.*]] = arith.constant 4 : i32
+! CHECK: hlfir.forall lb {
+! CHECK: hlfir.yield %[[VAL_6]] : i32
+! CHECK: } ub {
+! CHECK: hlfir.yield %[[VAL_7]] : i32
+! CHECK: } (%[[VAL_8:.*]]: i32) {
+! CHECK: %[[VAL_9:.*]] = hlfir.forall_index "i" %[[VAL_8]] : (i32) -> !fir.ref<i32>
+! CHECK: hlfir.region_assign {
+! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32>
+! CHECK: %[[VAL_11:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_10]], %[[VAL_11]] overflow<nsw> : i32
+! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i32) -> i64
+! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32>
+! CHECK: %[[VAL_15:.*]] = arith.constant 1 : i32
+! CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_14]], %[[VAL_15]] overflow<nsw> : i32
+! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i32) -> i64
+! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
+! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (i64) -> index
+! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_19]], %[[VAL_18]] : index
+! CHECK: %[[VAL_22:.*]] = arith.addi %[[VAL_21]], %[[VAL_20]] : index
+! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_24:.*]] = arith.cmpi sgt, %[[VAL_22]], %[[VAL_23]] : index
+! CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_24]], %[[VAL_22]], %[[VAL_23]] : index
+! CHECK: %[[VAL_26:.*]] = hlfir.designate %[[VAL_5]]#0 substr %[[VAL_18]], %[[VAL_19]] typeparams %[[VAL_25]] : (!fir.ref<!fir.char<1,10>>, index, index, index) -> !fir.boxchar<1>
+! CHECK: hlfir.yield %[[VAL_26]] : !fir.boxchar<1>
+! CHECK: } to {
+! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32>
+! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (i32) -> i64
+! CHECK: %[[VAL_29:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32>
+! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_29]] : (i32) -> i64
+! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_28]] : (i64) -> index
+! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_30]] : (i64) -> index
+! CHECK: %[[VAL_33:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_32]], %[[VAL_31]] : index
+! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_34]], %[[VAL_33]] : index
+! CHECK: %[[VAL_36:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_37:.*]] = arith.cmpi sgt, %[[VAL_35]], %[[VAL_36]] : index
+! CHECK: %[[VAL_38:.*]] = arith.select %[[VAL_37]], %[[VAL_35]], %[[VAL_36]] : index
+! CHECK: %[[VAL_39:.*]] = hlfir.designate %[[VAL_5]]#0 substr %[[VAL_31]], %[[VAL_32]] typeparams %[[VAL_38]] : (!fir.ref<!fir.char<1,10>>, index, index, index) -> !fir.boxchar<1>
+! CHECK: hlfir.yield %[[VAL_39]] : !fir.boxchar<1>
! CHECK: }
! CHECK: }
! CHECK: return
More information about the flang-commits
mailing list