| 1 |
! Test forall lowering |
| 2 |
|
| 3 |
! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s |
| 4 |
|
| 5 |
subroutine forall_with_allocatable(a1) |
| 6 |
real :: a1(:) |
| 7 |
real, allocatable :: arr(:) |
| 8 |
forall (i=5:15) |
| 9 |
arr(i) = a1(i) |
| 10 |
end forall |
| 11 |
end subroutine forall_with_allocatable |
| 12 |
|
| 13 |
! CHECK-LABEL: func @_QPforall_with_allocatable( |
| 14 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}) { |
| 15 |
! CHECK: %[[VAL_1:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"} |
| 16 |
! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "arr", uniq_name = "_QFforall_with_allocatableEarr"} |
| 17 |
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.heap<!fir.array<?xf32>> {uniq_name = "_QFforall_with_allocatableEarr.addr"} |
| 18 |
! CHECK: %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFforall_with_allocatableEarr.lb0"} |
| 19 |
! CHECK: %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFforall_with_allocatableEarr.ext0"} |
| 20 |
! CHECK: %[[VAL_6:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>> |
| 21 |
! CHECK: fir.store %[[VAL_6]] to %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xf32>>> |
| 22 |
! CHECK: %[[VAL_7:.*]] = arith.constant 5 : i32 |
| 23 |
! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index |
| 24 |
! CHECK: %[[VAL_9:.*]] = arith.constant 15 : i32 |
| 25 |
! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> index |
| 26 |
! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index |
| 27 |
! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_4]] : !fir.ref<index> |
| 28 |
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_5]] : !fir.ref<index> |
| 29 |
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xf32>>> |
| 30 |
! CHECK: %[[VAL_15:.*]] = fir.shape_shift %[[VAL_12]], %[[VAL_13]] : (index, index) -> !fir.shapeshift<1> |
| 31 |
! CHECK: %[[VAL_16:.*]] = fir.array_load %[[VAL_14]](%[[VAL_15]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>) -> !fir.array<?xf32> |
| 32 |
! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32> |
| 33 |
! CHECK: %[[VAL_18:.*]] = fir.do_loop %[[VAL_19:.*]] = %[[VAL_8]] to %[[VAL_10]] step %[[VAL_11]] unordered iter_args(%[[VAL_20:.*]] = %[[VAL_16]]) -> (!fir.array<?xf32>) { |
| 34 |
! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_19]] : (index) -> i32 |
| 35 |
! CHECK: fir.store %[[VAL_21]] to %[[VAL_1]] : !fir.ref<i32> |
| 36 |
! CHECK: %[[VAL_22:.*]] = arith.constant 1 : index |
| 37 |
! CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32> |
| 38 |
! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (i32) -> i64 |
| 39 |
! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (i64) -> index |
| 40 |
! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_25]], %[[VAL_22]] : index |
| 41 |
! CHECK: %[[VAL_27:.*]] = fir.array_fetch %[[VAL_17]], %[[VAL_26]] : (!fir.array<?xf32>, index) -> f32 |
| 42 |
! CHECK: %[[VAL_29:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32> |
| 43 |
! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_29]] : (i32) -> i64 |
| 44 |
! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_30]] : (i64) -> index |
| 45 |
! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_31]], %[[VAL_12]] : index |
| 46 |
! CHECK: %[[VAL_33:.*]] = fir.array_update %[[VAL_20]], %[[VAL_27]], %[[VAL_32]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32> |
| 47 |
! CHECK: fir.result %[[VAL_33]] : !fir.array<?xf32> |
| 48 |
! CHECK: } |
| 49 |
! CHECK: fir.array_merge_store %[[VAL_16]], %[[VAL_34:.*]] to %[[VAL_14]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>> |
| 50 |
! CHECK: return |
| 51 |
! CHECK: } |