1*3348c083SValentin Clement! RUN: bbc -o - %s | FileCheck %s 2*3348c083SValentin Clement 3*3348c083SValentin Clement! CHECK-LABEL: fir.global @_QBblock 4*3348c083SValentin Clement! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 1.000000e+00 : f32 5*3348c083SValentin Clement! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2.400000e+00 : f32 6*3348c083SValentin Clement! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f32 7*3348c083SValentin Clement! CHECK: %[[VAL_4:.*]] = fir.undefined tuple<!fir.array<5x5xf32>> 8*3348c083SValentin Clement! CHECK: %[[VAL_5:.*]] = fir.undefined !fir.array<5x5xf32> 9*3348c083SValentin Clement! CHECK: %[[VAL_6:.*]] = fir.insert_on_range %[[VAL_5]], %[[VAL_1]] from (0, 0) to (1, 0) : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 10*3348c083SValentin Clement! CHECK: %[[VAL_7:.*]] = fir.insert_on_range %[[VAL_6]], %[[VAL_3]] from (2, 0) to (4, 0) : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 11*3348c083SValentin Clement! CHECK: %[[VAL_8:.*]] = fir.insert_on_range %[[VAL_7]], %[[VAL_1]] from (0, 1) to (1, 1) : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 12*3348c083SValentin Clement! CHECK: %[[VAL_9:.*]] = fir.insert_value %[[VAL_8]], %[[VAL_3]], [2 : index, 1 : index] : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 13*3348c083SValentin Clement! CHECK: %[[VAL_10:.*]] = fir.insert_value %[[VAL_9]], %[[VAL_2]], [3 : index, 1 : index] : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 14*3348c083SValentin Clement! CHECK: %[[VAL_11:.*]] = fir.insert_value %[[VAL_10]], %[[VAL_3]], [4 : index, 1 : index] : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 15*3348c083SValentin Clement! CHECK: %[[VAL_12:.*]] = fir.insert_on_range %[[VAL_11]], %[[VAL_1]] from (0, 2) to (1, 2) : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 16*3348c083SValentin Clement! CHECK: %[[VAL_13:.*]] = fir.insert_value %[[VAL_12]], %[[VAL_3]], [2 : index, 2 : index] : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 17*3348c083SValentin Clement! CHECK: %[[VAL_14:.*]] = fir.insert_value %[[VAL_13]], %[[VAL_2]], [3 : index, 2 : index] : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 18*3348c083SValentin Clement! CHECK: %[[VAL_15:.*]] = fir.insert_on_range %[[VAL_14]], %[[VAL_3]] from (4, 2) to (2, 3) : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 19*3348c083SValentin Clement! CHECK: %[[VAL_16:.*]] = fir.insert_value %[[VAL_15]], %[[VAL_2]], [3 : index, 3 : index] : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 20*3348c083SValentin Clement! CHECK: %[[VAL_17:.*]] = fir.insert_on_range %[[VAL_16]], %[[VAL_3]] from (4, 3) to (4, 4) : (!fir.array<5x5xf32>, f32) -> !fir.array<5x5xf32> 21*3348c083SValentin Clement! CHECK: %[[VAL_18:.*]] = fir.insert_value %[[VAL_4]], %[[VAL_17]], [0 : index] : (tuple<!fir.array<5x5xf32>>, !fir.array<5x5xf32>) -> tuple<!fir.array<5x5xf32>> 22*3348c083SValentin Clement! CHECK: fir.has_value %[[VAL_18]] : tuple<!fir.array<5x5xf32>> 23*3348c083SValentin Clement 24*3348c083SValentin Clementsubroutine s(i,j,k,ii,jj,kk,a1,a2,a3,a4,a5,a6,a7) 25*3348c083SValentin Clement integer i, j, k, ii, jj, kk 26*3348c083SValentin Clement 27*3348c083SValentin Clement ! extents are compile-time constant 28*3348c083SValentin Clement real a1(10,20) 29*3348c083SValentin Clement integer a2(30,*) 30*3348c083SValentin Clement real a3(2:40,3:50) 31*3348c083SValentin Clement integer a4(4:60, 5:*) 32*3348c083SValentin Clement 33*3348c083SValentin Clement ! extents computed at run-time 34*3348c083SValentin Clement real a5(i:j) 35*3348c083SValentin Clement integer a6(6:i,j:*) 36*3348c083SValentin Clement real a7(i:70,7:j,k:80) 37*3348c083SValentin Clement 38*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 39*3348c083SValentin Clement ! CHECK-DAG: fir.load %arg3 : 40*3348c083SValentin Clement ! CHECK-DAG: %[[i1:.*]] = arith.subi %{{.*}}, %[[one:c1.*]] : 41*3348c083SValentin Clement ! CHECK: fir.load %arg4 : 42*3348c083SValentin Clement ! CHECK: %[[j1:.*]] = arith.subi %{{.*}}, %[[one]] : 43*3348c083SValentin Clement ! CHECK: fir.coordinate_of %arg6, %[[i1]], %[[j1]] : 44*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 45*3348c083SValentin Clement print *, a1(ii,jj) 46*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 47*3348c083SValentin Clement ! CHECK: fir.coordinate_of %{{[0-9]+}}, %{{[0-9]+}} : {{.*}} -> !fir.ref<i32> 48*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 49*3348c083SValentin Clement print *, a2(ii,jj) 50*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 51*3348c083SValentin Clement ! CHECK-DAG: fir.load %arg3 : 52*3348c083SValentin Clement ! CHECK-DAG: %[[cc2:.*]] = fir.convert %c2{{.*}} : 53*3348c083SValentin Clement ! CHECK: %[[i2:.*]] = arith.subi %{{.*}}, %[[cc2]] : 54*3348c083SValentin Clement ! CHECK-DAG: fir.load %arg4 : 55*3348c083SValentin Clement ! CHECK-DAG: %[[cc3:.*]] = fir.convert %c3{{.*}} : 56*3348c083SValentin Clement ! CHECK: %[[j2:.*]] = arith.subi %{{.*}}, %[[cc3]] : 57*3348c083SValentin Clement ! CHECK: fir.coordinate_of %arg8, %[[i2]], %[[j2]] : 58*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 59*3348c083SValentin Clement print *, a3(ii,jj) 60*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 61*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 62*3348c083SValentin Clement print *, a4(ii,jj) 63*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 64*3348c083SValentin Clement ! CHECK: fir.load %arg5 : 65*3348c083SValentin Clement ! CHECK: %[[x5:.*]] = arith.subi %{{.*}}, %{{.*}} : 66*3348c083SValentin Clement ! CHECK: fir.coordinate_of %arg10, %[[x5]] : 67*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 68*3348c083SValentin Clement print *, a5(kk) 69*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 70*3348c083SValentin Clement ! CHECK: %[[a6:.*]] = fir.convert %arg11 : {{.*}} -> !fir.ref<!fir.array<?xi32>> 71*3348c083SValentin Clement ! CHECK: fir.load %arg3 : 72*3348c083SValentin Clement ! CHECK-DAG: %[[x6:.*]] = arith.subi %{{.*}}, %{{.*}} : 73*3348c083SValentin Clement ! CHECK-DAG: fir.load %arg4 : 74*3348c083SValentin Clement ! CHECK: %[[y6:.*]] = arith.subi %{{.*}}, %{{.*}} : 75*3348c083SValentin Clement ! CHECK: %[[z6:.*]] = arith.muli %{{.}}, %[[y6]] : 76*3348c083SValentin Clement ! CHECK: %[[w6:.*]] = arith.addi %[[z6]], %[[x6]] : 77*3348c083SValentin Clement ! CHECK: fir.coordinate_of %[[a6]], %[[w6]] : 78*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 79*3348c083SValentin Clement print *, a6(ii, jj) 80*3348c083SValentin Clement ! CHECK-LABEL: BeginExternalListOutput 81*3348c083SValentin Clement ! CHECK: %[[a7:.*]] = fir.convert %arg12 : {{.*}} -> !fir.ref<!fir.array<?xf32>> 82*3348c083SValentin Clement ! CHECK: fir.load %arg5 : 83*3348c083SValentin Clement ! CHECK-DAG: %[[x7:.*]] = arith.subi %{{.*}}, %{{.*}} : 84*3348c083SValentin Clement ! CHECK-DAG: fir.load %arg4 : 85*3348c083SValentin Clement ! CHECK: %[[y7:.*]] = arith.subi %{{.*}}, %{{.*}} : 86*3348c083SValentin Clement ! CHECK: %[[z7:.*]] = arith.muli %[[u7:.*]], %[[y7]] : 87*3348c083SValentin Clement ! CHECK: %[[w7:.*]] = arith.addi %[[z7]], %[[x7]] : 88*3348c083SValentin Clement ! CHECK-DAG: %[[v7:.*]] = arith.muli %[[u7]], %{{.*}} : 89*3348c083SValentin Clement ! CHECK-DAG: fir.load %arg3 : 90*3348c083SValentin Clement ! CHECK: %[[r7:.*]] = arith.subi %{{.*}}, %{{.*}} : 91*3348c083SValentin Clement ! CHECK: %[[s7:.*]] = arith.muli %[[v7]], %[[r7]] : 92*3348c083SValentin Clement ! CHECK: %[[t7:.*]] = arith.addi %[[s7]], %[[w7]] : 93*3348c083SValentin Clement ! CHECK: fir.coordinate_of %[[a7]], %[[t7]] : 94*3348c083SValentin Clement ! CHECK-LABEL: EndIoStatement 95*3348c083SValentin Clement print *, a7(kk, jj, ii) 96*3348c083SValentin Clement 97*3348c083SValentin Clementend subroutine s 98*3348c083SValentin Clement 99*3348c083SValentin Clement! CHECK-LABEL range 100*3348c083SValentin Clementsubroutine range() 101*3348c083SValentin Clement ! Compile-time initalized arrays 102*3348c083SValentin Clement integer, dimension(10) :: a0 103*3348c083SValentin Clement real, dimension(2,3) :: a1 104*3348c083SValentin Clement integer, dimension(3,4) :: a2 105*3348c083SValentin Clement 106*3348c083SValentin Clement a0 = (/1, 2, 3, 3, 3, 3, 3, 3, 3, 3/) 107*3348c083SValentin Clement a1 = reshape((/3.5, 3.5, 3.5, 3.5, 3.5, 3.5/), shape(a1)) 108*3348c083SValentin Clement a2 = reshape((/1, 3, 3, 5, 3, 3, 3, 3, 9, 9, 9, 8/), shape(a2)) 109*3348c083SValentin Clementend subroutine range 110*3348c083SValentin Clement 111*3348c083SValentin Clement! a0 array constructor 112*3348c083SValentin Clement! CHECK: fir.global internal @_QQro.10xi4.{{.*}}(dense<[1, 2, 3, 3, 3, 3, 3, 3, 3, 3]> : tensor<10xi32>) constant : !fir.array<10xi32> 113*3348c083SValentin Clement 114*3348c083SValentin Clement! a1 array constructor 115*3348c083SValentin Clement! CHECK: fir.global internal @_QQro.2x3xr4.{{.*}} constant : !fir.array<2x3xf32> { 116*3348c083SValentin Clement ! CHECK-DAG: %cst = arith.constant {{.*}} : f32 117*3348c083SValentin Clement ! CHECK: %{{.*}} = fir.insert_on_range %{{[0-9]+}}, %cst from (0, 0) to (1, 2) : 118*3348c083SValentin Clement 119*3348c083SValentin Clement! a2 array constructor 120*3348c083SValentin Clement! CHECK: fir.global internal @_QQro.3x4xi4.{{.*}} constant : !fir.array<3x4xi32> { 121*3348c083SValentin Clement ! CHECK-DAG: %[[c1_i32:.*]] = arith.constant 1 : i32 122*3348c083SValentin Clement ! CHECK-DAG: %[[c3_i32:.*]] = arith.constant 3 : i32 123*3348c083SValentin Clement ! CHECK-DAG: %[[c5_i32:.*]] = arith.constant 5 : i32 124*3348c083SValentin Clement ! CHECK-DAG: %[[c8_i32:.*]] = arith.constant 8 : i32 125*3348c083SValentin Clement ! CHECK-DAG: %[[c9_i32:.*]] = arith.constant 9 : i32 126*3348c083SValentin Clement ! CHECK: %[[r1:.*]] = fir.insert_value %{{.*}}, %{{.*}}, [0 : index, 0 : index] : 127*3348c083SValentin Clement ! CHECK: %[[r2:.*]] = fir.insert_on_range %[[r1]], %[[c3_i32]] from (1, 0) to (2, 0) : 128*3348c083SValentin Clement ! CHECK: %[[r3:.*]] = fir.insert_value %[[r2]], %{{.*}}, [0 : index, 1 : index] : 129*3348c083SValentin Clement ! CHECK: %[[r4:.*]] = fir.insert_on_range %[[r3]], %[[c3_i32]] from (1, 1) to (1, 2) : 130*3348c083SValentin Clement ! CHECK: %[[r5:.*]] = fir.insert_on_range %[[r4]], %[[c9_i32]] from (2, 2) to (1, 3) : 131*3348c083SValentin Clement ! CHECK: %[[r6:.*]] = fir.insert_value %[[r5]], %{{.*}}, [2 : index, 3 : index] : 132*3348c083SValentin Clement 133*3348c083SValentin Clement! CHECK-LABEL rangeGlobal 134*3348c083SValentin Clementsubroutine rangeGlobal() 135*3348c083SValentin Clement! CHECK: fir.global internal @_QFrangeglobal{{.*}}(dense<[1, 1, 2, 2, 3, 3]> : tensor<6xi32>) : !fir.array<6xi32> 136*3348c083SValentin Clement integer, dimension(6) :: a0 = (/ 1, 1, 2, 2, 3, 3 /) 137*3348c083SValentin Clement 138*3348c083SValentin Clementend subroutine rangeGlobal 139*3348c083SValentin Clement 140*3348c083SValentin Clementblock data 141*3348c083SValentin Clement real(selected_real_kind(6)) :: x(5,5) 142*3348c083SValentin Clement common /block/ x 143*3348c083SValentin Clement data x(1,1), x(2,1), x(3,1) / 1, 1, 0 / 144*3348c083SValentin Clement data x(1,2), x(2,2), x(4,2) / 1, 1, 2.4 / 145*3348c083SValentin Clement data x(1,3), x(2,3), x(4,3) / 1, 1, 2.4 / 146*3348c083SValentin Clement data x(4,4) / 2.4 / 147*3348c083SValentin Clementend 148