brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · bbe2641 Raw
95 lines · plain
1! Test lowering of unary intrinsic operations to HLFIR2! RUN: bbc -emit-hlfir -o - %s 2>&1 | FileCheck %s3 4subroutine parentheses_numeric_var(x)5  integer :: x6  call bar((x))7end subroutine8! 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]] : i3211 12subroutine parentheses_numeric_expr(x)13  real :: x14  call bar((x+1000.)*2.)15end subroutine16! CHECK-LABEL: func.func @_QPparentheses_numeric_expr(17! CHECK:  %[[VAL_4:.*]] = arith.addf18! CHECK:  %[[VAL_5:.*]] = hlfir.no_reassoc %[[VAL_4]] : f3219! CHECK:  %[[VAL_7:.*]] = arith.mulf %[[VAL_5]], %{{.*}}20 21subroutine parentheses_char_var(x)22  character(*) :: x23  call bar2((x))24end subroutine25! CHECK-LABEL: func.func @_QPparentheses_char_var(26! CHECK:  %[[VAL_2:.*]]:2 = hlfir.declare27! CHECK:  %[[VAL_3:.*]] = hlfir.as_expr %[[VAL_2]]#0 : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>28 29subroutine parentheses_char_expr(x)30  character(*) :: x31  call bar2((x//x)//x)32end subroutine33! CHECK-LABEL: func.func @_QPparentheses_char_expr(34! CHECK:  %[[VAL_4:.*]] = hlfir.concat35! CHECK:  %[[VAL_5:.*]] = hlfir.no_reassoc %[[VAL_4]] : !hlfir.expr<!fir.char<1,?>>36! CHECK:  %[[VAL_7:.*]] = hlfir.concat %[[VAL_5]], %{{.*}} len %{{.*}}37subroutine test_not(l, x)38  logical :: l, x39  l = .not.x40end subroutine41! CHECK-LABEL: func.func @_QPtest_not(42! CHECK:  %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!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 true45! CHECK:  %[[VAL_6:.*]] = fir.convert %[[VAL_4]] : (!fir.logical<4>) -> i146! CHECK:  %[[VAL_7:.*]] = arith.xori %[[VAL_6]], %[[VAL_5]] : i147 48subroutine test_negate_int(res, x)49  integer :: res, x50  res = -x51end subroutine52! CHECK-LABEL: func.func @_QPtest_negate_int(53! CHECK:  %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<i32>, !fir.dscope) -> (!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 : i3256! CHECK:  %[[VAL_6:.*]] = arith.subi %[[VAL_5]], %[[VAL_4]] : i3257 58subroutine test_negate_real(res, x)59  real :: res, x60  res = -x61end subroutine62! CHECK-LABEL: func.func @_QPtest_negate_real(63! CHECK:  %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<f32>, !fir.dscope) -> (!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> : f3266 67subroutine test_negate_complex(res, x)68  complex :: res, x69  res = -x70end subroutine71! CHECK-LABEL: func.func @_QPtest_negate_complex(72! CHECK:  %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<complex<f32>>, !fir.dscope) -> (!fir.ref<complex<f32>>, !fir.ref<complex<f32>>)73! CHECK:  %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<complex<f32>>74! CHECK:  %[[VAL_5:.*]] = fir.negc %[[VAL_4]] : complex<f32>75 76subroutine test_complex_component_real(res, x)77  real :: res78  complex :: x79  res = real(x)80end subroutine81! CHECK-LABEL: func.func @_QPtest_complex_component_real(82! CHECK:  %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<complex<f32>>, !fir.dscope) -> (!fir.ref<complex<f32>>, !fir.ref<complex<f32>>)83! CHECK:  %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<complex<f32>>84! CHECK:  %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [0 : index] : (complex<f32>) -> f3285 86subroutine test_complex_component_imag(res, x)87  real :: res88  complex :: x89  res = aimag(x)90end subroutine91! CHECK-LABEL: func.func @_QPtest_complex_component_imag(92! CHECK:  %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<complex<f32>>, !fir.dscope) -> (!fir.ref<complex<f32>>, !fir.ref<complex<f32>>)93! CHECK:  %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<complex<f32>>94! CHECK:  %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [1 : index] : (complex<f32>) -> f3295