Files
TheRock/compiler/amd-llvm/flang/test/Lower/Intrinsics/maxval.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

67 lines
4.2 KiB
Fortran

! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPmaxval_test(
! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}) -> i32 {
integer function maxval_test(a)
integer :: a(:)
! CHECK-DAG: %[[A:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %{{.*}} arg 1 {uniq_name = "_QFmaxval_testEa"}
! CHECK-DAG: %[[RES_ALLOCA:.*]] = fir.alloca i32
! CHECK-DAG: %[[RES:.*]]:2 = hlfir.declare %[[RES_ALLOCA]] {uniq_name = "_QFmaxval_testEmaxval_test"}
maxval_test = maxval(a)
! CHECK: %[[MAXVAL:.*]] = hlfir.maxval %[[A]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> i32
! CHECK: hlfir.assign %[[MAXVAL]] to %[[RES]]#0 : i32, !fir.ref<i32>
end function
! CHECK-LABEL: func @_QPmaxval_test2(
! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.char<1>>, %[[ARG1:.*]]: index, %[[ARG2:.*]]: !fir.box<!fir.array<?x!fir.char<1>>> {fir.bindc_name = "a"}) -> !fir.boxchar<1> {
character function maxval_test2(a)
character :: a(:)
! CHECK-DAG: %[[A:.*]]:2 = hlfir.declare %[[ARG2]] typeparams %{{.*}} dummy_scope %{{.*}} arg 1 {uniq_name = "_QFmaxval_test2Ea"}
! CHECK-DAG: %[[RES:.*]]:2 = hlfir.declare %[[ARG0]] typeparams %{{.*}} {uniq_name = "_QFmaxval_test2Emaxval_test2"}
maxval_test2 = maxval(a)
! CHECK: %[[MAXVAL:.*]] = hlfir.maxval %[[A]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?x!fir.char<1>>>) -> !hlfir.expr<!fir.char<1>>
! CHECK: hlfir.assign %[[MAXVAL]] to %[[RES]]#0 : !hlfir.expr<!fir.char<1>>, !fir.ref<!fir.char<1>>
! CHECK: hlfir.destroy %[[MAXVAL]] : !hlfir.expr<!fir.char<1>>
end function
! CHECK-LABEL: func @_QPmaxval_test3(
! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[ARG1:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}) {
subroutine maxval_test3(a,r)
integer :: a(:,:)
integer :: r(:)
! CHECK-DAG: %[[A:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %{{.*}} arg 1 {uniq_name = "_QFmaxval_test3Ea"}
! CHECK-DAG: %[[R:.*]]:2 = hlfir.declare %[[ARG1]] dummy_scope %{{.*}} arg 2 {uniq_name = "_QFmaxval_test3Er"}
! CHECK-DAG: %[[C2:.*]] = arith.constant 2 : i32
r = maxval(a,dim=2)
! CHECK: %[[MAXVAL:.*]] = hlfir.maxval %[[A]]#0 dim %[[C2]] {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?x?xi32>>, i32) -> !hlfir.expr<?xi32>
! CHECK: hlfir.assign %[[MAXVAL]] to %[[R]]#0 : !hlfir.expr<?xi32>, !fir.box<!fir.array<?xi32>>
! CHECK: hlfir.destroy %[[MAXVAL]] : !hlfir.expr<?xi32>
end subroutine
! CHECK-LABEL: func @_QPtest_maxval_optional_scalar_mask(
! CHECK-SAME: %[[VAL_0:[^:]+]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "mask", fir.optional}
subroutine test_maxval_optional_scalar_mask(mask, array)
integer :: array(:)
logical, optional :: mask
print *, maxval(array, mask)
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{.*}} arg 1 {fortran_attrs = #fir.var_attrs<optional>,
! CHECK: %[[IS_PRESENT:.*]] = fir.is_present %[[MASK]]#0 : (!fir.ref<!fir.logical<4>>) -> i1
! CHECK: %[[EMBOX:.*]] = fir.embox %[[MASK]]#0 : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
! CHECK: %[[ABSENT:.*]] = fir.absent !fir.box<!fir.logical<4>>
! CHECK: %[[MASK_SEL:.*]] = arith.select %[[IS_PRESENT]], %[[EMBOX]], %[[ABSENT]] : !fir.box<!fir.logical<4>>
! CHECK: hlfir.maxval %{{.*}} mask %[[MASK_SEL]] {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.logical<4>>) -> i32
end subroutine
! CHECK-LABEL: func @_QPtest_maxval_optional_array_mask(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>> {fir.bindc_name = "mask", fir.optional}
subroutine test_maxval_optional_array_mask(mask, array)
integer :: array(:)
logical, optional :: mask(:)
print *, maxval(array, mask)
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{.*}} arg 1 {fortran_attrs = #fir.var_attrs<optional>,
! CHECK: %[[IS_PRESENT:.*]] = fir.is_present %[[MASK]]#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> i1
! CHECK: %[[ABSENT:.*]] = fir.absent !fir.box<!fir.array<?x!fir.logical<4>>>
! CHECK: %[[MASK_SEL:.*]] = arith.select %[[IS_PRESENT]], %[[MASK]]#1, %[[ABSENT]] : !fir.box<!fir.array<?x!fir.logical<4>>>
! CHECK: hlfir.maxval %{{.*}} mask %[[MASK_SEL]] {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
end subroutine