3 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
5 ! CHECK-LABEL: func @_QPtest_forall_with_slice(
6 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}) {
7 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
8 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
9 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
10 ! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
11 ! 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"}
12 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : i32
13 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index
14 ! CHECK: %[[VAL_9:.*]] = arith.constant 5 : i32
15 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
16 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
17 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
18 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i32) -> index
19 ! CHECK: %[[VAL_14:.*]] = arith.constant 10 : i32
20 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i32) -> index
21 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
22 ! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
23 ! 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>}>>
24 ! 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>}>>) {
25 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (index) -> i32
26 ! CHECK: fir.store %[[VAL_22]] to %[[VAL_3]] : !fir.ref<i32>
27 ! 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>}>>) {
28 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_24]] : (index) -> i32
29 ! CHECK: fir.store %[[VAL_26]] to %[[VAL_2]] : !fir.ref<i32>
30 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
31 ! CHECK: %[[VAL_28:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
32 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (i32) -> i64
33 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_29]] : (i64) -> index
34 ! CHECK: %[[VAL_31:.*]] = arith.subi %[[VAL_30]], %[[VAL_27]] : index
35 ! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
36 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_32]] : (i32) -> i64
37 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i64) -> index
38 ! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_34]], %[[VAL_27]] : index
39 ! CHECK: %[[VAL_36:.*]] = fir.field_index arr, !fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>
40 ! CHECK: %[[VAL_37:.*]] = arith.constant 1 : index
41 ! CHECK: %[[VAL_38:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
42 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_38]] : (i32) -> i64
43 ! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_39]] : (i64) -> index
44 ! CHECK: %[[VAL_41:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
45 ! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_41]] : (i32) -> i64
46 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_42]] : (i64) -> index
47 ! CHECK: %[[VAL_44:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
48 ! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_44]] : (i32) -> i64
49 ! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_45]] : (i64) -> index
50 ! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
51 ! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_46]], %[[VAL_40]] : index
52 ! CHECK: %[[VAL_49:.*]] = arith.addi %[[VAL_48]], %[[VAL_43]] : index
53 ! CHECK: %[[VAL_50:.*]] = arith.divsi %[[VAL_49]], %[[VAL_43]] : index
54 ! CHECK: %[[VAL_51:.*]] = arith.cmpi sgt, %[[VAL_50]], %[[VAL_47]] : index
55 ! CHECK: %[[VAL_52:.*]] = arith.select %[[VAL_51]], %[[VAL_50]], %[[VAL_47]] : index
56 ! CHECK: %[[VAL_59:.*]] = fir.call @_QPf(%[[VAL_3]]) {{.*}}: (!fir.ref<i32>) -> i32
57 ! CHECK: %[[VAL_53:.*]] = arith.constant 1 : index
58 ! CHECK: %[[VAL_54:.*]] = arith.constant 0 : index
59 ! CHECK: %[[VAL_55:.*]] = arith.subi %[[VAL_52]], %[[VAL_53]] : index
60 ! CHECK: %[[VAL_56:.*]] = fir.do_loop %[[VAL_57:.*]] = %[[VAL_54]] to %[[VAL_55]] step %[[VAL_53]] unordered iter_args(%[[VAL_58:.*]] = %[[VAL_25]]) -> (!fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>) {
61 ! CHECK: %[[VAL_60:.*]] = arith.subi %[[VAL_40]], %[[VAL_37]] : index
62 ! CHECK: %[[VAL_61:.*]] = arith.muli %[[VAL_57]], %[[VAL_43]] : index
63 ! CHECK: %[[VAL_62:.*]] = arith.addi %[[VAL_60]], %[[VAL_61]] : index
64 ! CHECK: %[[VAL_63:.*]] = fir.array_update %[[VAL_58]], %[[VAL_59]], %[[VAL_31]], %[[VAL_35]], %[[VAL_36]], %[[VAL_62]] : (!fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>, i32, index, index, !fir.field, index) -> !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>
65 ! CHECK: fir.result %[[VAL_63]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>
67 ! CHECK: fir.result %[[VAL_64:.*]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>
69 ! CHECK: fir.result %[[VAL_65:.*]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>
71 ! CHECK: fir.array_merge_store %[[VAL_18]], %[[VAL_66:.*]] to %[[VAL_6]] : !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>, !fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>, !fir.ref<!fir.array<10x10x!fir.type<_QFtest_forall_with_sliceTt{arr:!fir.array<11xi32>}>>>
75 subroutine test_forall_with_slice(i1
,i2
)
77 pure
integer function f(i
)
88 forall (i
=1:5, j
=1:10)
89 a(i
,j
)%arr(i
:i1
:i2
) = f(i
)
91 end subroutine test_forall_with_slice