1 ! Test lowering of extent and lower bound inquires that
2 ! come in lowering as evaluate::DescriptorInquiry.
4 ! RUN: bbc -emit-fir -hlfir -o - %s | FileCheck %s
6 subroutine test_assumed_shape(x
, r
)
9 r
= size(x
, dim
=2, kind
=8)
11 ! CHECK-LABEL: func.func @_QPtest_assumed_shape(
12 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare {{.*}}Ex
13 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
14 ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
15 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#1 : (index) -> i64
16 ! CHECK: hlfir.assign %[[VAL_6]] to %{{.*}}
18 subroutine test_explicit_shape(x
, n
, m
, r
)
21 r
= size(x
, dim
=2, kind
=8)
23 ! CHECK-LABEL: func.func @_QPtest_explicit_shape(
24 ! CHECK: %[[VAL_17:.*]] = fir.shape %{{.*}}, %[[VAL_16:.*]] : (index, index) -> !fir.shape<2>
25 ! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_17]]) {{.*}}Ex
26 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_16]] : (index) -> i64
27 ! CHECK: hlfir.assign %[[VAL_19]] to %{{.*}}
29 subroutine test_pointer(x
, r
)
32 r
= size(x
, dim
=2, kind
=8)
34 ! CHECK-LABEL: func.func @_QPtest_pointer(
35 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare {{.*}}Ex
36 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
37 ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
38 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#1 : (index) -> i64
39 ! CHECK: hlfir.assign %[[VAL_6]] to %{{.*}}
41 subroutine test_lbound_assumed_shape(x
, l1
, l2
, r
)
42 integer(8) :: l1
, l2
, r
44 r
= lbound(x
, dim
=2, kind
=8)
46 ! CHECK: %[[VAL_11:.*]] = fir.shift %[[VAL_8:.*]], %[[VAL_10:.*]] : (index, index) -> !fir.shift<2>
47 ! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_11]]) {{.*}}Ex
48 ! CHECK: %[[VAL_13:.*]] = arith.constant 1 : i64
49 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
50 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
51 ! CHECK: %[[VAL_16:.*]]:3 = fir.box_dims %[[VAL_12]]#1, %[[VAL_15]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
52 ! CHECK: %[[VAL_17:.*]] = arith.cmpi eq, %[[VAL_16]]#1, %[[VAL_14]] : index
53 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
54 ! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_17]], %[[VAL_18]], %[[VAL_10]] : index
55 ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (index) -> i64
56 ! CHECK: hlfir.assign %[[VAL_20]] to %{{.*}}
58 subroutine test_lbound_explicit_shape(x
, n
, m
, l1
, l2
, r
)
59 integer(8) :: n
, m
, l1
, l2
, r
61 r
= lbound(x
, dim
=2, kind
=8)
63 ! CHECK-LABEL: func.func @_QPtest_lbound_explicit_shape(
64 ! CHECK: %[[VAL_31:.*]] = fir.shape_shift %{{.*}}, %{{.*}}, %[[VAL_22:.*]], %[[VAL_30:.*]] : (index, index, index, index) -> !fir.shapeshift<2>
65 ! CHECK: %[[VAL_32:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_31]]) {{.*}}Ex
66 ! CHECK: %[[VAL_33:.*]] = arith.constant 1 : i64
67 ! CHECK: %[[VAL_34:.*]] = arith.constant 0 : index
68 ! CHECK: %[[VAL_35:.*]] = arith.cmpi eq, %[[VAL_30]], %[[VAL_34]] : index
69 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_33]] : (i64) -> index
70 ! CHECK: %[[VAL_37:.*]] = arith.select %[[VAL_35]], %[[VAL_36]], %[[VAL_22]] : index
71 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (index) -> i64
72 ! CHECK: hlfir.assign %[[VAL_38]] to %{{.*}}
74 subroutine test_lbound_pointer(x
, r
)
76 real, pointer :: x(:,:)
77 r
= lbound(x
, dim
=2, kind
=8)
79 ! CHECK-LABEL: func.func @_QPtest_lbound_pointer(
80 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare {{.*}}Ex
81 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
82 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
83 ! CHECK: %[[VAL_6:.*]]:3 = fir.box_dims %[[VAL_4]], %[[VAL_5]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
84 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (index) -> i64
85 ! CHECK: hlfir.assign %[[VAL_7]] to %{{.*}}