[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 3) (PR #174345)
via flang-commits
flang-commits at lists.llvm.org
Sun Jan 4 12:12:52 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Eugene Epshteyn (eugeneepshteyn)
<details>
<summary>Changes</summary>
Tests converted: always-execute-loop-body.f90, arithmetic-goto.f90, array-constructor-1.f90, array-constructor-index.f90, array-derived.f90
---
Patch is 51.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/174345.diff
5 Files Affected:
- (modified) flang/test/Lower/always-execute-loop-body.f90 (+9-8)
- (modified) flang/test/Lower/arithmetic-goto.f90 (+16-11)
- (modified) flang/test/Lower/array-constructor-1.f90 (+4-4)
- (modified) flang/test/Lower/array-constructor-index.f90 (+64-264)
- (modified) flang/test/Lower/array-derived.f90 (+112-107)
``````````diff
diff --git a/flang/test/Lower/always-execute-loop-body.f90 b/flang/test/Lower/always-execute-loop-body.f90
index 30b70fb8b145e..f3628419abde2 100644
--- a/flang/test/Lower/always-execute-loop-body.f90
+++ b/flang/test/Lower/always-execute-loop-body.f90
@@ -1,5 +1,5 @@
-! RUN: bbc --always-execute-loop-body --emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -mmlir --always-execute-loop-body -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! RUN: bbc --always-execute-loop-body --emit-fir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -mmlir --always-execute-loop-body -emit-fir %s -o - | FileCheck %s
! Given the flag `--always-execute-loop-body` the compiler emits an extra
! code to change to tripcount, test tries to verify the extra emitted FIR.
@@ -8,13 +8,14 @@
subroutine some()
integer :: i
- ! CHECK: [[tripcount:%[0-9]+]] = arith.divsi
- ! CHECK: [[one:%c1_i32[_0-9]*]] = arith.constant 1 : i32
- ! CHECK: [[cmp:%[0-9]+]] = arith.cmpi slt, [[tripcount]], [[one]] : i32
- ! CHECK: [[newtripcount:%[0-9]+]] = arith.select [[cmp]], [[one]], [[tripcount]] : i32
- ! CHECK: fir.store [[newtripcount]] to %{{[0-9]+}} : !fir.ref<i32>
+ ! CHECK: %[[C1:.*]] = arith.constant 1 : i32
+ ! CHECK: %[[TRIP:.*]] = fir.alloca i32
+ ! CHECK: fir.store %[[C1]] to %[[TRIP]] : !fir.ref<i32>
+ ! CHECK: %[[LOADED_TRIP:.*]] = fir.load %[[TRIP]] : !fir.ref<i32>
+ ! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[LOADED_TRIP]], %c0{{.*}} : i32
+ ! CHECK: cf.cond_br %[[CMP]]
do i=4,1,1
stop 2
end do
return
-end
+end
\ No newline at end of file
diff --git a/flang/test/Lower/arithmetic-goto.f90 b/flang/test/Lower/arithmetic-goto.f90
index 7b5288f727487..9fd6e4e6020e7 100644
--- a/flang/test/Lower/arithmetic-goto.f90
+++ b/flang/test/Lower/arithmetic-goto.f90
@@ -1,9 +1,12 @@
-! RUN: bbc -emit-fir -hlfir=false -o - %s | FileCheck %s
+! RUN: bbc -emit-fir -o - %s | FileCheck %s
! CHECK-LABEL: func @_QPkagi
+! CHECK-SAME: %[[ARG0:[^:]+]]: !fir.ref<i32>
function kagi(index)
- ! CHECK: %[[V_0:[0-9]+]] = fir.alloca i32 {bindc_name = "kagi"
- ! CHECK: %[[V_1:[0-9]+]] = fir.load %arg0 : !fir.ref<i32>
+ ! CHECK: %[[ARG0_D:[0-9]+]] = fir.declare %[[ARG0]]
+ ! CHECK: %[[V_0_RAW:[0-9]+]] = fir.alloca i32 {bindc_name = "kagi"
+ ! CHECK: %[[V_0:[0-9]+]] = fir.declare %[[V_0_RAW]]
+ ! CHECK: %[[V_1:[0-9]+]] = fir.load %[[ARG0_D]] : !fir.ref<i32>
! CHECK: %[[V_2:[0-9]+]] = arith.cmpi slt, %[[V_1]], %c0{{.*}} : i32
! CHECK: cf.cond_br %[[V_2]], ^bb2, ^bb1
! CHECK: ^bb1: // pred: ^bb0
@@ -29,17 +32,19 @@ function kagi(index)
end
! CHECK-LABEL: func @_QPkagf
+! CHECK-SAME: %[[ARG0:[^:]+]]: !fir.ref<f32>
function kagf(findex)
- ! CHECK: %[[V_0:[0-9]+]] = fir.alloca i32 {bindc_name = "kagf"
- ! CHECK: %[[V_1:[0-9]+]] = fir.load %arg0 : !fir.ref<f32>
- ! CHECK: %[[V_2:[0-9]+]] = fir.load %arg0 : !fir.ref<f32>
- ! CHECK: %[[V_3:[0-9]+]] = arith.addf %[[V_1]], %[[V_2]] {{.*}} : f32
+ ! CHECK: %[[CST:.*]] = arith.constant 0.000000e+00 : f32
+ ! CHECK: %[[ARG0_D:[0-9]+]] = fir.declare %[[ARG0]]
+ ! CHECK: %[[V_0_RAW:[0-9]+]] = fir.alloca i32 {bindc_name = "kagf"
+ ! CHECK: %[[V_0:[0-9]+]] = fir.declare %[[V_0_RAW]]
+ ! CHECK: %[[V_1:[0-9]+]] = fir.load %[[ARG0_D]] : !fir.ref<f32>
+ ! CHECK: %[[V_3:[0-9]+]] = arith.addf %[[V_1]], %[[V_1]] {{.*}} : f32
! CHECK: %[[V_4:[0-9]+]] = arith.addf %[[V_3]], %[[V_3]] {{.*}} : f32
- ! CHECK: %cst = arith.constant 0.000000e+00 : f32
- ! CHECK: %[[V_5:[0-9]+]] = arith.cmpf olt, %[[V_4]], %cst {{.*}} : f32
+ ! CHECK: %[[V_5:[0-9]+]] = arith.cmpf olt, %[[V_4]], %[[CST]] {{.*}} : f32
! CHECK: cf.cond_br %[[V_5]], ^bb2, ^bb1
! CHECK: ^bb1: // pred: ^bb0
- ! CHECK: %[[V_6:[0-9]+]] = arith.cmpf ogt, %[[V_4]], %cst {{.*}} : f32
+ ! CHECK: %[[V_6:[0-9]+]] = arith.cmpf ogt, %[[V_4]], %[[CST]] {{.*}} : f32
! CHECK: cf.cond_br %[[V_6]], ^bb4, ^bb3
! CHECK: ^bb2: // pred: ^bb0
! CHECK: fir.store %c1{{.*}} to %[[V_0]] : !fir.ref<i32>
@@ -72,4 +77,4 @@ function kagf(findex)
print*, kagf(+0.0)
print*, kagf(+1.0)
print*, kagf(+2.0)
-end
+end
\ No newline at end of file
diff --git a/flang/test/Lower/array-constructor-1.f90 b/flang/test/Lower/array-constructor-1.f90
index a766357f588a6..e061f0be9ccdc 100644
--- a/flang/test/Lower/array-constructor-1.f90
+++ b/flang/test/Lower/array-constructor-1.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -hlfir=false -o - %s | FileCheck %s
+! RUN: bbc -emit-fir -o - %s | FileCheck %s
module units
integer, parameter :: preconnected_unit(3) = [0, 5, 6]
@@ -6,11 +6,12 @@ module units
! CHECK-LABEL: _QMunitsPis_preconnected_unit
logical function is_preconnected_unit(u)
! CHECK: [[units_ssa:%[0-9]+]] = fir.address_of(@_QMunitsECpreconnected_unit) : !fir.ref<!fir.array<3xi32>>
+ ! CHECK: [[units_decl:%[0-9]+]] = fir.declare [[units_ssa]]
integer :: u
integer :: i
is_preconnected_unit = .true.
do i = lbound(preconnected_unit,1), ubound(preconnected_unit,1)
- ! CHECK: fir.coordinate_of [[units_ssa]]
+ ! CHECK: fir.array_coor [[units_decl]]
if (preconnected_unit(i) == u) return
end do
is_preconnected_unit = .false.
@@ -30,7 +31,6 @@ subroutine zero
complex, parameter :: a(0) = [(((k,k=1,10),j=-2,2,-1),i=2,-2,-2)]
complex, parameter :: b(0) = [(7,i=3,-3)]
! CHECK: fir.address_of(@_QQro.0xz4.null.0) : !fir.ref<!fir.array<0xcomplex<f32>>>
- ! CHECK-NOT: _QQro
print*, '>', a, '<'
print*, '>', b, '<'
end
@@ -43,4 +43,4 @@ program prog
! CHECK: fir.global internal @_QFzeroECa constant : !fir.array<0xcomplex<f32>>
! CHECK: %0 = fir.undefined !fir.array<0xcomplex<f32>>
-! CHECK: fir.has_value %0 : !fir.array<0xcomplex<f32>>
+! CHECK: fir.has_value %0 : !fir.array<0xcomplex<f32>>
\ No newline at end of file
diff --git a/flang/test/Lower/array-constructor-index.f90 b/flang/test/Lower/array-constructor-index.f90
index a8d330aea63dc..6b0fbf6ecc729 100644
--- a/flang/test/Lower/array-constructor-index.f90
+++ b/flang/test/Lower/array-constructor-index.f90
@@ -1,5 +1,5 @@
! Check that the implied-do index value is converted to proper type.
-! RUN: bbc -emit-fir -hlfir=false -o - %s | FileCheck %s
+! RUN: bbc -emit-fir -o - %s | FileCheck %s
function test1(k)
integer*1 :: k
@@ -7,73 +7,23 @@ function test1(k)
test1 = ([(i*k, integer(8)::i=1,4)])
end function test1
! CHECK-LABEL: func.func @_QPtest1(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i8> {fir.bindc_name = "k"}) -> !fir.array<4xi8> {
-! CHECK: %[[VAL_1:.*]] = fir.alloca index {bindc_name = ".buff.pos"}
-! CHECK: %[[VAL_2:.*]] = fir.alloca index {bindc_name = ".buff.size"}
-! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
-! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.array<4xi8> {bindc_name = "test1", uniq_name = "_QFtest1Etest1"}
-! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_4]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xi8>>, !fir.shape<1>) -> !fir.array<4xi8>
-! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
-! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<index>
-! CHECK: %[[VAL_8:.*]] = fir.allocmem !fir.array<4xi64>
-! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
-! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<index>
-! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
-! CHECK: %[[VAL_12:.*]] = arith.constant 4 : 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:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_15]] iter_args(%[[VAL_18:.*]] = %[[VAL_8]]) -> (!fir.heap<!fir.array<4xi64>>) {
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
-! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_0]] : !fir.ref<i8>
-! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i8) -> i64
-! CHECK: %[[VAL_22:.*]] = arith.muli %[[VAL_19]], %[[VAL_21]] : i64
-! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_24:.*]] = fir.zero_bits !fir.ref<!fir.array<4xi64>>
-! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_24]], %[[VAL_23]] : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<i64>) -> index
-! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
-! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_2]] : !fir.ref<index>
-! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_27]], %[[VAL_29]] : index
-! CHECK: %[[VAL_31:.*]] = arith.cmpi sle, %[[VAL_28]], %[[VAL_30]] : index
-! CHECK: %[[VAL_32:.*]] = fir.if %[[VAL_31]] -> (!fir.heap<!fir.array<4xi64>>) {
-! CHECK: %[[VAL_33:.*]] = arith.constant 2 : index
-! CHECK: %[[VAL_34:.*]] = arith.muli %[[VAL_30]], %[[VAL_33]] : index
-! CHECK: fir.store %[[VAL_34]] to %[[VAL_2]] : !fir.ref<index>
-! CHECK: %[[VAL_35:.*]] = arith.muli %[[VAL_34]], %[[VAL_26]] : index
-! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<4xi64>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
-! CHECK: %[[VAL_38:.*]] = fir.call @realloc(%[[VAL_36]], %[[VAL_37]]) fastmath<contract> : (!fir.ref<i8>, i64) -> !fir.ref<i8>
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<i8>) -> !fir.heap<!fir.array<4xi64>>
-! CHECK: fir.result %[[VAL_39]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: }
-! CHECK: %[[VAL_40:.*]] = fir.coordinate_of %[[VAL_41:.*]], %[[VAL_27]] : (!fir.heap<!fir.array<4xi64>>, index) -> !fir.ref<i64>
-! CHECK: fir.store %[[VAL_22]] to %[[VAL_40]] : !fir.ref<i64>
-! CHECK: fir.store %[[VAL_30]] to %[[VAL_1]] : !fir.ref<index>
-! CHECK: fir.result %[[VAL_41]] : !fir.heap<!fir.array<4xi64>>
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<i8> {fir.bindc_name = "k"}) -> !fir.array<4xi8> {
+! CHECK: %[[C1:.*]] = arith.constant 1 : index
+! CHECK: %[[C4:.*]] = arith.constant 4 : index
+! CHECK: %[[ARG0_D:.*]] = fir.declare %[[ARG0]]
+! CHECK: %[[RES:.*]] = fir.alloca !fir.array<4xi8>
+! CHECK: %[[SHAPE:.*]] = fir.shape %[[C4]]
+! CHECK: %[[RES_D:.*]] = fir.declare %[[RES]](%[[SHAPE]])
+! CHECK: fir.do_loop %[[IDX:.*]] = %[[C1]] to %[[C4]] step %[[C1]] unordered {
+! CHECK: %[[IDX_I64:.*]] = fir.convert %[[IDX]] : (index) -> i64
+! CHECK: %[[VAL_K:.*]] = fir.load %[[ARG0_D]] : !fir.ref<i8>
+! CHECK: %[[VAL_K_I64:.*]] = fir.convert %[[VAL_K]] : (i8) -> i64
+! CHECK: %[[PROD:.*]] = arith.muli %[[IDX_I64]], %[[VAL_K_I64]] : i64
+! CHECK: %[[PROD_NO:.*]] = fir.no_reassoc %[[PROD]] : i64
+! CHECK: %[[PROD_I8:.*]] = fir.convert %[[PROD_NO]] : (i64) -> i8
+! CHECK: %[[ADDR:.*]] = fir.array_coor %[[RES_D]](%[[SHAPE]]) %[[IDX]]
+! CHECK: fir.store %[[PROD_I8]] to %[[ADDR]] : !fir.ref<i8>
! CHECK: }
-! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
-! CHECK: %[[VAL_43:.*]] = fir.shape %[[VAL_42]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_44:.*]] = fir.array_load %[[VAL_45:.*]](%[[VAL_43]]) : (!fir.heap<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
-! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_3]], %[[VAL_46]] : index
-! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_47]] to %[[VAL_48]] step %[[VAL_46]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_6]]) -> (!fir.array<4xi8>) {
-! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_44]], %[[VAL_50]] : (!fir.array<4xi64>, index) -> i64
-! CHECK: %[[VAL_53:.*]] = fir.no_reassoc %[[VAL_52]] : i64
-! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i8
-! CHECK: %[[VAL_55:.*]] = fir.array_update %[[VAL_51]], %[[VAL_54]], %[[VAL_50]] : (!fir.array<4xi8>, i8, index) -> !fir.array<4xi8>
-! CHECK: fir.result %[[VAL_55]] : !fir.array<4xi8>
-! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_56:.*]] to %[[VAL_4]] : !fir.array<4xi8>, !fir.array<4xi8>, !fir.ref<!fir.array<4xi8>>
-! CHECK: fir.freemem %[[VAL_45]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: %[[VAL_57:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.array<4xi8>>
-! CHECK: return %[[VAL_57]] : !fir.array<4xi8>
! CHECK: }
function test2(k)
@@ -82,73 +32,23 @@ function test2(k)
test2 = ([(i*k, integer(8)::i=1,4)])
end function test2
! CHECK-LABEL: func.func @_QPtest2(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i16> {fir.bindc_name = "k"}) -> !fir.array<4xi16> {
-! CHECK: %[[VAL_1:.*]] = fir.alloca index {bindc_name = ".buff.pos"}
-! CHECK: %[[VAL_2:.*]] = fir.alloca index {bindc_name = ".buff.size"}
-! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
-! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.array<4xi16> {bindc_name = "test2", uniq_name = "_QFtest2Etest2"}
-! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_4]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xi16>>, !fir.shape<1>) -> !fir.array<4xi16>
-! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
-! CHECK: fir.store %[[VAL_7]] to %[[VAL_1]] : !fir.ref<index>
-! CHECK: %[[VAL_8:.*]] = fir.allocmem !fir.array<4xi64>
-! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
-! CHECK: fir.store %[[VAL_9]] to %[[VAL_2]] : !fir.ref<index>
-! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
-! CHECK: %[[VAL_12:.*]] = arith.constant 4 : 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:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_11]] to %[[VAL_13]] step %[[VAL_15]] iter_args(%[[VAL_18:.*]] = %[[VAL_8]]) -> (!fir.heap<!fir.array<4xi64>>) {
-! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
-! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_0]] : !fir.ref<i16>
-! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i16) -> i64
-! CHECK: %[[VAL_22:.*]] = arith.muli %[[VAL_19]], %[[VAL_21]] : i64
-! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_24:.*]] = fir.zero_bits !fir.ref<!fir.array<4xi64>>
-! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_24]], %[[VAL_23]] : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<i64>) -> index
-! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
-! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_2]] : !fir.ref<index>
-! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_27]], %[[VAL_29]] : index
-! CHECK: %[[VAL_31:.*]] = arith.cmpi sle, %[[VAL_28]], %[[VAL_30]] : index
-! CHECK: %[[VAL_32:.*]] = fir.if %[[VAL_31]] -> (!fir.heap<!fir.array<4xi64>>) {
-! CHECK: %[[VAL_33:.*]] = arith.constant 2 : index
-! CHECK: %[[VAL_34:.*]] = arith.muli %[[VAL_30]], %[[VAL_33]] : index
-! CHECK: fir.store %[[VAL_34]] to %[[VAL_2]] : !fir.ref<index>
-! CHECK: %[[VAL_35:.*]] = arith.muli %[[VAL_34]], %[[VAL_26]] : index
-! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<4xi64>>) -> !fir.ref<i8>
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
-! CHECK: %[[VAL_38:.*]] = fir.call @realloc(%[[VAL_36]], %[[VAL_37]]) fastmath<contract> : (!fir.ref<i8>, i64) -> !fir.ref<i8>
-! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<i8>) -> !fir.heap<!fir.array<4xi64>>
-! CHECK: fir.result %[[VAL_39]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: } else {
-! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: }
-! CHECK: %[[VAL_40:.*]] = fir.coordinate_of %[[VAL_41:.*]], %[[VAL_27]] : (!fir.heap<!fir.array<4xi64>>, index) -> !fir.ref<i64>
-! CHECK: fir.store %[[VAL_22]] to %[[VAL_40]] : !fir.ref<i64>
-! CHECK: fir.store %[[VAL_30]] to %[[VAL_1]] : !fir.ref<index>
-! CHECK: fir.result %[[VAL_41]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: }
-! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_1]] : !fir.ref<index>
-! CHECK: %[[VAL_43:.*]] = fir.shape %[[VAL_42]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_44:.*]] = fir.array_load %[[VAL_45:.*]](%[[VAL_43]]) : (!fir.heap<!fir.array<4xi64>>, !fir.shape<1>) -> !fir.array<4xi64>
-! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_3]], %[[VAL_46]] : index
-! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_47]] to %[[VAL_48]] step %[[VAL_46]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_6]]) -> (!fir.array<4xi16>) {
-! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_44]], %[[VAL_50]] : (!fir.array<4xi64>, index) -> i64
-! CHECK: %[[VAL_53:.*]] = fir.no_reassoc %[[VAL_52]] : i64
-! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i16
-! CHECK: %[[VAL_55:.*]] = fir.array_update %[[VAL_51]], %[[VAL_54]], %[[VAL_50]] : (!fir.array<4xi16>, i16, index) -> !fir.array<4xi16>
-! CHECK: fir.result %[[VAL_55]] : !fir.array<4xi16>
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<i16> {fir.bindc_name = "k"}) -> !fir.array<4xi16> {
+! CHECK: %[[C1:.*]] = arith.constant 1 : index
+! CHECK: %[[C4:.*]] = arith.constant 4 : index
+! CHECK: %[[ARG0_D:.*]] = fir.declare %[[ARG0]]
+! CHECK: %[[RES:.*]] = fir.alloca !fir.array<4xi16>
+! CHECK: %[[SHAPE:.*]] = fir.shape %[[C4]]
+! CHECK: %[[RES_D:.*]] = fir.declare %[[RES]](%[[SHAPE]])
+! CHECK: fir.do_loop %[[IDX:.*]] = %[[C1]] to %[[C4]] step %[[C1]] unordered {
+! CHECK: %[[IDX_I64:.*]] = fir.convert %[[IDX]] : (index) -> i64
+! CHECK: %[[VAL_K:.*]] = fir.load %[[ARG0_D]] : !fir.ref<i16>
+! CHECK: %[[VAL_K_I64:.*]] = fir.convert %[[VAL_K]] : (i16) -> i64
+! CHECK: %[[PROD:.*]] = arith.muli %[[IDX_I64]], %[[VAL_K_I64]] : i64
+! CHECK: %[[PROD_NO:.*]] = fir.no_reassoc %[[PROD]] : i64
+! CHECK: %[[PROD_I16:.*]] = fir.convert %[[PROD_NO]] : (i64) -> i16
+! CHECK: %[[ADDR:.*]] = fir.array_coor %[[RES_D]](%[[SHAPE]]) %[[IDX]]
+! CHECK: fir.store %[[PROD_I16]] to %[[ADDR]] : !fir.ref<i16>
! CHECK: }
-! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_56:.*]] to %[[VAL_4]] : !fir.array<4xi16>, !fir.array<4xi16>, !fir.ref<!fir.array<4xi16>>
-! CHECK: fir.freemem %[[VAL_45]] : !fir.heap<!fir.array<4xi64>>
-! CHECK: %[[VAL_57:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.array<4xi16>>
-! CHECK: return %[[VAL_57]] : !fir.array<4xi16>
! CHECK: }
function test3(k)
@@ -15...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/174345
More information about the flang-commits
mailing list