https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89125

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Jan 30, 2019 at 08:06:44PM +0000, dominiq at lps dot ens.fr wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89125
> 
> --- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> See pr31249.
> 

Don't see the relevance in that I'm not advocating that
the middle-end transform the sin(x), cos(x) pair into a
complex function cexpi.

function foo(x)
 complex foo
 real,intent(in) :: x
 foo = cmplx(cos(x),sin(x))
end

 gfcx -o - -S -O3 a.f90
        .file   "a.f90"
        .text
        .p2align 4
        .globl  foo_
        .type   foo_, @function
foo_:
.LFB0:
        .cfi_startproc
        subq    $24, %rsp
        .cfi_def_cfa_offset 32
        movss   (%rdi), %xmm2
        movaps  %xmm2, %xmm0
        movss   %xmm2, 4(%rsp)
        call    cosf
        movss   4(%rsp), %xmm2
        movss   %xmm0, (%rsp)
        movaps  %xmm2, %xmm0
        call    sinf
        movss   (%rsp), %xmm1
        movss   %xmm0, 12(%rsp)
        movss   %xmm1, 8(%rsp)
        movq    8(%rsp), %xmm0
        addq    $24, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc
.LFE0:
        .size   foo_, .-foo_
        .ident  "GCC: (GNU) 9.0.1 20190125 (experimental)"
        .section        .note.GNU-stack,"",@progbits

On FreeBSD and suspect with glibc, there is a clear win

Single precision, 100M calls for x in [0, 20000)
 ./testf -s -n 100 -m 0 -M 20000
100M sincosf calls in 4.235 seconds.
100M sinf and 100M cosf calls in 5.330 seconds.

Double precision, 100M calls for x in [0, 20000)
./testd -s -n 100 -m 0 -M 20000
100M sincos calls in 5.222 seconds.
100M sin and 100M cos calls in 8.105 seconds.

Reply via email to