On Wed, Oct 14, 2026 at 9:40 AM Kewen Lin <[email protected]> wrote:
>
> 在 2026/10/14 14:08, Richard Biener 写道:
> > On Wed, Oct 14, 2026 at 3:54 AM Kewen Lin <[email protected]> wrote:
> >>
> >> 在 2026/10/13 17:08, Richard Biener 写道:
> >>> On Tue, Oct 13, 2026 at 9:50 AM Kewen Lin <[email protected]> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> When adding vector math lib support, I found trigonometric pi-based
> >>>> functions introduced by r16-710-g591d3d02664c7b are missing from
> >>>> macro SEQ_OF_CASE_MATHFN in function mathfn_built_in_2, which caused
> >>>> ICE as hanlder assumes there is a non-null function declaration but
> >>>> actually mathfn_built_in cannot map their combined_fn codes to
> >>>> type-specific builtin declarations.
> >>>>
> >>>> I think this is an oversight, so this patch is to add those
> >>>> trigonometric pi-based builtins to SEQ_OF_CASE_MATHFN, and keep
> >>>> builtin_with_linkage_p in sync as well.
> >>>>
> >>>> Bootstrapped and the regression-tested well, is it ok for trunk?
> >>>
> >>> OK.
> >>
> >> Thanks Richi, pushed as r17-5176-g10e202e107d23a.
> >>
> >> Do we want it to be backported to gcc-16 branch?
> >> If yes, is it ok to backport after burn-in time?
> >
> > Can you add a testcase then?  Then it's OK to backport.
>
> Sure, without the VML change, it seems no way to construct a test case
> for showing ICE, so I didn't include a testcase in the original patch.
> With AI's assistance, I have now constructed a testcase for the
> builtin_with_linkage_p path instead, so a follow-up patch for test
> case is listed below.  Is it ok for trunk and backporting?

OK.

> BR,
> Kewen
> -----
>
> Subject: [PATCH] testsuite: Check LTO linkage for pi-based builtins
>
> The pi-based builtins are library functions and must be recorded as
> undefined symbols in LTO object files.  Add a test that emits calls to
> all seven trigonometric pi-based function families and checks each
> symbol independently.
>
> This verifies their builtin_with_linkage_p classification and prevents
> missing LTO symbol references from changing archive and shared-library
> resolution.
>
> Assisted-by: LLM
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.dg/builtin-pi-linkage.c: New test.
>
> Signed-off-by: Kewen Lin <[email protected]>
> ---
>  gcc/testsuite/gcc.dg/builtin-pi-linkage.c | 63 +++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.dg/builtin-pi-linkage.c
>
> diff --git a/gcc/testsuite/gcc.dg/builtin-pi-linkage.c 
> b/gcc/testsuite/gcc.dg/builtin-pi-linkage.c
> new file mode 100644
> index 00000000000..93c25e4226f
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/builtin-pi-linkage.c
> @@ -0,0 +1,63 @@
> +/* { dg-do assemble } */
> +/* { dg-require-effective-target lto } */
> +/* { dg-options "-O2 -flto" } */
> +
> +/* LTO should record library references for all pi-based builtins.  */
> +
> +extern double acospi (double);
> +extern double asinpi (double);
> +extern double atan2pi (double, double);
> +extern double atanpi (double);
> +extern double cospi (double);
> +extern double sinpi (double);
> +extern double tanpi (double);
> +
> +double
> +f1 (double x)
> +{
> +  return acospi (x);
> +}
> +
> +double
> +f2 (double x)
> +{
> +  return asinpi (x);
> +}
> +
> +double
> +f3 (double x, double y)
> +{
> +  return atan2pi (x, y);
> +}
> +
> +double
> +f4 (double x)
> +{
> +  return atanpi (x);
> +}
> +
> +double
> +f5 (double x)
> +{
> +  return cospi (x);
> +}
> +
> +double
> +f6 (double x)
> +{
> +  return sinpi (x);
> +}
> +
> +double
> +f7 (double x)
> +{
> +  return tanpi (x);
> +}
> +
> +/* { dg-final { scan-symbol "acospi" } } */
> +/* { dg-final { scan-symbol "asinpi" } } */
> +/* { dg-final { scan-symbol "atan2pi" } } */
> +/* { dg-final { scan-symbol "atanpi" } } */
> +/* { dg-final { scan-symbol "cospi" } } */
> +/* { dg-final { scan-symbol "sinpi" } } */
> +/* { dg-final { scan-symbol "tanpi" } } */
> --
> 2.34.1
>

Reply via email to