94 lines · plain
1! Test passing of vector subscripted entities inside elemental2! procedures.3! RUN: bbc --emit-hlfir -o - %s | FileCheck %s4 5subroutine test()6 interface7 elemental subroutine foo(x, y)8 real, intent(in) :: x9 real, value :: y10 end subroutine11 end interface12 real :: x(10)13 call foo(x([1,3,7]), 0.)14end subroutine15! CHECK-LABEL: func.func @_QPtest() {16! CHECK: %[[VAL_0:.*]] = arith.constant 10 : index17! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.array<10xf32> {bindc_name = "x", uniq_name = "_QFtestEx"}18! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1>19! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_2]]) {uniq_name = "_QFtestEx"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)20! CHECK: %[[VAL_4:.*]] = fir.address_of(@_QQro.3xi8.0) : !fir.ref<!fir.array<3xi64>>21! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index22! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>23! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_6]])24! CHECK: %[[VAL_8:.*]] = arith.constant 3 : index25! CHECK: %[[VAL_9:.*]] = arith.constant 0.000000e+00 : f3226! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index27! CHECK: fir.do_loop %[[VAL_11:.*]] = %[[VAL_10]] to %[[VAL_8]] step %[[VAL_10]] unordered {28! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_11]]) : (!fir.ref<!fir.array<3xi64>>, index) -> !fir.ref<i64>29! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref<i64>30! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xf32>>, i64) -> !fir.ref<f32>31! CHECK: fir.call @_QPfoo(%[[VAL_14]], %[[VAL_9]]) {{.*}}: (!fir.ref<f32>, f32) -> ()32! CHECK: }33! CHECK: return34! CHECK: }35 36subroutine test_value()37 interface38 elemental subroutine foo_value(x, y)39 real, value :: x40 real, value :: y41 end subroutine42 end interface43 real :: x(10)44 call foo_value(x([1,3,7]), 0.)45end subroutine46 47! CHECK-LABEL: func.func @_QPtest_value() {48! CHECK: %[[VAL_0:.*]] = arith.constant 10 : index49! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.array<10xf32> {bindc_name = "x", uniq_name = "_QFtest_valueEx"}50! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1>51! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_2]]) {uniq_name = "_QFtest_valueEx"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)52! CHECK: %[[VAL_4:.*]] = fir.address_of(@_QQro.3xi8.0) : !fir.ref<!fir.array<3xi64>>53! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index54! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>55! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_6]])56! CHECK: %[[VAL_8:.*]] = arith.constant 3 : index57! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>58! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_9]] unordered : (!fir.shape<1>) -> !hlfir.expr<3xf32> {59! CHECK: ^bb0(%[[VAL_11:.*]]: index):60! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_11]]) : (!fir.ref<!fir.array<3xi64>>, index) -> !fir.ref<i64>61! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref<i64>62! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xf32>>, i64) -> !fir.ref<f32>63! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_14]] : !fir.ref<f32>64! CHECK: hlfir.yield_element %[[VAL_15]] : f3265! CHECK: }66! CHECK: %[[VAL_16:.*]] = arith.constant 0.000000e+00 : f3267! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index68! CHECK: fir.do_loop %[[VAL_18:.*]] = %[[VAL_17]] to %[[VAL_8]] step %[[VAL_17]] unordered {69! CHECK: %[[VAL_19:.*]] = hlfir.apply %[[VAL_10]], %[[VAL_18]] : (!hlfir.expr<3xf32>, index) -> f3270! CHECK: fir.call @_QPfoo_value(%[[VAL_19]], %[[VAL_16]]) {{.*}}: (f32, f32) -> ()71! CHECK: }72! CHECK: hlfir.destroy %[[VAL_10]] : !hlfir.expr<3xf32>73! CHECK: return74 75subroutine test_not_a_variable(i)76 interface77 elemental subroutine foo2(j)78 integer(8), intent(in) :: j79 end subroutine80 end interface81 integer(8) :: i(:)82 call foo2((i(i)))83end subroutine84! CHECK-LABEL: func.func @_QPtest_not_a_variable(85! CHECK: hlfir.elemental86! CHECK: %[[VAL_16:.*]] = hlfir.elemental87! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index88! CHECK: fir.do_loop %[[VAL_21:.*]] = {{.*}}89! CHECK: %[[VAL_22:.*]] = hlfir.apply %[[VAL_16]], %[[VAL_21]] : (!hlfir.expr<?xi64>, index) -> i6490! CHECK: %[[VAL_23:.*]]:3 = hlfir.associate %[[VAL_22]] {adapt.valuebyref} : (i64) -> (!fir.ref<i64>, !fir.ref<i64>, i1)91! CHECK: fir.call @_QPfoo2(%[[VAL_23]]#0){{.*}}: (!fir.ref<i64>) -> ()92! CHECK: hlfir.end_associate %[[VAL_23]]#1, %[[VAL_23]]#2 : !fir.ref<i64>, i193! CHECK: }94