3 ! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
6 ! Test a FORALL construct with a nested WHERE construct where the mask
7 ! contains temporary array expressions.
9 subroutine test_nested_forall_where_with_temp_in_mask(a
,b
)
11 function temp_foo(i
, j
)
13 real, allocatable
:: temp_foo(:)
19 type(t
) :: a(:,:), b(:,:)
20 forall (i
=1:ubound(a
,1), j
=1:ubound(a
,2))
21 where (b(j
,i
)%data > temp_foo(i
, j
))
22 a(i
,j
)%data = b(j
,i
)%data / 3.14
24 a(i
,j
)%data = -b(j
,i
)%data
29 ! CHECK: func @_QPtest_nested_forall_where_with_temp_in_mask({{.*}}) {
30 ! CHECK: %[[tempResultBox:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = ".result"}
31 ! Where condition pre-evaluation
32 ! CHECK: fir.do_loop {{.*}} {
33 ! CHECK: fir.do_loop {{.*}} {
34 ! Evaluation of mask for iteration (i,j) into ragged array temp
35 ! CHECK: %[[tempResult:.*]] = fir.call @_QPtemp_foo
36 ! CHECK: fir.save_result %[[tempResult]] to %[[tempResultBox]] : !fir.box<!fir.heap<!fir.array<?xf32>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
37 ! CHECK: fir.if {{.*}} {
38 ! CHECK: @_FortranARaggedArrayAllocate
40 ! CHECK: fir.do_loop {{.*}} {
41 ! store into ragged array temp element
43 ! CHECK: %[[box:.*]] = fir.load %[[tempResultBox]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
44 ! CHECK: %[[tempAddr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
45 ! local temps that were generated during the evaluation are cleaned-up after the value were stored
46 ! into the ragged array temp.
47 ! CHECK: fir.freemem %[[tempAddr]] : !fir.heap<!fir.array<?xf32>>
51 ! CHECK: fir.do_loop {{.*}} {
52 ! CHECK: fir.do_loop {{.*}} {
53 ! Array assignment at iteration (i, j)
54 ! CHECK: fir.do_loop {{.*}} {
55 ! CHECK: fir.if {{.*}} {
62 ! Elsewhere assignment
63 ! CHECK: fir.do_loop {{.*}} {
64 ! CHECK: fir.do_loop {{.*}} {
65 ! Array assignment at iteration (i, j)
66 ! CHECK: fir.do_loop {{.*}} {
67 ! CHECK: fir.if {{.*}} {
74 ! Ragged array clean-up
75 ! CHECK: fir.call @_FortranARaggedArrayDeallocate