[PATCH] Optimize sin(atan(x)) and cos(atan(x)), take 3 (PR tree-optimization/86829)

Christophe Lyon christophe.lyon@linaro.org
Fri Oct 12 08:21:00 GMT 2018


On Thu, 11 Oct 2018 at 23:07, Jeff Law <law@redhat.com> wrote:
>
> On 10/9/18 5:29 PM, Giuliano Augusto Faulin Belinassi wrote:
> > Fixed all issues pointed in the previous iteration.
> > There is now a significant change regarding how the sin(atan(x))
> > constant is calculated, as now it checks for which values such that
> > computing 1 + x*x won't overflow. There are two reasons for this
> > change: (1) Avoid an intermediate infinity value when optimizing
> > cos(atan(x)), and (2) avoid the requirement of separate constants for
> > sin(atan(x)) and cos(atan(x)), thus making easier to maintain the
> > code.
> >
> > gcc/ChangeLog
> >
> > 2018-10-09  Giuliano Belinassi  <giuliano.belinassi@usp.br>
> >
> >     PR tree-optimization/86829
> >     * match.pd: Added sin(atan(x)) and cos(atan(x)) simplification rules.
> >     * real.c (build_sinatan_real): New function to build a constant equal to the
> >     largest value c such that 1 + c*c will not overflow.
> >     * real.h (build_sinatan_real): Allows this function to be called externally.
> >
> > gcc/testsuite/gcc.dg/ChangeLog
> >
> > 2018-10-09  Giuliano Belinassi  <giuliano.belinassi@usp.br>
> >
> >     PR tree-optimization/86829
> >     * gcc.dg/sinatan-1.c: New test.
> >     * gcc.dg/sinatan-2.c: New test.
> >     * gcc.dg/sinatan-3.c: New test.
> >
> > There are no tests broken in trunk that seems related to this PR.
> THanks.  I've installed this onto the trunk.  It's right at the
> borderline of what would require a copyright assignment.  So if you're
> going to do further work on GCC you should go ahead and start the
> copyright assignment process.
>
> Jeff

Hi!

The new sinatan-1.c test fails to link against newlib on aarch64-elf:
/tmp/ccmp5fP4.o: In function `sinatanl':
sinatan-1.c:(.text+0x68): undefined reference to `atanl'
sinatan-1.c:(.text+0x70): undefined reference to `sinl'
/tmp/ccmp5fP4.o: In function `cosatanl':
sinatan-1.c:(.text+0x80): undefined reference to `atanl'
sinatan-1.c:(.text+0x88): undefined reference to `cosl'
collect2: error: ld returned 1 exit status

I'm not familiar enough with newlib to know if it's a newlib bug, or
if we should skip the test?

On arm-eabi, the same test fails at runtime, but I haven't yet taken
the time to reproduce it manually.

Christophe



More information about the Gcc-patches mailing list