1 ! Test lowering of unary intrinsic operations to HLFIR
2 ! RUN: bbc -emit-fir -hlfir -o - %s 2>&1 | FileCheck %s
4 subroutine parentheses_numeric_var(x
)
8 ! CHECK-LABEL: func.func @_QPparentheses_numeric_var(
9 ! CHECK: %[[VAL_2:.*]] = fir.load %{{.*}} : !fir.ref<i32>
10 ! CHECK: %[[VAL_3:.*]] = hlfir.no_reassoc %[[VAL_2]] : i32
12 subroutine parentheses_numeric_expr(x
)
14 call bar((x
+1000.)*2.)
16 ! CHECK-LABEL: func.func @_QPparentheses_numeric_expr(
17 ! CHECK: %[[VAL_4:.*]] = arith.addf
18 ! CHECK: %[[VAL_5:.*]] = hlfir.no_reassoc %[[VAL_4]] : f32
19 ! CHECK: %[[VAL_7:.*]] = arith.mulf %[[VAL_5]], %{{.*}}
21 subroutine parentheses_char_var(x
)
25 ! CHECK-LABEL: func.func @_QPparentheses_char_var(
26 ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare
27 ! CHECK: %[[VAL_3:.*]] = hlfir.as_expr %[[VAL_2]]#0 : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
29 subroutine parentheses_char_expr(x
)
33 ! CHECK-LABEL: func.func @_QPparentheses_char_expr(
34 ! CHECK: %[[VAL_4:.*]] = hlfir.concat
35 ! CHECK: %[[VAL_5:.*]] = hlfir.no_reassoc %[[VAL_4]] : !hlfir.expr<!fir.char<1,?>>
36 ! CHECK: %[[VAL_7:.*]] = hlfir.concat %[[VAL_5]], %{{.*}} len %{{.*}}
37 subroutine test_not(l
, x
)
41 ! CHECK-LABEL: func.func @_QPtest_not(
42 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
43 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.logical<4>>
44 ! CHECK: %[[VAL_5:.*]] = arith.constant true
45 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_4]] : (!fir.logical<4>) -> i1
46 ! CHECK: %[[VAL_7:.*]] = arith.xori %[[VAL_6]], %[[VAL_5]] : i1
48 subroutine test_negate_int(res
, x
)
52 ! CHECK-LABEL: func.func @_QPtest_negate_int(
53 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
54 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
55 ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32
56 ! CHECK: %[[VAL_6:.*]] = arith.subi %[[VAL_5]], %[[VAL_4]] : i32
58 subroutine test_negate_real(res
, x
)
62 ! CHECK-LABEL: func.func @_QPtest_negate_real(
63 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
64 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<f32>
65 ! CHECK: %[[VAL_5:.*]] = arith.negf %[[VAL_4]] fastmath<contract> : f32
67 subroutine test_negate_complex(res
, x
)
71 ! CHECK-LABEL: func.func @_QPtest_negate_complex(
72 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>)
73 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.complex<4>>
74 ! CHECK: %[[VAL_5:.*]] = fir.negc %[[VAL_4]] : !fir.complex<4>
76 subroutine test_complex_component_real(res
, x
)
81 ! CHECK-LABEL: func.func @_QPtest_complex_component_real(
82 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>)
83 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.complex<4>>
84 ! CHECK: %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [0 : index] : (!fir.complex<4>) -> f32
86 subroutine test_complex_component_imag(res
, x
)
91 ! CHECK-LABEL: func.func @_QPtest_complex_component_imag(
92 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<!fir.complex<4>>) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>)
93 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.complex<4>>
94 ! CHECK: %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [1 : index] : (!fir.complex<4>) -> f32