Skip to content

Commit

Permalink
Delete libpgmath veclib definitions for sincos
Browse files Browse the repository at this point in the history
As noted in #11, flang currently crashes when lowering
a sincos reference into a libpgmath runtime function call. The issue is
that `__fd_sincos_1` is defined as returning a `<{ double, double }>`
struct and there is no LLVM support for automatically vectorizing target
functions of this form. In particular, it is somewhat ambiguous how to
vectorize such functions, i.e. how they pack their return values into the
vector registers. libpgmath itself also has a somewhat questionable
implementation of the vector forms of `sincos`, relying on this beauty:

https://github.com/flang-compiler/flang/blob/master/runtime/libpgmath/lib/common/mth_vreturns.c#L8-L47

This may sometimes work in practice, but it is not particularly
robust. For example, this will definitely break in any sort of LTO or
instrumentation setting.

I think until libpgmath is updated and LLVM upstream has a consensus on
how to vectorize these functions, we just need to stop trying to vectorize
these functions. As noted, since LLVM was crashing anyway, no performance
and functionality is lost here over current master.

Fixes #11.

Originally By: Keno Fischer <keno@juliacomputing.com>
  • Loading branch information
gbaraldi authored and bryanpkc committed Oct 18, 2023
1 parent dc4997c commit 410b76b
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions llvm/include/llvm/Analysis/VecFuncs.def
Original file line number Diff line number Diff line change
Expand Up @@ -1131,30 +1131,6 @@ TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_8", FIXED(8))
TLI_DEFINE_VECFUNC("__rs_cos_1", "__rs_cos_16", FIXED(16))

TLI_DEFINE_VECFUNC("__fd_sincos_1", "__fd_sincos_2", FIXED(2))
TLI_DEFINE_VECFUNC("__fd_sincos_1", "__fd_sincos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__fd_sincos_1", "__fd_sincos_8", FIXED(8))

TLI_DEFINE_VECFUNC("__fs_sincos_1", "__fs_sincos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__fs_sincos_1", "__fs_sincos_8", FIXED(8))
TLI_DEFINE_VECFUNC("__fs_sincos_1", "__fs_sincos_16", FIXED(16))

TLI_DEFINE_VECFUNC("__pd_sincos_1", "__pd_sincos_2", FIXED(2))
TLI_DEFINE_VECFUNC("__pd_sincos_1", "__pd_sincos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__pd_sincos_1", "__pd_sincos_8", FIXED(8))

TLI_DEFINE_VECFUNC("__ps_sincos_1", "__ps_sincos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__ps_sincos_1", "__ps_sincos_8", FIXED(8))
TLI_DEFINE_VECFUNC("__ps_sincos_1", "__ps_sincos_16", FIXED(16))

TLI_DEFINE_VECFUNC("__rd_sincos_1", "__rd_sincos_2", FIXED(2))
TLI_DEFINE_VECFUNC("__rd_sincos_1", "__rd_sincos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__rd_sincos_1", "__rd_sincos_8", FIXED(8))

TLI_DEFINE_VECFUNC("__rs_sincos_1", "__rs_sincos_4", FIXED(4))
TLI_DEFINE_VECFUNC("__rs_sincos_1", "__rs_sincos_8", FIXED(8))
TLI_DEFINE_VECFUNC("__rs_sincos_1", "__rs_sincos_16", FIXED(16))

TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_2", FIXED(2))
TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_4", FIXED(4))
TLI_DEFINE_VECFUNC("__fd_tan_1", "__fd_tan_8", FIXED(8))
Expand Down

0 comments on commit 410b76b

Please sign in to comment.