Files
TheRock/compiler/amd-llvm/flang/test/Lower/array-elemental-calls-3.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

69 lines
2.1 KiB
Fortran

! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
! Test lowering of elemental calls with array arguments that use array
! elements as indices.
! As reported in issue #62981, wrong code was being generated in this case.
module test_ops
implicit none
interface
integer elemental function elem_func_i(i)
integer, intent(in) :: i
end function
real elemental function elem_func_r(r)
real, intent(in) :: r
end function
end interface
integer :: a(3), b(3), v(3), i, j, k, l
real :: x(2), y(2), u
contains
! CHECK-LABEL: func @_QMtest_opsPcheck_array_elems_as_indices() {
subroutine check_array_elems_as_indices()
! CHECK: %[[A_ADDR:.*]] = fir.address_of(@_QMtest_opsEa) : !fir.ref<!fir.array<3xi32>>
! CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_ADDR]]
! CHECK: %[[V_ADDR:.*]] = fir.address_of(@_QMtest_opsEv) : !fir.ref<!fir.array<3xi32>>
! CHECK: %[[V_DECL:.*]]:2 = hlfir.declare %[[V_ADDR]]
! CHECK: hlfir.forall lb {
! CHECK: } ub {
! CHECK: } (%[[I:.*]]: i32) {
! CHECK: %[[I_IDX:.*]] = hlfir.forall_index "i" %[[I]]
! CHECK: hlfir.region_assign {
! CHECK: %[[SLICE:.*]] = hlfir.designate %[[A_DECL]]#0
! CHECK: hlfir.elemental {{.*}} unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
! CHECK: ^bb0(%[[ARG:.*]]: index):
! CHECK: %[[ELEM_ADDR:.*]] = hlfir.designate %[[SLICE]] (%[[ARG]])
! CHECK: %[[RES:.*]] = fir.call @_QPelem_func_i(%[[ELEM_ADDR]])
! CHECK: hlfir.yield_element %[[RES]] : i32
! CHECK: }
! CHECK: }
! CHECK: }
forall (i=1:3)
b(i:i) = elem_func_i(a(v(i):v(i)))
end forall
end subroutine
! CHECK-LABEL: func @_QMtest_opsPcheck_not_assert() {
subroutine check_not_assert()
! Implicit path.
! CHECK: hlfir.elemental
! CHECK: fir.call @_QPelem_func_i
b = 10 + elem_func_i(a)
! Expression as argument, instead of variable.
forall (i=1:3)
b(i:i) = elem_func_i(a(i:i) + a(i:i))
end forall
! Nested elemental function calls.
y = elem_func_r(cos(x))
y = elem_func_r(cos(x) + u)
! Array constructors as elemental function arguments.
y = atan2( (/ (real(i, 4), i = 1, 2) /), &
real( (/ (i, i = j, k, l) /), 4) )
end subroutine
end module