[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 19) (PR #182554)

via flang-commits flang-commits at lists.llvm.org
Fri Feb 20 09:49:49 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Eugene Epshteyn (eugeneepshteyn)

<details>
<summary>Changes</summary>

Tests converted from test/Lower/forall: forall-construct-4.f90, forall-construct.f90, forall-ranked.f90, forall-slice.f90, forall-stmt.f90

---

Patch is 30.70 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182554.diff


5 Files Affected:

- (modified) flang/test/Lower/forall/forall-construct-4.f90 (+5-5) 
- (modified) flang/test/Lower/forall/forall-construct.f90 (+34-80) 
- (modified) flang/test/Lower/forall/forall-ranked.f90 (+22-51) 
- (modified) flang/test/Lower/forall/forall-slice.f90 (+31-64) 
- (modified) flang/test/Lower/forall/forall-stmt.f90 (+28-35) 


``````````diff
diff --git a/flang/test/Lower/forall/forall-construct-4.f90 b/flang/test/Lower/forall/forall-construct-4.f90
index 8134a2f7f2710..ef3a6c91993c8 100644
--- a/flang/test/Lower/forall/forall-construct-4.f90
+++ b/flang/test/Lower/forall/forall-construct-4.f90
@@ -1,6 +1,6 @@
 ! Test forall lowering
 
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
 !*** Test forall targeted by label
 subroutine test4_forall_construct()
@@ -13,10 +13,10 @@ subroutine test4_forall_construct()
 200   return
 end subroutine test4_forall_construct
 
-! CHECK-LABEL: func @_QPtest4_forall_construct
+! CHECK-LABEL: func.func @_QPtest4_forall_construct() {
 ! CHECK:   cf.br ^bb1
 ! CHECK: ^bb1:  // 2 preds: ^bb0, ^bb2
-! CHECK:   %{{.*}} = fir.do_loop
+! CHECK:   hlfir.forall
 ! CHECK:   cf.cond_br %{{.*}}, ^bb2, ^bb3
 ! CHECK: ^bb2:  // pred: ^bb1
 ! CHECK:   cf.br ^bb1
@@ -33,10 +33,10 @@ subroutine test4_forall_construct2()
 200   return
 end subroutine test4_forall_construct2
 
-! CHECK-LABEL: func @_QPtest4_forall_construct2
+! CHECK-LABEL: func.func @_QPtest4_forall_construct2() {
 ! CHECK:   cf.br ^bb1
 ! CHECK: ^bb1:  // 2 preds: ^bb0, ^bb2
-! CHECK:   %{{.*}} = fir.do_loop
+! CHECK:   hlfir.forall
 ! CHECK:   cf.cond_br %{{.*}}, ^bb2, ^bb3
 ! CHECK: ^bb2:  // pred: ^bb1
 ! CHECK:   cf.br ^bb1
diff --git a/flang/test/Lower/forall/forall-construct.f90 b/flang/test/Lower/forall/forall-construct.f90
index 6d4dad580ec96..fa11e1e644005 100644
--- a/flang/test/Lower/forall/forall-construct.f90
+++ b/flang/test/Lower/forall/forall-construct.f90
@@ -1,6 +1,6 @@
 ! Test forall lowering
 
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
 !*** Test a FORALL construct
 subroutine test_forall_construct(a,b)
@@ -11,87 +11,41 @@ subroutine test_forall_construct(a,b)
   end forall
 end subroutine test_forall_construct
 
-! CHECK-LABEL: func @_QPtest_forall_construct(
-! CHECK-SAME:     %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
-! CHECK:         %[[VAL_2:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
-! CHECK:         %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
-! CHECK:         %[[VAL_4:.*]] = arith.constant 1 : i32
-! CHECK:         %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
-! CHECK:         %[[VAL_6:.*]] = arith.constant 0 : index
-! CHECK:         %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_6]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
-! CHECK:         %[[VAL_8:.*]] = fir.convert %[[VAL_7]]#1 : (index) -> i64
-! CHECK:         %[[VAL_9:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (index) -> i64
-! CHECK:         %[[VAL_11:.*]] = arith.addi %[[VAL_8]], %[[VAL_10]] : i64
-! CHECK:         %[[VAL_12:.*]] = arith.constant 1 : i64
-! CHECK:         %[[VAL_13:.*]] = arith.subi %[[VAL_11]], %[[VAL_12]] : i64
-! CHECK:         %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> i32
-! CHECK:         %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i32) -> index
-! CHECK:         %[[VAL_16:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_17:.*]] = arith.constant 1 : i32
-! CHECK:         %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i32) -> index
-! CHECK:         %[[VAL_19:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_20:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_19]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
-! CHECK:         %[[VAL_21:.*]] = fir.convert %[[VAL_20]]#1 : (index) -> i64
-! CHECK:         %[[VAL_22:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (index) -> i64
-! CHECK:         %[[VAL_24:.*]] = arith.addi %[[VAL_21]], %[[VAL_23]] : i64
-! CHECK:         %[[VAL_25:.*]] = arith.constant 1 : i64
-! CHECK:         %[[VAL_26:.*]] = arith.subi %[[VAL_24]], %[[VAL_25]] : i64
-! CHECK:         %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (i64) -> i32
-! CHECK:         %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (i32) -> index
-! CHECK:         %[[VAL_29:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_30:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.array<?x?xf32>
-! CHECK:         %[[VAL_31:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.array<?x?xf32>
-! CHECK:         %[[VAL_32:.*]] = fir.do_loop %[[VAL_33:.*]] = %[[VAL_5]] to %[[VAL_15]] step %[[VAL_16]] unordered iter_args(%[[VAL_34:.*]] = %[[VAL_30]]) -> (!fir.array<?x?xf32>) {
-! CHECK:           %[[VAL_35:.*]] = fir.convert %[[VAL_33]] : (index) -> i32
-! CHECK:           fir.store %[[VAL_35]] to %[[VAL_3]] : !fir.ref<i32>
-! CHECK:           %[[VAL_36:.*]] = fir.do_loop %[[VAL_37:.*]] = %[[VAL_18]] to %[[VAL_28]] step %[[VAL_29]] unordered iter_args(%[[VAL_38:.*]] = %[[VAL_34]]) -> (!fir.array<?x?xf32>) {
-! CHECK:             %[[VAL_39:.*]] = fir.convert %[[VAL_37]] : (index) -> i32
-! CHECK:             fir.store %[[VAL_39]] to %[[VAL_2]] : !fir.ref<i32>
-! CHECK:             %[[VAL_40:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK:             %[[VAL_41:.*]] = fir.convert %[[VAL_40]] : (i32) -> i64
-! CHECK:             %[[VAL_42:.*]] = arith.constant 1 : i64
-! CHECK:             %[[VAL_43:.*]] = arith.subi %[[VAL_41]], %[[VAL_42]] : i64
-! CHECK:             %[[VAL_44:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK:             %[[VAL_45:.*]] = fir.convert %[[VAL_44]] : (i32) -> i64
-! CHECK:             %[[VAL_46:.*]] = arith.constant 1 : i64
-! CHECK:             %[[VAL_47:.*]] = arith.subi %[[VAL_45]], %[[VAL_46]] : i64
-! CHECK:             %[[VAL_48:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_43]], %[[VAL_47]] : (!fir.box<!fir.array<?x?xf32>>, i64, i64) -> !fir.ref<f32>
-! CHECK:             %[[VAL_49:.*]] = fir.load %[[VAL_48]] : !fir.ref<f32>
-! CHECK:             %[[VAL_50:.*]] = arith.constant 0.000000e+00 : f32
-! CHECK:             %[[VAL_51:.*]] = arith.cmpf ogt, %[[VAL_49]], %[[VAL_50]] {{.*}} : f32
-! CHECK:             %[[VAL_52:.*]] = fir.if %[[VAL_51]] -> (!fir.array<?x?xf32>) {
-! CHECK:               %[[VAL_53:.*]] = arith.constant 1 : index
-! CHECK:               %[[VAL_54:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK:               %[[VAL_55:.*]] = fir.convert %[[VAL_54]] : (i32) -> i64
-! CHECK:               %[[VAL_56:.*]] = fir.convert %[[VAL_55]] : (i64) -> index
-! CHECK:               %[[VAL_57:.*]] = arith.subi %[[VAL_56]], %[[VAL_53]] : index
-! CHECK:               %[[VAL_58:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK:               %[[VAL_59:.*]] = fir.convert %[[VAL_58]] : (i32) -> i64
-! CHECK:               %[[VAL_60:.*]] = fir.convert %[[VAL_59]] : (i64) -> index
-! CHECK:               %[[VAL_61:.*]] = arith.subi %[[VAL_60]], %[[VAL_53]] : index
-! CHECK-DAG:           %[[VAL_62:.*]] = arith.constant 3.140000e+00 : f32
-! CHECK-DAG:           %[[VAL_63:.*]] = fir.array_fetch %[[VAL_31]], %[[VAL_57]], %[[VAL_61]] : (!fir.array<?x?xf32>, index, index) -> f32
-! CHECK:               %[[VAL_64:.*]] = arith.divf %[[VAL_63]], %[[VAL_62]] {{.*}}: f32
-! CHECK:               %[[VAL_65:.*]] = arith.constant 1 : index
-! CHECK:               %[[VAL_66:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
-! CHECK:               %[[VAL_67:.*]] = fir.convert %[[VAL_66]] : (i32) -> i64
-! CHECK:               %[[VAL_68:.*]] = fir.convert %[[VAL_67]] : (i64) -> index
-! CHECK:               %[[VAL_69:.*]] = arith.subi %[[VAL_68]], %[[VAL_65]] : index
-! CHECK:               %[[VAL_70:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
-! CHECK:               %[[VAL_71:.*]] = fir.convert %[[VAL_70]] : (i32) -> i64
-! CHECK:               %[[VAL_72:.*]] = fir.convert %[[VAL_71]] : (i64) -> index
-! CHECK:               %[[VAL_73:.*]] = arith.subi %[[VAL_72]], %[[VAL_65]] : index
-! CHECK:               %[[VAL_74:.*]] = fir.array_update %[[VAL_38]], %[[VAL_64]], %[[VAL_69]], %[[VAL_73]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
-! CHECK:               fir.result %[[VAL_74]] : !fir.array<?x?xf32>
-! CHECK:             } else {
-! CHECK:               fir.result %[[VAL_38]] : !fir.array<?x?xf32>
+! CHECK-LABEL: func.func @_QPtest_forall_construct(
+! CHECK-SAME:     %[[ARG0:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}, %[[ARG1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
+! CHECK:         %[[VAL_1:.*]]:2 = hlfir.declare %[[ARG0]]
+! CHECK:         %[[VAL_2:.*]]:2 = hlfir.declare %[[ARG1]]
+! CHECK:         hlfir.forall lb {
+! CHECK:           hlfir.yield %{{.*}} : i32
+! CHECK:         } ub {
+! CHECK:           hlfir.yield %{{.*}} : i32
+! CHECK:         }  (%[[I:.*]]: i32) {
+! CHECK:           %[[IDX_I:.*]] = hlfir.forall_index "i" %[[I]]
+! CHECK:           hlfir.forall lb {
+! CHECK:             hlfir.yield %{{.*}} : i32
+! CHECK:           } ub {
+! CHECK:             hlfir.yield %{{.*}} : i32
+! CHECK:           }  (%[[J:.*]]: i32) {
+! CHECK:             %[[IDX_J:.*]] = hlfir.forall_index "j" %[[J]]
+! CHECK:             hlfir.forall_mask {
+! CHECK:               %[[VAL_J:.*]] = fir.load %[[IDX_J]]
+! CHECK:               %[[VAL_I:.*]] = fir.load %[[IDX_I]]
+! CHECK:               %[[B_JI_REF:.*]] = hlfir.designate %[[VAL_2]]#0 (%{{.*}}, %{{.*}})
+! CHECK:               %[[B_JI:.*]] = fir.load %[[B_JI_REF]]
+! CHECK:               %[[COND:.*]] = arith.cmpf ogt, %[[B_JI]], %{{.*}}
+! CHECK:               hlfir.yield %[[COND]] : i1
+! CHECK:             } do {
+! CHECK:               hlfir.region_assign {
+! CHECK:                 %[[B_JI_REF2:.*]] = hlfir.designate %[[VAL_2]]#0 (%{{.*}}, %{{.*}})
+! CHECK:                 %[[B_JI2:.*]] = fir.load %[[B_JI_REF2]]
+! CHECK:                 %[[RES:.*]] = arith.divf %[[B_JI2]], %{{.*}}
+! CHECK:                 hlfir.yield %[[RES]] : f32
+! CHECK:               } to {
+! CHECK:                 %[[A_IJ_REF:.*]] = hlfir.designate %[[VAL_1]]#0 (%{{.*}}, %{{.*}})
+! CHECK:                 hlfir.yield %[[A_IJ_REF]] : !fir.ref<f32>
+! CHECK:               }
 ! CHECK:             }
-! CHECK:             fir.result %[[VAL_75:.*]] : !fir.array<?x?xf32>
 ! CHECK:           }
-! CHECK:           fir.result %[[VAL_76:.*]] : !fir.array<?x?xf32>
 ! CHECK:         }
-! CHECK:         fir.array_merge_store %[[VAL_30]], %[[VAL_77:.*]] to %[[VAL_0]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.box<!fir.array<?x?xf32>>
 ! CHECK:         return
 ! CHECK:       }
diff --git a/flang/test/Lower/forall/forall-ranked.f90 b/flang/test/Lower/forall/forall-ranked.f90
index f508c67468212..b300dc638f72d 100644
--- a/flang/test/Lower/forall/forall-ranked.f90
+++ b/flang/test/Lower/forall/forall-ranked.f90
@@ -1,59 +1,30 @@
 ! Test forall lowering
 
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
-! CHECK-LABEL: func @_QPtest_forall_with_ranked_dimension() {
-! CHECK:         %[[VAL_0:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
-! CHECK:         %[[VAL_1:.*]] = arith.constant 10 : index
-! CHECK:         %[[VAL_2:.*]] = arith.constant 10 : index
-! CHECK:         %[[VAL_3:.*]] = fir.alloca !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>> {bindc_name = "a", uniq_name = "_QFtest_forall_with_ranked_dimensionEa"}
-! CHECK:         %[[VAL_4:.*]] = arith.constant 1 : i32
-! CHECK:         %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
-! CHECK:         %[[VAL_6:.*]] = arith.constant 5 : i32
-! CHECK:         %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
-! CHECK:         %[[VAL_8:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_9:.*]] = fir.shape %[[VAL_1]], %[[VAL_2]] : (index, index) -> !fir.shape<2>
-! CHECK:         %[[VAL_10:.*]] = fir.array_load %[[VAL_3]](%[[VAL_9]]) : (!fir.ref<!fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>>, !fir.shape<2>) -> !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
-! CHECK:         %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_7]] step %[[VAL_8]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_10]]) -> (!fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>) {
-! CHECK:           %[[VAL_14:.*]] = fir.convert %[[VAL_12]] : (index) -> i32
-! CHECK:           fir.store %[[VAL_14]] to %[[VAL_0]] : !fir.ref<i32>
-! CHECK:           %[[VAL_16:.*]] = arith.constant 1 : index
-! CHECK:           %[[VAL_17:.*]] = arith.constant 1 : index
-! CHECK:           %[[VAL_18:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
-! CHECK:           %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i32) -> i64
-! CHECK:           %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i64) -> index
-! CHECK:           %[[VAL_21:.*]] = arith.subi %[[VAL_20]], %[[VAL_17]] : index
-! CHECK:           %[[VAL_22:.*]] = arith.constant 1 : i64
-! CHECK:           %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
-! CHECK:           %[[VAL_24:.*]] = arith.addi %[[VAL_17]], %[[VAL_2]] : index
-! CHECK:           %[[VAL_25:.*]] = arith.subi %[[VAL_24]], %[[VAL_17]] : index
-! CHECK:           %[[VAL_26:.*]] = arith.constant 0 : index
-! CHECK:           %[[VAL_27:.*]] = arith.subi %[[VAL_25]], %[[VAL_17]] : index
-! CHECK:           %[[VAL_28:.*]] = arith.addi %[[VAL_27]], %[[VAL_23]] : index
-! CHECK:           %[[VAL_29:.*]] = arith.divsi %[[VAL_28]], %[[VAL_23]] : index
-! CHECK:           %[[VAL_30:.*]] = arith.cmpi sgt, %[[VAL_29]], %[[VAL_26]] : index
-! CHECK:           %[[VAL_31:.*]] = arith.select %[[VAL_30]], %[[VAL_29]], %[[VAL_26]] : index
-! CHECK:           %[[VAL_32:.*]] = fir.field_index arr, !fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>
-! CHECK-DAG:       %[[VAL_33:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
-! CHECK-DAG:       %[[VAL_34:.*]] = arith.constant 4 : i32
-! CHECK:           %[[VAL_35:.*]] = arith.addi %[[VAL_33]], %[[VAL_34]] : i32
-! CHECK:           %[[VAL_36:.*]] = fir.convert %[[VAL_35]] : (i32) -> i64
-! CHECK:           %[[VAL_37:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
-! CHECK:           %[[VAL_38:.*]] = arith.subi %[[VAL_37]], %[[VAL_16]] : index
-! CHECK:           %[[VAL_45:.*]] = fir.call @_QPf(%[[VAL_0]]) {{.*}}: (!fir.ref<i32>) -> i32
-! CHECK:           %[[VAL_39:.*]] = arith.constant 1 : index
-! CHECK:           %[[VAL_40:.*]] = arith.constant 0 : index
-! CHECK:           %[[VAL_41:.*]] = arith.subi %[[VAL_31]], %[[VAL_39]] : index
-! CHECK:           %[[VAL_42:.*]] = fir.do_loop %[[VAL_43:.*]] = %[[VAL_40]] to %[[VAL_41]] step %[[VAL_39]] unordered iter_args(%[[VAL_44:.*]] = %[[VAL_13]]) -> (!fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>) {
-! CHECK:             %[[VAL_46:.*]] = arith.subi %[[VAL_17]], %[[VAL_17]] : index
-! CHECK:             %[[VAL_47:.*]] = arith.muli %[[VAL_43]], %[[VAL_23]] : index
-! CHECK:             %[[VAL_48:.*]] = arith.addi %[[VAL_46]], %[[VAL_47]] : index
-! CHECK:             %[[VAL_49:.*]] = fir.array_update %[[VAL_44]], %[[VAL_45]], %[[VAL_21]], %[[VAL_48]], %[[VAL_32]], %[[VAL_38]] : (!fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>, i32, index, index, !fir.field, index) -> !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
-! CHECK:             fir.result %[[VAL_49]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
+! CHECK-LABEL: func.func @_QPtest_forall_with_ranked_dimension() {
+! CHECK:         %[[VAL_8:.*]] = fir.alloca !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
+! CHECK:         %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]]
+! CHECK:         hlfir.forall lb {
+! CHECK:           hlfir.yield %{{.*}} : i32
+! CHECK:         } ub {
+! CHECK:           hlfir.yield %{{.*}} : i32
+! CHECK:         }  (%[[I:.*]]: i32) {
+! CHECK:           %[[IDX_I:.*]] = hlfir.forall_index "i" %[[I]]
+! CHECK:           hlfir.region_assign {
+! CHECK:             %[[RES:.*]] = fir.call @_QPf(%[[IDX_I]]) {{.*}} : (!fir.ref<i32>) -> i32
+! CHECK:             hlfir.yield %[[RES]] : i32
+! CHECK:           } to {
+! CHECK:             %[[I_VAL:.*]] = fir.load %[[IDX_I]]
+! CHECK:             %[[I_I64:.*]] = fir.convert %[[I_VAL]] : (i32) -> i64
+! CHECK:             %[[A_SLICE:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[I_I64]], %{{.*}}:%{{.*}}:%{{.*}})
+! CHECK:             %[[I_VAL2:.*]] = fir.load %[[IDX_I]]
+! CHECK:             %[[I_OFF:.*]] = arith.addi %[[I_VAL2]], %{{.*}}
+! CHECK:             %[[I_OFF_I64:.*]] = fir.convert %[[I_OFF]] : (i32) -> i64
+! CHECK:             %[[A_SUB_SLICE:.*]] = hlfir.designate %[[A_SLICE]]{"arr"} {{.*}} (%[[I_OFF_I64]])
+! CHECK:             hlfir.yield %[[A_SUB_SLICE]] : !fir.box<!fir.array<10xi32>>
 ! CHECK:           }
-! CHECK:           fir.result %[[VAL_50:.*]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
 ! CHECK:         }
-! CHECK:         fir.array_merge_store %[[VAL_10]], %[[VAL_51:.*]] to %[[VAL_3]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>, !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>, !fir.ref<!fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>>
 ! CHECK:         return
 ! CHECK:       }
 
diff --git a/flang/test/Lower/forall/forall-slice.f90 b/flang/test/Lower/forall/forall-slice.f90
index 05148cea2e941..4a881b4f9e913 100644
--- a/flang/test/Lower/forall/forall-slice.f90
+++ b/flang/test/Lower/forall/forall-slice.f90
@@ -1,74 +1,41 @@
 ! Test forall lowering
 
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
-! CHECK-LABEL: func @_QPtest_forall_with_slice(
+! CHECK-LABEL: func.func @_QPtest_forall_with_slice(
 ! CHECK-SAME:       %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}) {
-! CHECK:         %[[VAL_2:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
-! CHECK:         %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
-! CHECK:         %[[VAL_4:.*]] = arith.constant 10 : index
-! CHECK:         %[[VAL_5:.*]] = arith.constant 10 : index
-! CHECK:         %[[VAL_6:.*]] = fir.alloca !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>> {bindc_name = "a", uniq_name = "_QFtest_forall_with_sliceEa"}
-! CHECK:         %[[VAL_7:.*]] = arith.constant 1 : i32
-! CHECK:         %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index
-! CHECK:         %[[VAL_9:.*]] = arith.constant 5 : i32
-! CHECK:         %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
-! CHECK:         %[[VAL_11:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_12:.*]] = arith.constant 1 : i32
-! CHECK:         %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i32) -> index
-! CHECK:         %[[VAL_14:.*]] = arith.constant 10 : i32
-! CHECK:         %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i32) -> index
-! CHECK:         %[[VAL_16:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_17:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
-! CHECK:         %[[VAL_18:.*]] = fir.array_load %[[VAL_6]](%[[VAL_17]]) : (!fir.ref<!fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>>, !fir.shape<2>) -> !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>
-! CHECK:         %[[VAL_19:.*]] = fir.do_loop %[[VAL_20:.*]] = %[[VAL_8]] to %[[VAL_10]] step %[[VAL_11]] unordered iter_args(%[[VAL_21:.*]] = %[[VAL_18]]) -> (!fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>) {
-! CHECK:           %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (index) -> i32
-! CHECK:           fir.store %[[VAL_22]] to %[[VAL_3]] : !fir.ref<i32>
-! CHECK:           %[[VAL_23:.*]] = fir.do_loop %[[VAL_24:.*]] = %[[VAL_13]] to %[[VAL_15]] step %[[VAL_16]] unordered iter_args(%[[VAL_25:.*]] = %[[VAL_21]]) -> (!fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>) {
-! CHECK:             %[[VAL_26:.*]] = fir.convert %[[VAL_24]] : (index) -> i32
-! CHECK:             fir.store %[[VAL_26]] to %[[VAL_2]] : !fir.ref...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/182554


More information about the flang-commits mailing list