[libc-commits] [libc] [libc][GPU] Remove code duplicate in GPU math functions (PR #241177)
via libc-commits
libc-commits at lists.llvm.org
Wed Nov 11 19:04:30 PST 2026
jinge90 wrote:
> > > This isn't exactly a GPU property. I wish we had a better answer for how to emit the intrinsics from libc
> >
> >
> > Do you mean using built-in functions is not a reliable way for GPU devices, different GPU may have different way to name intrinsics which has similar functionalities(**nv**, **ocl** or __spirv_*).
>
> No, I very much want to stop using those vendor functions. I mean these are defining the libm function in terms of a builtin defined as emitting a call to the libm function with the same name. It only happens to work out if clang emits the IR intrinsic instead of the direct libcall, and codegen can deal with the intrinsic through a not-libcall codegen path
Hi, @arsenm
Got it, your concern does make sense and I encountered similar issue when enabling libc math function for SPIR-V targets locally. The code can still build pass if the corresponding built-in is converted into a library call with same name and runtime failure will happen on GPU, so I had to manually check the IR to filter out such functions.
Is it acceptable to check such behavior in clang when building for GPU targets? Even some warnings that telling the used built-in is converted into a libcall on current GPU target can be helpful to catch such issues in compilation time.
Thanks very much.
https://github.com/llvm/llvm-project/pull/241177
More information about the libc-commits
mailing list