[all-commits] [llvm/llvm-project] 06789c: [libclc] Optimize ceil/fabs/floor/rint/trunc (#119...
Fraser Cormack via All-commits
all-commits at lists.llvm.org
Fri Dec 13 00:47:36 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 06789ccb1695214f787cd471a300522973d33375
https://github.com/llvm/llvm-project/commit/06789ccb1695214f787cd471a300522973d33375
Author: Fraser Cormack <fraser at codeplay.com>
Date: 2024-12-13 (Fri, 13 Dec 2024)
Changed paths:
M libclc/clc/include/clc/clcmacro.h
M libclc/clc/include/clc/math/clc_ceil.h
M libclc/clc/include/clc/math/clc_fabs.h
M libclc/clc/include/clc/math/clc_floor.h
M libclc/clc/include/clc/math/clc_rint.h
M libclc/clc/include/clc/math/clc_trunc.h
A libclc/clc/include/clc/math/unary_builtin.inc
M libclc/clc/lib/clspv/SOURCES
R libclc/clc/lib/clspv/dummy.cl
M libclc/clc/lib/generic/SOURCES
A libclc/clc/lib/generic/math/clc_ceil.cl
A libclc/clc/lib/generic/math/clc_fabs.cl
A libclc/clc/lib/generic/math/clc_floor.cl
A libclc/clc/lib/generic/math/clc_rint.cl
A libclc/clc/lib/generic/math/clc_trunc.cl
M libclc/clc/lib/spirv/SOURCES
M libclc/clc/lib/spirv64/SOURCES
M libclc/generic/lib/math/ceil.cl
M libclc/generic/lib/math/fabs.cl
M libclc/generic/lib/math/floor.cl
M libclc/generic/lib/math/rint.cl
M libclc/generic/lib/math/round.cl
M libclc/generic/lib/math/sqrt.cl
M libclc/generic/lib/math/trunc.cl
R libclc/generic/lib/math/unary_builtin.inc
Log Message:
-----------
[libclc] Optimize ceil/fabs/floor/rint/trunc (#119596)
These functions all map to the corresponding LLVM intrinsics, but the
vector intrinsics weren't being generated. The intrinsic mapping from
CLC vector function to vector intrinsic was working correctly, but the
mapping from OpenCL builtin to CLC function was suboptimally recursively
splitting vectors in halves.
For example, with this change, `ceil(float16)` calls `llvm.ceil.v16f32`
directly once optimizations are applied.
Now also, instead of generating LLVM intrinsics through `__asm` we now
call clang elementwise builtins for each CLC builtin. This should be a
more standard way of achieving the same result
The CLC versions of each of these builtins are also now built and
enabled for SPIR-V targets. The LLVM -> SPIR-V translator maps the
intrinsics to the appropriate OpExtInst, so there should be no
difference in semantics, despite the newly introduced indirection from
OpenCL builtin through the CLC builtin to the intrinsic.
The AMDGPU targets make use of the same `_CLC_DEFINE_UNARY_BUILTIN`
macro to override `sqrt`, so those functions also appear more optimal
with this change, calling the vector `llvm.sqrt.vXf32` intrinsics
directly.
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