Gcc46 and 128 Bit Floating Point
Steve Kargl
sgk at troutmask.apl.washington.edu
Wed Feb 29 04:46:03 UTC 2012
On Tue, Feb 28, 2012 at 08:03:36PM -0800, Thomas D. Dean wrote:
> On 02/17/12 13:03, Thomas D. Dean wrote:
>
> Or, am I missing something?
I think the answer to you question is 'maybe'.
> #include <quadmath.h>
> #include <stdio.h>
> int main() {
> char buf[128];
> __float128 x = sqrtq(2.0Q);
> quadmath_snprintf(buf, sizeof buf, "%.45Qf",x);
> printf("sin(%s) = ",buf);
> quadmath_snprintf(buf, sizeof buf, "%.45Qf",sinq(x));
> printf("%s\n",buf);
> return 0;
> }
>
> gcc46 math.c -o math /usr/local/lib/gcc46/libquadmath.a /usr/lib/libm.a
You probably want to add -O here.
> Looking at the output of objdump -d math shows software implementation
> of sqrtq() and sinq(). gcc46 does use the fsqrt instruction but not fsin.
Huh? gcc46 -S gives
.file "a.c"
.section .rodata
.LC1:
.string "%.45Qf"
.LC2:
.string "sin(%s) = "
.text
.globl main
.type main, @function
main:
.LFB4:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $144, %rsp
movdqa .LC0(%rip), %xmm0
call sqrtq
movdqa %xmm0, -16(%rbp)
movdqa -16(%rbp), %xmm0
leaq -144(%rbp), %rax
movl $.LC1, %edx
movl $128, %esi
movq %rax, %rdi
movl $1, %eax
call quadmath_snprintf
leaq -144(%rbp), %rax
movq %rax, %rsi
movl $.LC2, %edi
movl $0, %eax
call printf
movdqa -16(%rbp), %xmm0
call sinq
leaq -144(%rbp), %rax
movl $.LC1, %edx
movl $128, %esi
movq %rax, %rdi
movl $1, %eax
call quadmath_snprintf
leaq -144(%rbp), %rax
movq %rax, %rdi
call puts
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE4:
.size main, .-main
.section .rodata
.align 16
.LC0:
.long 0
.long 0
.long 0
.long 1073741824
.ident "GCC: (FreeBSD Ports Collection) 4.6.2"
I don't see fsqrt.
--
Steve
More information about the freebsd-amd64
mailing list