[all-commits] [llvm/llvm-project] 586cac: [libclc] Optimize generic CLC fmin/fmax (#128506)
Fraser Cormack via All-commits
all-commits at lists.llvm.org
Tue Jul 29 05:22:04 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 586cacdbdd995d2a2f010f7152843745f4978b4b
https://github.com/llvm/llvm-project/commit/586cacdbdd995d2a2f010f7152843745f4978b4b
Author: Fraser Cormack <fraser at codeplay.com>
Date: 2025-07-29 (Tue, 29 Jul 2025)
Changed paths:
M libclc/clc/lib/amdgcn/SOURCES
R libclc/clc/lib/amdgcn/math/clc_fmax.cl
R libclc/clc/lib/amdgcn/math/clc_fmin.cl
M libclc/clc/lib/generic/math/clc_fmax.cl
M libclc/clc/lib/generic/math/clc_fmin.cl
M libclc/clc/lib/r600/SOURCES
R libclc/clc/lib/r600/math/clc_fmax.cl
R libclc/clc/lib/r600/math/clc_fmin.cl
M libclc/clc/lib/spirv/SOURCES
A libclc/clc/lib/spirv/math/clc_fmax.cl
A libclc/clc/lib/spirv/math/clc_fmin.cl
Log Message:
-----------
[libclc] Optimize generic CLC fmin/fmax (#128506)
With this commit, the CLC fmin/fmax builtins use clang's
__builtin_elementwise_(min|max)imumnum which helps us generate LLVM
minimumnum/maximumnum intrinsics directly. These intrinsics uniformly
select the non-NaN input over the (quiet or signalling) NaN input, which
corresponds to what the OpenCL CTS tests.
These intrinsics maintain the vector types, as opposed to scalarizing,
which was previously happening. This commit therefore helps to optimize
codegen for those targets.
Note that there is ongoing discussion regarding how these builtins
should handle signalling NaNs in the OpenCL specification and whether
they should be able to return a quiet NaN as per the IEEE behaviour. If
the specification and/or CTS is ever updated to allow or mandate
returning a qNAN, these builtins could/should be updated to use
__builtin_elementwise_(min|max)num instead which would lower to LLVM
minnum/maxnum intrinsics.
The SPIR-V targets maintain the old implementations, as the LLVM ->
SPIR-V translator can't currently handle the LLVM intrinsics. The
implementation has been simplifies to consistently use clang builtins,
as opposed to before where the half version was explicitly defined.
[1] https://github.com/KhronosGroup/OpenCL-CTS/pull/2285
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list