3 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
5 ! CHECK-LABEL: func @_QPtest_forall_with_ranked_dimension() {
6 ! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
7 ! CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
8 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
9 ! 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"}
10 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
11 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
12 ! CHECK: %[[VAL_6:.*]] = arith.constant 5 : i32
13 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
14 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
15 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_1]], %[[VAL_2]] : (index, index) -> !fir.shape<2>
16 ! 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>}>>
17 ! 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>}>>) {
18 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_12]] : (index) -> i32
19 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_0]] : !fir.ref<i32>
20 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
21 ! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
22 ! CHECK: %[[VAL_18:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
23 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i32) -> i64
24 ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i64) -> index
25 ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_20]], %[[VAL_17]] : index
26 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i64
27 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
28 ! CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_17]], %[[VAL_2]] : index
29 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_24]], %[[VAL_17]] : index
30 ! CHECK: %[[VAL_26:.*]] = arith.constant 0 : index
31 ! CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_25]], %[[VAL_17]] : index
32 ! CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_27]], %[[VAL_23]] : index
33 ! CHECK: %[[VAL_29:.*]] = arith.divsi %[[VAL_28]], %[[VAL_23]] : index
34 ! CHECK: %[[VAL_30:.*]] = arith.cmpi sgt, %[[VAL_29]], %[[VAL_26]] : index
35 ! CHECK: %[[VAL_31:.*]] = arith.select %[[VAL_30]], %[[VAL_29]], %[[VAL_26]] : index
36 ! CHECK: %[[VAL_32:.*]] = fir.field_index arr, !fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>
37 ! CHECK-DAG: %[[VAL_33:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
38 ! CHECK-DAG: %[[VAL_34:.*]] = arith.constant 4 : i32
39 ! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_33]], %[[VAL_34]] : i32
40 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_35]] : (i32) -> i64
41 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
42 ! CHECK: %[[VAL_38:.*]] = arith.subi %[[VAL_37]], %[[VAL_16]] : index
43 ! CHECK: %[[VAL_45:.*]] = fir.call @_QPf(%[[VAL_0]]) {{.*}}: (!fir.ref<i32>) -> i32
44 ! CHECK: %[[VAL_39:.*]] = arith.constant 1 : index
45 ! CHECK: %[[VAL_40:.*]] = arith.constant 0 : index
46 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_31]], %[[VAL_39]] : index
47 ! 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>}>>) {
48 ! CHECK: %[[VAL_46:.*]] = arith.subi %[[VAL_17]], %[[VAL_17]] : index
49 ! CHECK: %[[VAL_47:.*]] = arith.muli %[[VAL_43]], %[[VAL_23]] : index
50 ! CHECK: %[[VAL_48:.*]] = arith.addi %[[VAL_46]], %[[VAL_47]] : index
51 ! 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>}>>
52 ! CHECK: fir.result %[[VAL_49]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
54 ! CHECK: fir.result %[[VAL_50:.*]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_ranked_dimensionTt{arr:!fir.array<11xi32>}>>
56 ! 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>}>>>
60 subroutine test_forall_with_ranked_dimension
62 pure
integer function f(i
)
63 integer, intent(in
) :: i
73 a(i
,:)%arr(i
+4) = f(i
)
75 end subroutine test_forall_with_ranked_dimension