[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 20:21:47 PST 2026


jinge90 wrote:

> > > I think some duplication is fine here, the math functions are ordered per architecture so I'd rather keep that straightforward than save the bytes.
> > 
> > 
> > Hi, @jhuber6 Got it, I will close this PR. By the way, during my testing with Intel GPU for spirv, I found currently amd and nv both used __builtin_remainder/f to implement remainder/f function. However, this builtin is not converted to llvm intrinsic, in LLVM IR level(llvm-dis libm.bc), it is:
> > ```llvm
> > ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
> > define hidden noundef double @remainder(double %0, double %1) #0 !guid !465 {
> >   ret double undef
> > }
> > ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
> > define hidden noundef float @remainderf(float %0, float %1) #0 !guid !466 {
> >   ret float undef
> > }
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > It looks like can't work. My testing reports runtime error on Intel GPU but didn't try AMD and NV devices. Thanks very much.
> 
> Yeah the way builtins are handles is incredibly arbitrary. If they don't lower to something meaningful we should delete them and fall back to the generic implementation.

Hi, @jhuber6 
A fix is in: https://github.com/llvm/llvm-project/pull/241657
Could you take a look when having time?
Thanks very much.

https://github.com/llvm/llvm-project/pull/241177


More information about the libc-commits mailing list