| 1 |
! Test lowering of elemental intrinsic operations with array arguments to HLFIR |
| 2 |
! RUN: bbc -emit-hlfir -I nowhere -o - %s 2>&1 | FileCheck %s |
| 3 |
|
| 4 |
subroutine binary(x, y) |
| 5 |
integer :: x(100), y(100) |
| 6 |
x = x+y |
| 7 |
end subroutine |
| 8 |
! CHECK-LABEL: func.func @_QPbinary( |
| 9 |
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_3:[^)]*]]) {{.*}}x |
| 10 |
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_6:[^)]*]]) {{.*}}y |
| 11 |
! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_3]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> { |
| 12 |
! CHECK: ^bb0(%[[VAL_9:.*]]: index): |
| 13 |
! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 14 |
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 15 |
! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_10]] : !fir.ref<i32> |
| 16 |
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_11]] : !fir.ref<i32> |
| 17 |
! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_12]], %[[VAL_13]] : i32 |
| 18 |
! CHECK: hlfir.yield_element %[[VAL_14]] : i32 |
| 19 |
! CHECK: } |
| 20 |
! CHECK: hlfir.assign |
| 21 |
! CHECK: hlfir.destroy %[[VAL_8]] |
| 22 |
|
| 23 |
subroutine binary_with_scalar_and_array(x, y) |
| 24 |
integer :: x(100), y |
| 25 |
x = x+y |
| 26 |
end subroutine |
| 27 |
! CHECK-LABEL: func.func @_QPbinary_with_scalar_and_array( |
| 28 |
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_3:[^)]*]]) {{.*}}x |
| 29 |
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %{{.*}} {{.*}}y |
| 30 |
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<i32> |
| 31 |
! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_3]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> { |
| 32 |
! CHECK: ^bb0(%[[VAL_8:.*]]: index): |
| 33 |
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_8]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 34 |
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32> |
| 35 |
! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_10]], %[[VAL_6]] : i32 |
| 36 |
! CHECK: hlfir.yield_element %[[VAL_11]] : i32 |
| 37 |
! CHECK: } |
| 38 |
! CHECK: hlfir.assign |
| 39 |
! CHECK: hlfir.destroy %[[VAL_7]] |
| 40 |
|
| 41 |
subroutine char_binary(x, y) |
| 42 |
character(*) :: x(100), y(100) |
| 43 |
call test_char(x//y) |
| 44 |
end subroutine |
| 45 |
! CHECK-LABEL: func.func @_QPchar_binary( |
| 46 |
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_5:.*]]) typeparams %[[VAL_2:.*]]#1 {{.*}}x |
| 47 |
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_10:.*]]) typeparams %[[VAL_7:.*]]#1 {{.*}}y |
| 48 |
! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_2]]#1, %[[VAL_7]]#1 : index |
| 49 |
! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_12]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> { |
| 50 |
! CHECK: ^bb0(%[[VAL_14:.*]]: index): |
| 51 |
! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_14]]) typeparams %[[VAL_2]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1> |
| 52 |
! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_14]]) typeparams %[[VAL_7]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1> |
| 53 |
! CHECK: %[[VAL_17:.*]] = hlfir.concat %[[VAL_15]], %[[VAL_16]] len %[[VAL_12]] : (!fir.boxchar<1>, !fir.boxchar<1>, index) -> !hlfir.expr<!fir.char<1,?>> |
| 54 |
! CHECK: hlfir.yield_element %[[VAL_17]] : !hlfir.expr<!fir.char<1,?>> |
| 55 |
! CHECK: } |
| 56 |
! CHECK: fir.call |
| 57 |
! CHECK: hlfir.destroy %[[VAL_13]] |
| 58 |
|
| 59 |
subroutine unary(x, n) |
| 60 |
integer :: n |
| 61 |
logical :: x(n) |
| 62 |
x = .not.x |
| 63 |
end subroutine |
| 64 |
! CHECK-LABEL: func.func @_QPunary( |
| 65 |
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_9:[^)]*]]) {{.*}}x |
| 66 |
! CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_9]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> { |
| 67 |
! CHECK: ^bb0(%[[VAL_12:.*]]: index): |
| 68 |
! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[VAL_12]]) : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.ref<!fir.logical<4>> |
| 69 |
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_13]] : !fir.ref<!fir.logical<4>> |
| 70 |
! CHECK: %[[VAL_15:.*]] = arith.constant true |
| 71 |
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_14]] : (!fir.logical<4>) -> i1 |
| 72 |
! CHECK: %[[VAL_17:.*]] = arith.xori %[[VAL_16]], %[[VAL_15]] : i1 |
| 73 |
! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i1) -> !fir.logical<4> |
| 74 |
! CHECK: hlfir.yield_element %[[VAL_18]] : !fir.logical<4> |
| 75 |
! CHECK: } |
| 76 |
! CHECK: hlfir.assign |
| 77 |
! CHECK: hlfir.destroy %[[VAL_11]] |
| 78 |
|
| 79 |
subroutine char_unary(x) |
| 80 |
character(10) :: x(20) |
| 81 |
call test_char_2((x)) |
| 82 |
end subroutine |
| 83 |
! CHECK-LABEL: func.func @_QPchar_unary( |
| 84 |
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_5:.*]]) typeparams %[[VAL_2:[^ ]*]] {{.*}}x |
| 85 |
! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<20x!fir.char<1,?>> { |
| 86 |
! CHECK: ^bb0(%[[VAL_8:.*]]: index): |
| 87 |
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_8]]) typeparams %[[VAL_2]] : (!fir.ref<!fir.array<20x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>> |
| 88 |
! CHECK: %[[VAL_10:.*]] = hlfir.as_expr %[[VAL_9]] : (!fir.ref<!fir.char<1,10>>) -> !hlfir.expr<!fir.char<1,10>> |
| 89 |
! CHECK: hlfir.yield_element %[[VAL_10]] : !hlfir.expr<!fir.char<1,10>> |
| 90 |
! CHECK: } |
| 91 |
! CHECK: fir.call |
| 92 |
! CHECK: hlfir.destroy %[[VAL_7]] |
| 93 |
|
| 94 |
subroutine chained_elemental(x, y, z) |
| 95 |
integer :: x(100), y(100), z(100) |
| 96 |
x = x+y+z |
| 97 |
end subroutine |
| 98 |
! CHECK-LABEL: func.func @_QPchained_elemental( |
| 99 |
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_4:[^)]*]]) {{.*}}x |
| 100 |
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_7:[^)]*]]) {{.*}}y |
| 101 |
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_10:[^)]*]]) {{.*}}z |
| 102 |
! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> { |
| 103 |
! CHECK: ^bb0(%[[VAL_13:.*]]: index): |
| 104 |
! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 105 |
! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 106 |
! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_14]] : !fir.ref<i32> |
| 107 |
! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_15]] : !fir.ref<i32> |
| 108 |
! CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_16]], %[[VAL_17]] : i32 |
| 109 |
! CHECK: hlfir.yield_element %[[VAL_18]] : i32 |
| 110 |
! CHECK: } |
| 111 |
! CHECK: %[[VAL_19:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> { |
| 112 |
! CHECK: ^bb0(%[[VAL_20:.*]]: index): |
| 113 |
! CHECK: %[[VAL_21:.*]] = hlfir.apply %[[VAL_22:.*]], %[[VAL_20]] : (!hlfir.expr<100xi32>, index) -> i32 |
| 114 |
! CHECK: %[[VAL_23:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_20]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 115 |
! CHECK: %[[VAL_24:.*]] = fir.load %[[VAL_23]] : !fir.ref<i32> |
| 116 |
! CHECK: %[[VAL_25:.*]] = arith.addi %[[VAL_21]], %[[VAL_24]] : i32 |
| 117 |
! CHECK: hlfir.yield_element %[[VAL_25]] : i32 |
| 118 |
! CHECK: } |
| 119 |
! CHECK: hlfir.assign |
| 120 |
! CHECK: hlfir.destroy %[[VAL_19]] |
| 121 |
! CHECK: hlfir.destroy %[[VAL_12]] |
| 122 |
|
| 123 |
subroutine lower_bounds(x) |
| 124 |
integer :: x(2:101) |
| 125 |
call test((x)) |
| 126 |
end subroutine |
| 127 |
! CHECK-LABEL: func.func @_QPlower_bounds( |
| 128 |
! CHECK: %[[VAL_1:.*]] = arith.constant 2 : index |
| 129 |
! CHECK: %[[VAL_2:.*]] = arith.constant 100 : index |
| 130 |
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_3:[^)]*]]) {{.*}}x |
| 131 |
! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> |
| 132 |
! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> { |
| 133 |
! CHECK: ^bb0(%[[VAL_7:.*]]: index): |
| 134 |
! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index |
| 135 |
! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_1]], %[[VAL_8]] : index |
| 136 |
! CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_7]], %[[VAL_9]] : index |
| 137 |
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_10]]) : (!fir.box<!fir.array<100xi32>>, index) -> !fir.ref<i32> |
| 138 |
! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_11]] : !fir.ref<i32> |
| 139 |
! CHECK: %[[VAL_13:.*]] = hlfir.no_reassoc %[[VAL_12]] : i32 |
| 140 |
! CHECK: hlfir.yield_element %[[VAL_13]] : i32 |
| 141 |
! CHECK: } |
| 142 |
! CHECK: fir.call |
| 143 |
! CHECK: hlfir.destroy %[[VAL_6]] |
| 144 |
|
| 145 |
! Check that the character length for hlfir.associate is taken from |
| 146 |
! hlfir.apply: |
| 147 |
subroutine char_return(x,y) |
| 148 |
interface |
| 149 |
elemental character(3) function callee(x) |
| 150 |
character(3), intent(in) :: x |
| 151 |
end function callee |
| 152 |
end interface |
| 153 |
character(3), intent(in) :: x(:), y(:) |
| 154 |
logical, allocatable :: l(:) |
| 155 |
l = x==callee(y) |
| 156 |
end subroutine char_return |
| 157 |
! CHECK-LABEL: func.func @_QPchar_return( |
| 158 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.char<1,3>>> {fir.bindc_name = "x"}, |
| 159 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.char<1,3>>> {fir.bindc_name = "y"}) { |
| 160 |
! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.char<1,3> {bindc_name = ".result"} |
| 161 |
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>> {bindc_name = "l", uniq_name = "_QFchar_returnEl"} |
| 162 |
! CHECK: %[[VAL_4:.*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.logical<4>>> |
| 163 |
! CHECK: %[[VAL_5:.*]] = arith.constant 0 : index |
| 164 |
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1> |
| 165 |
! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_4]](%[[VAL_6]]) : (!fir.heap<!fir.array<?x!fir.logical<4>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>> |
| 166 |
! CHECK: fir.store %[[VAL_7]] to %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>> |
| 167 |
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_3]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFchar_returnEl"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>>) |
| 168 |
! CHECK: %[[VAL_9:.*]] = arith.constant 3 : index |
| 169 |
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_9]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFchar_returnEx"} : (!fir.box<!fir.array<?x!fir.char<1,3>>>, index, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.char<1,3>>>, !fir.box<!fir.array<?x!fir.char<1,3>>>) |
| 170 |
! CHECK: %[[VAL_11:.*]] = arith.constant 3 : index |
| 171 |
! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_1]] typeparams %[[VAL_11]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFchar_returnEy"} : (!fir.box<!fir.array<?x!fir.char<1,3>>>, index, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.char<1,3>>>, !fir.box<!fir.array<?x!fir.char<1,3>>>) |
| 172 |
! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index |
| 173 |
! CHECK: %[[VAL_14:.*]]:3 = fir.box_dims %[[VAL_12]]#0, %[[VAL_13]] : (!fir.box<!fir.array<?x!fir.char<1,3>>>, index) -> (index, index, index) |
| 174 |
! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_14]]#1 : (index) -> !fir.shape<1> |
| 175 |
! CHECK: %[[VAL_16:.*]] = arith.constant 3 : index |
| 176 |
! CHECK: %[[VAL_17:.*]] = hlfir.elemental %[[VAL_15]] typeparams %[[VAL_16]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<?x!fir.char<1,3>> { |
| 177 |
! CHECK: ^bb0(%[[VAL_18:.*]]: index): |
| 178 |
! CHECK: %[[VAL_19:.*]] = hlfir.designate %[[VAL_12]]#0 (%[[VAL_18]]) typeparams %[[VAL_11]] : (!fir.box<!fir.array<?x!fir.char<1,3>>>, index, index) -> !fir.ref<!fir.char<1,3>> |
| 179 |
! CHECK: %[[VAL_20:.*]] = fir.emboxchar %[[VAL_19]], %[[VAL_11]] : (!fir.ref<!fir.char<1,3>>, index) -> !fir.boxchar<1> |
| 180 |
! CHECK: %[[VAL_21:.*]] = arith.constant 3 : i64 |
| 181 |
! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> index |
| 182 |
! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index |
| 183 |
! CHECK: %[[VAL_24:.*]] = arith.cmpi sgt, %[[VAL_22]], %[[VAL_23]] : index |
| 184 |
! CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_24]], %[[VAL_22]], %[[VAL_23]] : index |
| 185 |
! CHECK: %[[VAL_26:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8> |
| 186 |
! CHECK: %[[VAL_27:.*]] = fir.call @_QPcallee(%[[VAL_2]], %[[VAL_25]], %[[VAL_20]]) fastmath<contract> : (!fir.ref<!fir.char<1,3>>, index, !fir.boxchar<1>) -> !fir.boxchar<1> |
| 187 |
! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[VAL_25]] {uniq_name = ".tmp.func_result"} : (!fir.ref<!fir.char<1,3>>, index) -> (!fir.ref<!fir.char<1,3>>, !fir.ref<!fir.char<1,3>>) |
| 188 |
! CHECK: %[[MustFree:.*]] = arith.constant false |
| 189 |
! CHECK: %[[ResultTemp:.*]] = hlfir.as_expr %[[VAL_28]]#0 move %[[MustFree]] : (!fir.ref<!fir.char<1,3>>, i1) -> !hlfir.expr<!fir.char<1,3>> |
| 190 |
! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_26]]) fastmath<contract> : (!fir.ref<i8>) -> () |
| 191 |
! CHECK: hlfir.yield_element %[[ResultTemp]] : !hlfir.expr<!fir.char<1,3>> |
| 192 |
! CHECK: } |
| 193 |
! CHECK: %[[VAL_29:.*]] = arith.constant 0 : index |
| 194 |
! CHECK: %[[VAL_30:.*]]:3 = fir.box_dims %[[VAL_10]]#0, %[[VAL_29]] : (!fir.box<!fir.array<?x!fir.char<1,3>>>, index) -> (index, index, index) |
| 195 |
! CHECK: %[[VAL_31:.*]] = fir.shape %[[VAL_30]]#1 : (index) -> !fir.shape<1> |
| 196 |
! CHECK: %[[VAL_32:.*]] = hlfir.elemental %[[VAL_31]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> { |
| 197 |
! CHECK: ^bb0(%[[VAL_33:.*]]: index): |
| 198 |
! CHECK: %[[VAL_34:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[VAL_33]]) typeparams %[[VAL_9]] : (!fir.box<!fir.array<?x!fir.char<1,3>>>, index, index) -> !fir.ref<!fir.char<1,3>> |
| 199 |
! CHECK: %[[VAL_35:.*]] = hlfir.apply %[[VAL_36:.*]], %[[VAL_33]] typeparams %[[VAL_16]] : (!hlfir.expr<?x!fir.char<1,3>>, index, index) -> !hlfir.expr<!fir.char<1,3>> |
| 200 |
! CHECK: %[[VAL_37:.*]]:3 = hlfir.associate %[[VAL_35]] typeparams %[[VAL_16]] {adapt.valuebyref} : (!hlfir.expr<!fir.char<1,3>>, index) -> (!fir.ref<!fir.char<1,3>>, !fir.ref<!fir.char<1,3>>, i1) |
| 201 |
! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8> |
| 202 |
! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_37]]#1 : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8> |
| 203 |
! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_9]] : (index) -> i64 |
| 204 |
! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_16]] : (index) -> i64 |
| 205 |
! CHECK: %[[VAL_42:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_38]], %[[VAL_39]], %[[VAL_40]], %[[VAL_41]]) fastmath<contract> : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32 |
| 206 |
! CHECK: %[[VAL_43:.*]] = arith.constant 0 : i32 |
| 207 |
! CHECK: %[[VAL_44:.*]] = arith.cmpi eq, %[[VAL_42]], %[[VAL_43]] : i32 |
| 208 |
! CHECK: hlfir.end_associate %[[VAL_37]]#1, %[[VAL_37]]#2 : !fir.ref<!fir.char<1,3>>, i1 |
| 209 |
! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_44]] : (i1) -> !fir.logical<4> |
| 210 |
! CHECK: hlfir.yield_element %[[VAL_45]] : !fir.logical<4> |
| 211 |
! CHECK: } |
| 212 |
! CHECK: hlfir.assign %[[VAL_46:.*]] to %[[VAL_8]]#0 realloc : !hlfir.expr<?x!fir.logical<4>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>> |
| 213 |
! CHECK: hlfir.destroy %[[VAL_46]] : !hlfir.expr<?x!fir.logical<4>> |
| 214 |
! CHECK: hlfir.destroy %[[VAL_47:.*]] : !hlfir.expr<?x!fir.char<1,3>> |
| 215 |
! CHECK: return |
| 216 |
! CHECK: } |
| 217 |
|
| 218 |
subroutine polymorphic_parenthesis(x, y) |
| 219 |
type t |
| 220 |
end type t |
| 221 |
class(t), allocatable :: x(:) |
| 222 |
class(t), intent(in) :: y(:) |
| 223 |
x = (y) |
| 224 |
end subroutine polymorphic_parenthesis |
| 225 |
! CHECK-LABEL: func.func @_QPpolymorphic_parenthesis( |
| 226 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.class<!fir.heap<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>>> {fir.bindc_name = "x"}, |
| 227 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>> {fir.bindc_name = "y"}) { |
| 228 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFpolymorphic_parenthesisEx"} : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>>>, !fir.dscope) -> (!fir.ref<!fir.class<!fir.heap<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>>>, !fir.ref<!fir.class<!fir.heap<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>>>) |
| 229 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFpolymorphic_parenthesisEy"} : (!fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>, !fir.dscope) -> (!fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>, !fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>) |
| 230 |
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index |
| 231 |
! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>, index) -> (index, index, index) |
| 232 |
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1> |
| 233 |
! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] mold %[[VAL_3]]#0 unordered : (!fir.shape<1>, !fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>) -> !hlfir.expr<?x!fir.type<_QFpolymorphic_parenthesisTt>?> { |
| 234 |
! CHECK: ^bb0(%[[VAL_8:.*]]: index): |
| 235 |
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_8]]) : (!fir.class<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>, index) -> !fir.class<!fir.type<_QFpolymorphic_parenthesisTt>> |
| 236 |
! CHECK: %[[VAL_10:.*]] = hlfir.as_expr %[[VAL_9]] : (!fir.class<!fir.type<_QFpolymorphic_parenthesisTt>>) -> !hlfir.expr<!fir.type<_QFpolymorphic_parenthesisTt>?> |
| 237 |
! CHECK: hlfir.yield_element %[[VAL_10]] : !hlfir.expr<!fir.type<_QFpolymorphic_parenthesisTt>?> |
| 238 |
! CHECK: } |
| 239 |
! CHECK: hlfir.assign %[[VAL_7]] to %[[VAL_2]]#0 realloc : !hlfir.expr<?x!fir.type<_QFpolymorphic_parenthesisTt>?>, !fir.ref<!fir.class<!fir.heap<!fir.array<?x!fir.type<_QFpolymorphic_parenthesisTt>>>>> |
| 240 |
! CHECK: hlfir.destroy %[[VAL_7]] : !hlfir.expr<?x!fir.type<_QFpolymorphic_parenthesisTt>?> |
| 241 |
! CHECK: return |
| 242 |
! CHECK: } |
| 243 |
|
| 244 |
subroutine unlimited_polymorphic_parenthesis(x, y) |
| 245 |
class(*), allocatable :: x(:) |
| 246 |
class(*), intent(in) :: y(:) |
| 247 |
x = (y) |
| 248 |
end subroutine unlimited_polymorphic_parenthesis |
| 249 |
! CHECK-LABEL: func.func @_QPunlimited_polymorphic_parenthesis( |
| 250 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.class<!fir.heap<!fir.array<?xnone>>>> {fir.bindc_name = "x"}, |
| 251 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.class<!fir.array<?xnone>> {fir.bindc_name = "y"}) { |
| 252 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFunlimited_polymorphic_parenthesisEx"} : (!fir.ref<!fir.class<!fir.heap<!fir.array<?xnone>>>>, !fir.dscope) -> (!fir.ref<!fir.class<!fir.heap<!fir.array<?xnone>>>>, !fir.ref<!fir.class<!fir.heap<!fir.array<?xnone>>>>) |
| 253 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFunlimited_polymorphic_parenthesisEy"} : (!fir.class<!fir.array<?xnone>>, !fir.dscope) -> (!fir.class<!fir.array<?xnone>>, !fir.class<!fir.array<?xnone>>) |
| 254 |
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index |
| 255 |
! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.class<!fir.array<?xnone>>, index) -> (index, index, index) |
| 256 |
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1> |
| 257 |
! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] mold %[[VAL_3]]#0 unordered : (!fir.shape<1>, !fir.class<!fir.array<?xnone>>) -> !hlfir.expr<?xnone?> { |
| 258 |
! CHECK: ^bb0(%[[VAL_8:.*]]: index): |
| 259 |
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_8]]) : (!fir.class<!fir.array<?xnone>>, index) -> !fir.class<none> |
| 260 |
! CHECK: %[[VAL_10:.*]] = hlfir.as_expr %[[VAL_9]] : (!fir.class<none>) -> !hlfir.expr<none?> |
| 261 |
! CHECK: hlfir.yield_element %[[VAL_10]] : !hlfir.expr<none?> |
| 262 |
! CHECK: } |
| 263 |
! CHECK: hlfir.assign %[[VAL_7]] to %[[VAL_2]]#0 realloc : !hlfir.expr<?xnone?>, !fir.ref<!fir.class<!fir.heap<!fir.array<?xnone>>>> |
| 264 |
! CHECK: hlfir.destroy %[[VAL_7]] : !hlfir.expr<?xnone?> |
| 265 |
! CHECK: return |
| 266 |
! CHECK: } |