https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64020
--- Comment #2 from dmalcolm at gcc dot gnu.org --- For reference, both at -O3, based on r217939: ./cc1 of #include <math.h> int test_of_builtin_trig (double theta) { return 2 * sin (theta) * cos (theta); } generates: test_of_builtin_trig: .LFB3: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 leaq 8(%rsp), %rdi movq %rsp, %rsi call sincos movsd 8(%rsp), %xmm0 addsd %xmm0, %xmm0 mulsd (%rsp), %xmm0 addq $24, %rsp .cfi_def_cfa_offset 8 cvttsd2si %xmm0, %eax ret .cfi_endproc [would it be even better to optimize this to just a sin (2 * theta) ?] whereas the jit test generates: test_of_builtin_trig: .LFB32: .cfi_startproc .LVL4: .L37: subq $24, %rsp .cfi_def_cfa_offset 32 movsd %xmm0, 8(%rsp) call sin@PLT .LVL5: movsd 8(%rsp), %xmm1 movsd %xmm0, (%rsp) movapd %xmm1, %xmm0 call cos@PLT .LVL6: mulsd (%rsp), %xmm0 addq $24, %rsp .cfi_def_cfa_offset 8 addsd %xmm0, %xmm0 ret .cfi_endproc