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
98 lines
4.5 KiB
Fortran
98 lines
4.5 KiB
Fortran
! Test lowering of COUNT intrinsic to HLFIR
|
|
! RUN: bbc -emit-hlfir -o - %s 2>&1 | FileCheck %s
|
|
|
|
! simple 1 argument COUNT
|
|
subroutine count1(a, s)
|
|
logical :: a(:)
|
|
integer :: s
|
|
s = COUNT(a)
|
|
end subroutine
|
|
! CHECK-LABEL: func.func @_QPcount1(
|
|
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>
|
|
! CHECK: %[[ARG1:.*]]: !fir.ref<i32>
|
|
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG0]]
|
|
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
|
|
! CHECK-NEXT: %[[EXPR:.*]] = hlfir.count %[[MASK]]#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
|
|
! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
|
|
! CHECK-NEXT: return
|
|
! CHECK-NEXT: }
|
|
|
|
! count with by-ref DIM argument
|
|
subroutine count2(a, s, d)
|
|
logical :: a(:,:)
|
|
integer :: s(:), d
|
|
s = COUNT(a, d)
|
|
end subroutine
|
|
! CHECK-LABEL: func.func @_QPcount2(
|
|
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>
|
|
! CHECK: %[[ARG1:.*]]: !fir.box<!fir.array<?xi32>>
|
|
! CHECK: %[[ARG2:.*]]: !fir.ref<i32>
|
|
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG0]]
|
|
! CHECK-DAG: %[[DIM_REF:.*]]:2 = hlfir.declare %[[ARG2]]
|
|
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
|
|
! CHECK-DAG: %[[DIM:.*]] = fir.load %[[DIM_REF]]#0 : !fir.ref<i32>
|
|
! CHECK-DAG: %[[EXPR:.*]] = hlfir.count %[[MASK]]#0 dim %[[DIM]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i32) -> !hlfir.expr<?xi32>
|
|
! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<?xi32>, !fir.box<!fir.array<?xi32>>
|
|
! CHECK-NEXT: hlfir.destroy %[[EXPR]] : !hlfir.expr<?xi32>
|
|
! CHECK-NEXT: return
|
|
! CHECK-NEXT: }
|
|
|
|
! count with DIM argument by-val, mask isn't boxed
|
|
subroutine count3(s)
|
|
integer :: s(2)
|
|
logical :: a(2,2) = reshape((/.true.,.false.,.true.,.false./), shape(a))
|
|
s = COUNT(a, 1)
|
|
end subroutine
|
|
! CHECK-LABEL: func.func @_QPcount3(
|
|
! CHECK: %[[ARG0:.*]]: !fir.ref<!fir.array<2xi32>>
|
|
! CHECK-DAG: %[[ADDR:.*]] = fir.address_of{{.*}} : !fir.ref<!fir.array<2x2x!fir.logical<4>>>
|
|
! CHECK-DAG: %[[MASK_SHAPE:.*]] = fir.shape {{.*}} -> !fir.shape<2>
|
|
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ADDR]](%[[MASK_SHAPE]])
|
|
! CHECK-DAG: %[[OUT_SHAPE:.*]] = fir.shape {{.*}} -> !fir.shape<1>
|
|
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG0]](%[[OUT_SHAPE]])
|
|
! CHECK-DAG: %[[C1:.*]] = arith.constant 1 : i32
|
|
! CHECK-DAG: %[[EXPR:.*]] = hlfir.count %[[MASK]]#0 dim %[[C1]] : (!fir.ref<!fir.array<2x2x!fir.logical<4>>>, i32) -> !hlfir.expr<2xi32>
|
|
! CHECK-DAG: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<2xi32>, !fir.ref<!fir.array<2xi32>>
|
|
! CHECK-NEXT: hlfir.destroy %[[EXPR]] : !hlfir.expr<2xi32>
|
|
! CHECK-NEXT: return
|
|
! CHECK-NEXT: }
|
|
|
|
! count with dim and kind arguments
|
|
subroutine count4(a, s, d)
|
|
logical :: a(:,:)
|
|
integer :: s(:), d
|
|
s = COUNT(a, d, 8)
|
|
end subroutine
|
|
! CHECK-LABEL: func.func @_QPcount4(
|
|
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>
|
|
! CHECK: %[[ARG1:.*]]: !fir.box<!fir.array<?xi32>>
|
|
! CHECK: %[[ARG2:.*]]: !fir.ref<i32>
|
|
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG0]]
|
|
! CHECK-DAG: %[[DIM_REF:.*]]:2 = hlfir.declare %[[ARG2]]
|
|
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
|
|
! CHECK-DAG: %[[DIM:.*]] = fir.load %[[DIM_REF]]#0 : !fir.ref<i32>
|
|
! CHECK-DAG: %[[EXPR:.*]] = hlfir.count %[[MASK]]#0 dim %[[DIM]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i32) -> !hlfir.expr<?xi64>
|
|
! CHECK-DAG: %[[RES_SHAPE:.*]] = hlfir.shape_of %[[EXPR]]
|
|
! CHECK-DAG: %[[RES:.*]] = hlfir.elemental %[[RES_SHAPE]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32>
|
|
! CHECK-DAG: hlfir.assign %[[RES]] to %[[OUT]]#0
|
|
! CHECK-NEXT: hlfir.destroy %[[RES]] : !hlfir.expr<?xi32>
|
|
! CHECK-NEXT: hlfir.destroy %[[EXPR]] : !hlfir.expr<?xi64>
|
|
! CHECK-NEXT: return
|
|
! CHECK-NEXT: }
|
|
|
|
subroutine count5(a, s)
|
|
logical, allocatable :: a(:)
|
|
integer :: s
|
|
s = COUNT(a)
|
|
end subroutine
|
|
! CHECK-LABEL: func.func @_QPcount5(
|
|
! CHECK: %[[ARG0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>>
|
|
! CHECK: %[[ARG1:.*]]: !fir.ref<i32>
|
|
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG0]]
|
|
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
|
|
! CHECK-NEXT: %[[MASK_LOADED:.*]] = fir.load %[[MASK]]#0
|
|
! CHECK-NEXT: %[[EXPR:.*]] = hlfir.count %[[MASK_LOADED]] : (!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>) -> i32
|
|
! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
|
|
! CHECK-NEXT: return
|
|
! CHECK-NEXT: }
|