| 1 |
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s |
| 2 |
|
| 3 |
! CHECK-LABEL: func.func @_QPtest1( |
| 4 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "x"}, |
| 5 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "y"}) { |
| 6 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest1Ex"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 7 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest1Ey"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 8 |
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.logical<4>> |
| 9 |
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.logical<4>) -> i32 |
| 10 |
! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_2]]#0 : i32, !fir.ref<i32> |
| 11 |
! CHECK: return |
| 12 |
! CHECK: } |
| 13 |
subroutine test1(x, y) |
| 14 |
integer :: x |
| 15 |
logical :: y |
| 16 |
x = y |
| 17 |
end subroutine test1 |
| 18 |
|
| 19 |
! CHECK-LABEL: func.func @_QPtest2( |
| 20 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "x"}, |
| 21 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "y"}) { |
| 22 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest2Ex"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 23 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest2Ey"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 24 |
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<i32> |
| 25 |
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> !fir.logical<4> |
| 26 |
! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_3]]#0 : !fir.logical<4>, !fir.ref<!fir.logical<4>> |
| 27 |
! CHECK: return |
| 28 |
! CHECK: } |
| 29 |
subroutine test2(x, y) |
| 30 |
integer :: x |
| 31 |
logical :: y |
| 32 |
y = x |
| 33 |
end subroutine test2 |
| 34 |
|
| 35 |
! CHECK-LABEL: func.func @_QPtest3( |
| 36 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "x"}, |
| 37 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "y"}) { |
| 38 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest3Ex"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 39 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest3Ey"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 40 |
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32> |
| 41 |
! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32 |
| 42 |
! CHECK: %[[VAL_6:.*]] = arith.cmpi eq, %[[VAL_4]], %[[VAL_5]] : i32 |
| 43 |
! CHECK: %[[VAL_7:.*]] = hlfir.no_reassoc %[[VAL_6]] : i1 |
| 44 |
! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i1) -> !fir.logical<4> |
| 45 |
! CHECK: hlfir.assign %[[VAL_8]] to %[[VAL_2]]#0 : !fir.logical<4>, !fir.ref<!fir.logical<4>> |
| 46 |
! CHECK: return |
| 47 |
! CHECK: } |
| 48 |
subroutine test3(x, y) |
| 49 |
logical :: x |
| 50 |
integer :: y |
| 51 |
x = (y.eq.1) |
| 52 |
end subroutine test3 |
| 53 |
|
| 54 |
! CHECK-LABEL: func.func @_QPtest4( |
| 55 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "x"}, |
| 56 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32> {fir.bindc_name = "y"}) { |
| 57 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest4Ex"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 58 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest4Ey"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 59 |
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32> |
| 60 |
! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32 |
| 61 |
! CHECK: %[[VAL_6:.*]] = arith.cmpi eq, %[[VAL_4]], %[[VAL_5]] : i32 |
| 62 |
! CHECK: %[[VAL_7:.*]] = hlfir.no_reassoc %[[VAL_6]] : i1 |
| 63 |
! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i1) -> i32 |
| 64 |
! CHECK: hlfir.assign %[[VAL_8]] to %[[VAL_2]]#0 : i32, !fir.ref<i32> |
| 65 |
! CHECK: return |
| 66 |
! CHECK: } |
| 67 |
subroutine test4(x, y) |
| 68 |
integer :: x |
| 69 |
integer :: y |
| 70 |
x = (y.eq.1) |
| 71 |
end subroutine test4 |
| 72 |
|
| 73 |
! CHECK-LABEL: func.func @_QPtest5( |
| 74 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "x"}, |
| 75 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "y"}) { |
| 76 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest5Ex"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>) |
| 77 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest5Ey"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) |
| 78 |
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.logical<4>> |
| 79 |
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.logical<4>) -> i32 |
| 80 |
! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_2]]#0 : i32, !fir.box<!fir.array<?xi32>> |
| 81 |
! CHECK: return |
| 82 |
! CHECK: } |
| 83 |
subroutine test5(x, y) |
| 84 |
integer :: x(:) |
| 85 |
logical :: y |
| 86 |
x = y |
| 87 |
end subroutine test5 |
| 88 |
|
| 89 |
! CHECK-LABEL: func.func @_QPtest6( |
| 90 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "x"}, |
| 91 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>> {fir.bindc_name = "y"}) { |
| 92 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest6Ex"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>) |
| 93 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest6Ey"} : (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>) |
| 94 |
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index |
| 95 |
! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> (index, index, index) |
| 96 |
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1> |
| 97 |
! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> { |
| 98 |
! CHECK: ^bb0(%[[VAL_8:.*]]: index): |
| 99 |
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_8]]) : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.ref<!fir.logical<4>> |
| 100 |
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<!fir.logical<4>> |
| 101 |
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.logical<4>) -> i32 |
| 102 |
! CHECK: hlfir.yield_element %[[VAL_11]] : i32 |
| 103 |
! CHECK: } |
| 104 |
! CHECK: hlfir.assign %[[VAL_12:.*]] to %[[VAL_2]]#0 : !hlfir.expr<?xi32>, !fir.box<!fir.array<?xi32>> |
| 105 |
! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<?xi32> |
| 106 |
! CHECK: return |
| 107 |
! CHECK: } |
| 108 |
subroutine test6(x, y) |
| 109 |
integer :: x(:) |
| 110 |
logical :: y(:) |
| 111 |
x = y |
| 112 |
end subroutine test6 |
| 113 |
|
| 114 |
! CHECK-LABEL: func.func @_QPtest7( |
| 115 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>> {fir.bindc_name = "x"}, |
| 116 |
! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "y"}) { |
| 117 |
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest7Ex"} : (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>) |
| 118 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest7Ey"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>) |
| 119 |
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index |
| 120 |
! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index) |
| 121 |
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1> |
| 122 |
! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> { |
| 123 |
! CHECK: ^bb0(%[[VAL_8:.*]]: index): |
| 124 |
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_8]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32> |
| 125 |
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32> |
| 126 |
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i32) -> !fir.logical<4> |
| 127 |
! CHECK: hlfir.yield_element %[[VAL_11]] : !fir.logical<4> |
| 128 |
! CHECK: } |
| 129 |
! CHECK: hlfir.assign %[[VAL_12:.*]] to %[[VAL_2]]#0 : !hlfir.expr<?x!fir.logical<4>>, !fir.box<!fir.array<?x!fir.logical<4>>> |
| 130 |
! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<?x!fir.logical<4>> |
| 131 |
! CHECK: return |
| 132 |
! CHECK: } |
| 133 |
subroutine test7(x, y) |
| 134 |
logical :: x(:) |
| 135 |
integer :: y(:) |
| 136 |
x = y |
| 137 |
end subroutine test7 |