1 ! Test that WHERE mask clean-up occurs at the right time when the
2 ! WHERE contains whole allocatable assignments.
3 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
8 ! CHECK-LABEL: func.func @_QMmtestPfoo(
9 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"},
10 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "b"}) {
13 integer, allocatable
:: b(:)
14 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
15 ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
16 ! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_3]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
17 ! WHERE mask temp allocation
18 ! CHECK: %[[VAL_9:.*]] = fir.allocmem !fir.array<?x!fir.logical<4>>, %[[VAL_4]]#1 {uniq_name = ".array.expr"}
19 ! CHECK: %[[VAL_15:.*]] = fir.do_loop {{.*}} {
20 ! ! WHERE mask element computation
22 ! CHECK: fir.array_merge_store %{{.*}}, %[[VAL_15]] to %[[VAL_9]] : !fir.array<?x!fir.logical<4>>, !fir.array<?x!fir.logical<4>>, !fir.heap<!fir.array<?x!fir.logical<4>>>
24 ! First assignment to a whole allocatable (in WHERE)
25 ! CHECK: fir.if {{.*}} {
26 ! CHECK: fir.if {{.*}} {
27 ! assignment into new storage (`b` allocated with bad shape)
29 ! CHECK: fir.do_loop {{.*}} {
30 ! CHECK: fir.array_coor %[[VAL_9]]
31 ! CHECK: fir.if %{{.*}} {
33 ! CHECK: fir.array_update {{.*}}
38 ! assignment into old storage (`b` allocated with the same shape)
39 ! CHECK: fir.do_loop {{.*}} {
40 ! CHECK: fir.array_coor %[[VAL_9]]
41 ! CHECK: fir.if %{{.*}} {
43 ! CHECK: fir.array_update {{.*}}
49 ! assignment into new storage (`b` unallocated)
51 ! CHECK: fir.do_loop %{{.*}} {
52 ! CHECK: fir.array_coor %[[VAL_9]]
53 ! CHECK: fir.if %{{.*}} {
55 ! CHECK: fir.array_update {{.*}}
60 ! CHECK: fir.if {{.*}} {
61 ! CHECK: fir.if {{.*}} {
62 ! deallocation of `b` old allocatable data store
64 ! update of `b` descriptor
66 ! Second assignment (in ELSEWHERE)
67 ! CHECK: fir.do_loop {{.*}} {
68 ! CHECK: fir.array_coor %[[VAL_9]]{{.*}} : (!fir.heap<!fir.array<?x!fir.logical<4>>>, !fir.shape<1>, index) -> !fir.ref<!fir.logical<4>>
69 ! CHECK: fir.if {{.*}} {
72 ! CHECK: fir.array_update
76 ! CHECK: fir.freemem %[[VAL_9]] : !fir.heap<!fir.array<?x!fir.logical<4>>>
87 integer, allocatable
:: a(:), b(:)