Files
TheRock/compiler/amd-llvm/flang/test/Lower/HLFIR/unary-ops.f90
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

95 lines
3.9 KiB
Fortran

! Test lowering of unary intrinsic operations to HLFIR
! RUN: bbc -emit-hlfir -o - %s 2>&1 | FileCheck %s
subroutine parentheses_numeric_var(x)
integer :: x
call bar((x))
end subroutine
! CHECK-LABEL: func.func @_QPparentheses_numeric_var(
! CHECK: %[[VAL_2:.*]] = fir.load %{{.*}} : !fir.ref<i32>
! CHECK: %[[VAL_3:.*]] = hlfir.no_reassoc %[[VAL_2]] : i32
subroutine parentheses_numeric_expr(x)
real :: x
call bar((x+1000.)*2.)
end subroutine
! CHECK-LABEL: func.func @_QPparentheses_numeric_expr(
! CHECK: %[[VAL_4:.*]] = arith.addf
! CHECK: %[[VAL_5:.*]] = hlfir.no_reassoc %[[VAL_4]] : f32
! CHECK: %[[VAL_7:.*]] = arith.mulf %[[VAL_5]], %{{.*}}
subroutine parentheses_char_var(x)
character(*) :: x
call bar2((x))
end subroutine
! CHECK-LABEL: func.func @_QPparentheses_char_var(
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare
! CHECK: %[[VAL_3:.*]] = hlfir.as_expr %[[VAL_2]]#0 : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
subroutine parentheses_char_expr(x)
character(*) :: x
call bar2((x//x)//x)
end subroutine
! CHECK-LABEL: func.func @_QPparentheses_char_expr(
! CHECK: %[[VAL_4:.*]] = hlfir.concat
! CHECK: %[[VAL_5:.*]] = hlfir.no_reassoc %[[VAL_4]] : !hlfir.expr<!fir.char<1,?>>
! CHECK: %[[VAL_7:.*]] = hlfir.concat %[[VAL_5]], %{{.*}} len %{{.*}}
subroutine test_not(l, x)
logical :: l, x
l = .not.x
end subroutine
! CHECK-LABEL: func.func @_QPtest_not(
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<!fir.logical<4>>
! CHECK: %[[VAL_5:.*]] = arith.constant true
! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_4]] : (!fir.logical<4>) -> i1
! CHECK: %[[VAL_7:.*]] = arith.xori %[[VAL_6]], %[[VAL_5]] : i1
subroutine test_negate_int(res, x)
integer :: res, x
res = -x
end subroutine
! CHECK-LABEL: func.func @_QPtest_negate_int(
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32
! CHECK: %[[VAL_6:.*]] = arith.subi %[[VAL_5]], %[[VAL_4]] : i32
subroutine test_negate_real(res, x)
real :: res, x
res = -x
end subroutine
! CHECK-LABEL: func.func @_QPtest_negate_real(
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_5:.*]] = arith.negf %[[VAL_4]] fastmath<contract> : f32
subroutine test_negate_complex(res, x)
complex :: res, x
res = -x
end subroutine
! CHECK-LABEL: func.func @_QPtest_negate_complex(
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<complex<f32>>, !fir.dscope) -> (!fir.ref<complex<f32>>, !fir.ref<complex<f32>>)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<complex<f32>>
! CHECK: %[[VAL_5:.*]] = fir.negc %[[VAL_4]] : complex<f32>
subroutine test_complex_component_real(res, x)
real :: res
complex :: x
res = real(x)
end subroutine
! CHECK-LABEL: func.func @_QPtest_complex_component_real(
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<complex<f32>>, !fir.dscope) -> (!fir.ref<complex<f32>>, !fir.ref<complex<f32>>)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<complex<f32>>
! CHECK: %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [0 : index] : (complex<f32>) -> f32
subroutine test_complex_component_imag(res, x)
real :: res
complex :: x
res = aimag(x)
end subroutine
! CHECK-LABEL: func.func @_QPtest_complex_component_imag(
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}}x"} : (!fir.ref<complex<f32>>, !fir.dscope) -> (!fir.ref<complex<f32>>, !fir.ref<complex<f32>>)
! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<complex<f32>>
! CHECK: %[[VAL_5:.*]] = fir.extract_value %[[VAL_4]], [1 : index] : (complex<f32>) -> f32