This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/13240] _Qp_itoq produces wrong value on Linux/SPARC64
- From: "bruno at clisp dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Fri, 07 Oct 2011 22:56:16 +0000
- Subject: [Bug libc/13240] _Qp_itoq produces wrong value on Linux/SPARC64
- Auto-submitted: auto-generated
- References: <bug-13240-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=13240
--- Comment #5 from Bruno Haible <bruno at clisp dot org> 2011-10-07 22:56:16 UTC ---
The machine on which this is happening is gcc54.fsffrance.org.
CPU is:
$ cat /proc/cpuinfo
cpu : TI UltraSparc IIe (Hummingbird)
fpu : UltraSparc IIe integrated FPU
prom : OBP 4.0.12 2002/01/08 13:01
type : sun4u
ncpus probed : 1
ncpus active : 1
D$ parity tl1 : 0
I$ parity tl1 : 0
Cpu0ClkTck : 000000001dcd6500
MMU Type : Spitfire
Maybe you can understand the disassembly of main() and _Qp_itoq.
$ gcc -m64 -Wall -O2 bug.c -S
$ cat bug.s
.file "bug.c"
.global _Qp_itoq
.global _Qp_mul
.global _Qp_add
.global _Qp_itoq
.global _Qp_mul
.global _Qp_add
.section .rodata.str1.8,"aMS",@progbits,1
.align 8
.LLC0:
.asciz "lla=%Lg, llb=%Lg\n"
.section ".text"
.align 4
.align 32
.global main
.type main, #function
.proc 04
main:
.register %g2, #scratch
.register %g3, #scratch
save %sp, -304, %sp
sethi %hi(a), %g1
add %fp, 2015, %i1
lduw [%g1+%lo(a)], %o1
sethi %hi(lla), %l1
sethi %hi(ll), %g1
mov %i1, %o0
ldx [%g1+%lo(ll)], %l4
add %fp, 1999, %i2
ldx [%g1+%lo(ll+8)], %l5
add %fp, 1983, %i4
add %fp, 1967, %i3
ldx [%l1+%lo(lla)], %l2
add %fp, 1951, %l6
add %fp, 1935, %l7
ldx [%l1+%lo(lla+8)], %l3
add %fp, 1919, %i5
call _Qp_itoq, 0
sethi %hi(llb), %l0
stx %l4, [%fp+1967]
ldx [%fp+2015], %g2
mov %i2, %o0
mov %i4, %o1
ldx [%fp+2023], %g3
mov %i3, %o2
mov 0, %i0
stx %g2, [%fp+1983]
stx %g3, [%fp+1991]
call _Qp_mul, 0
stx %l5, [%fp+1975]
stx %l2, [%fp+1919]
ldx [%fp+1999], %g2
mov %i5, %o2
mov %l6, %o0
ldx [%fp+2007], %g3
mov %l7, %o1
stx %g2, [%fp+1935]
stx %g3, [%fp+1943]
call _Qp_add, 0
stx %l3, [%fp+1927]
ldx [%fp+1951], %g2
sethi %hi(b), %g1
mov %i1, %o0
ldx [%fp+1959], %g3
stx %g2, [%l1+%lo(lla)]
lduw [%g1+%lo(b)], %o1
stx %g3, [%l1+%lo(lla+8)]
ldx [%l0+%lo(llb)], %l2
ldx [%l0+%lo(llb+8)], %l3
call _Qp_itoq, 0
nop
stx %l4, [%fp+1983]
ldx [%fp+2015], %g2
mov %i2, %o0
mov %i4, %o1
ldx [%fp+2023], %g3
mov %i3, %o2
stx %g2, [%fp+1967]
stx %g3, [%fp+1975]
call _Qp_mul, 0
stx %l5, [%fp+1991]
stx %l2, [%fp+1919]
ldx [%fp+1999], %g2
mov %l6, %o0
mov %i5, %o2
ldx [%fp+2007], %g3
mov %l7, %o1
stx %g2, [%fp+1935]
stx %g3, [%fp+1943]
call _Qp_add, 0
stx %l3, [%fp+1927]
ldx [%fp+1951], %g2
sethi %hi(.LLC0), %o0
ldx [%fp+1959], %g3
or %o0, %lo(.LLC0), %o0
stx %g2, [%l0+%lo(llb)]
stx %g3, [%l0+%lo(llb+8)]
ldx [%l1+%lo(lla)], %o2
ldx [%l1+%lo(lla+8)], %o3
ldx [%l0+%lo(llb)], %o4
ldx [%l0+%lo(llb+8)], %o5
call printf, 0
nop
return %i7+8
nop
.size main, .-main
.global a
.section ".data"
.align 4
.type a, #object
.size a, 4
a:
.long 1
.global b
.align 4
.type b, #object
.size b, 4
b:
.long -1
.global ll
.align 16
.type ll, #object
.size ll, 16
ll:
.long 1073765360
.long -1464777360
.long 930009367
.long 539791195
.common lla,16,16
.common llb,16,16
.ident "GCC: (Debian 4.3.2-1.1) 4.3.2"
.section ".note.GNU-stack"
$ gcc -m64 -Wall -O2 bug.c -static
$ ./a.out
lla=2.71828, llb=1.16749e+10
$ objdump --disassemble a.out > a.disasm
Excerpt of a.disasm:
000000000010cca0 <_Qp_itoq>:
10cca0: 9d e3 bf 40 save %sp, -192, %sp
10cca4: 84 10 20 00 clr %g2
10cca8: 9a 10 20 00 clr %o5
10ccac: 98 10 20 00 clr %o4
10ccb0: 02 ce 40 1b brz %i1, 10cd1c <_Qp_itoq+0x7c>
10ccb4: 8c 10 20 00 clr %g6
10ccb8: a1 36 70 3f srlx %i1, 0x3f, %l0
10ccbc: 82 20 00 19 neg %i1, %g1
10ccc0: 83 7c 04 19 movre %l0, %i1, %g1
10ccc4: b3 30 60 00 srl %g1, 0, %i1
10ccc8: 40 01 71 2e call 169180 <__clzdi2>
10cccc: 90 10 00 19 mov %i1, %o0
10ccd0: 07 00 00 10 sethi %hi(0x4000), %g3
10ccd4: 05 00 40 6f sethi %hi(0x101bc00), %g2
10ccd8: 8b 30 b0 0a srlx %g2, 0xa, %g5
10ccdc: 82 10 e0 3e or %g3, 0x3e, %g1
10cce0: 82 20 40 08 sub %g1, %o0, %g1
10cce4: 89 38 60 00 sra %g1, 0, %g4
10cce8: 84 21 40 04 sub %g5, %g4, %g2
10ccec: 80 a0 a0 3f cmp %g2, 0x3f
10ccf0: 04 60 00 24 ble,pn %xcc, 10cd80 <_Qp_itoq+0xe0>
10ccf4: 82 10 e0 2f or %g3, 0x2f, %g1
10ccf8: 05 3f ff e0 sethi %hi(0xffff8000), %g2
10ccfc: 82 20 40 04 sub %g1, %g4, %g1
10cd00: 98 29 00 02 andn %g4, %g2, %o4
10cd04: 9b 2e 50 01 sllx %i1, %g1, %o5
10cd08: 82 10 3f ff mov -1, %g1
10cd0c: 83 30 70 10 srlx %g1, 0x10, %g1
10cd10: 8c 10 00 10 mov %l0, %g6
10cd14: 9a 0b 40 01 and %o5, %g1, %o5
10cd18: 84 10 20 00 clr %g2
10cd1c: 88 10 3f ff mov -1, %g4
10cd20: c6 5e 00 00 ldx [ %i0 ], %g3
10cd24: 8c 09 a0 ff and %g6, 0xff, %g6
10cd28: 8b 29 30 30 sllx %g4, 0x30, %g5
10cd2c: c4 76 20 08 stx %g2, [ %i0 + 8 ]
10cd30: 83 31 30 10 srlx %g4, 0x10, %g1
10cd34: 86 08 c0 05 and %g3, %g5, %g3
10cd38: 85 31 30 31 srlx %g4, 0x31, %g2
10cd3c: 82 0b 40 01 and %o5, %g1, %g1
10cd40: 86 10 c0 01 or %g3, %g1, %g3
10cd44: 03 00 7f ff sethi %hi(0x1fffc00), %g1
10cd48: 83 28 70 26 sllx %g1, 0x26, %g1
10cd4c: 84 08 80 0c and %g2, %o4, %g2
10cd50: 85 28 b0 30 sllx %g2, 0x30, %g2
10cd54: 82 28 c0 01 andn %g3, %g1, %g1
10cd58: 89 31 30 01 srlx %g4, 1, %g4
10cd5c: 82 10 40 02 or %g1, %g2, %g1
10cd60: 8d 29 b0 3f sllx %g6, 0x3f, %g6
10cd64: 82 08 40 04 and %g1, %g4, %g1
10cd68: 82 10 40 06 or %g1, %g6, %g1
10cd6c: c2 76 00 00 stx %g1, [ %i0 ]
10cd70: bf b0 0c 00 fzero %f62
10cd74: bf a7 c8 5f faddd %f62, %f62, %f62
10cd78: 81 cf e0 08 rett %i7 + 8
10cd7c: 01 00 00 00 nop
10cd80: 82 01 20 11 add %g4, 0x11, %g1
10cd84: 05 3f ff e0 sethi %hi(0xffff8000), %g2
10cd88: 9b 36 50 01 srlx %i1, %g1, %o5
10cd8c: 82 10 3f ff mov -1, %g1
10cd90: 86 21 40 04 sub %g5, %g4, %g3
10cd94: 98 29 00 02 andn %g4, %g2, %o4
10cd98: 83 30 70 10 srlx %g1, 0x10, %g1
10cd9c: 8c 10 00 10 mov %l0, %g6
10cda0: 85 2e 50 03 sllx %i1, %g3, %g2
10cda4: 10 6f ff de b %xcc, 10cd1c <_Qp_itoq+0x7c>
10cda8: 9a 0b 40 01 and %o5, %g1, %o5
10cdac: 30 68 00 05 b,a %xcc, 10cdc0 <_Qp_itoq+0x120>
10cdb0: 01 00 00 00 nop
10cdb4: 01 00 00 00 nop
10cdb8: 01 00 00 00 nop
10cdbc: 01 00 00 00 nop
10cdc0: 00 10 d0 90 illtrap 0x10d090
10cdc4: 00 10 d6 48 illtrap 0x10d648
10cdc8: 00 10 d6 48 illtrap 0x10d648
10cdcc: 00 10 d6 34 illtrap 0x10d634
10cdd0: 00 10 d5 60 illtrap 0x10d560
10cdd4: 00 10 d5 60 illtrap 0x10d560
10cdd8: 00 10 d4 c0 illtrap 0x10d4c0
10cddc: 00 10 d6 34 illtrap 0x10d634
10cde0: 00 10 d5 60 illtrap 0x10d560
10cde4: 00 10 d4 c0 illtrap 0x10d4c0
10cde8: 00 10 d5 60 illtrap 0x10d560
10cdec: 00 10 d6 34 illtrap 0x10d634
10cdf0: 00 10 d6 08 illtrap 0x10d608
10cdf4: 00 10 d6 08 illtrap 0x10d608
10cdf8: 00 10 d6 08 illtrap 0x10d608
10cdfc: 00 10 d5 d0 illtrap 0x10d5d0
$ gcc -v
Using built-in specs.
Target: sparc-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --with-cpu=v8 --with-long-double-128
--enable-checking=release --build=sparc-linux-gnu --host=sparc-linux-gnu
--target=sparc-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1)
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.