* another bug
@ 1997-12-13 22:36 Ulrich Drepper
1997-12-15 20:55 ` H.J. Lu
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Drepper @ 1997-12-13 22:36 UTC (permalink / raw)
To: egcs, gcc2; +Cc: drepper
Hi,
I think I found another bug which was introduced in egcs by the gcc
2.8 merge. So this might also effect gcc 2.8. I sincerely hope that
none of my modifications to my local gcc repository caused this
problem.
I appended a preprocessed file which you must compile on ix86 using
gcc e_hypotf.i -c -O3 -g -momit-leaf-frame-pointer -fPIC
The problematic code is right at the start
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0: 83 ec 04 subl $0x4,%esp
3: 56 pushl %esi
4: 53 pushl %ebx
5: e8 00 00 00 00 call a <__ieee754_hypotf+0xa>
a: 5b popl %ebx
b: 81 c3 03 00 00 addl $0x3,%ebx
10: 00
float a,b,t1,t2,y1,y2,w;
int32_t j,k,ha,hb;
do { ieee_float_shape_type gf_u; gf_u.value = ( x ); ( ha ) =
gf_u.word; } while (0) ;
ha &= 0x7fffffff;
11: 8b 4c 24 0c movl 0xc(%esp,1),%ecx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The load in the last line loads the word at offset 12 but the stack
layout is like this:
+--------------+
| param #2 |
+--------------+
| param #1 |
+--------------+
| return addr | <---- %esp + 12
+--------------+
| <not init.> | <---------------------- created by the subl $4
+--------------+
| old %esi |
+--------------+
| old %ebx | <---- %esp
+--------------+
By some optimization the subl $4 moved before the prologue and this
kills all the parameter loading.
-- Uli
---------------. drepper at gnu.org ,-. Rubensstrasse 5
Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany
Cygnus Solutions `--' drepper at cygnus.com `------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extern __inline float __ieee754_sqrtf ( float ); extern __inline float __ieee754_sqrtf ( float __x) { register float __result; __asm __volatile__ ( "fsqrt" : "=t" (__result) : "0" (__x) ); return __result; }
typedef int int32_t __attribute__ ((__mode__ ( __SI__ ))) ;
typedef unsigned int u_int32_t __attribute__ ((__mode__ ( __SI__ ))) ;
typedef union
{
float value;
u_int32_t word;
} ieee_float_shape_type;
float __ieee754_hypotf(float x, float y)
{
float a,b,t1,t2,y1,y2,w;
int32_t j,k,ha,hb;
do { ieee_float_shape_type gf_u; gf_u.value = ( x ); ( ha ) = gf_u.word; } while (0) ;
ha &= 0x7fffffff;
do { ieee_float_shape_type gf_u; gf_u.value = ( y ); ( hb ) = gf_u.word; } while (0) ;
hb &= 0x7fffffff;
if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
do { ieee_float_shape_type sf_u; sf_u.word = ( ha ); ( a ) = sf_u.value; } while (0) ;
do { ieee_float_shape_type sf_u; sf_u.word = ( hb ); ( b ) = sf_u.value; } while (0) ;
if((ha-hb)>0xf000000) {return a+b;}
k=0;
if(ha > 0x58800000) {
if(ha >= 0x7f800000) {
w = a+b;
if(ha == 0x7f800000) w = a;
if(hb == 0x7f800000) w = b;
return w;
}
ha -= 0x5d800000; hb -= 0x5d800000; k += 60;
do { ieee_float_shape_type sf_u; sf_u.word = ( ha ); ( a ) = sf_u.value; } while (0) ;
do { ieee_float_shape_type sf_u; sf_u.word = ( hb ); ( b ) = sf_u.value; } while (0) ;
}
if(hb < 0x26800000) {
if(hb <= 0x007fffff) {
if(hb==0) return a;
do { ieee_float_shape_type sf_u; sf_u.word = ( 0x3f000000 ); ( t1 ) = sf_u.value; } while (0) ;
b *= t1;
a *= t1;
k -= 126;
} else {
ha += 0x5d800000;
hb += 0x5d800000;
k -= 60;
do { ieee_float_shape_type sf_u; sf_u.word = ( ha ); ( a ) = sf_u.value; } while (0) ;
do { ieee_float_shape_type sf_u; sf_u.word = ( hb ); ( b ) = sf_u.value; } while (0) ;
}
}
w = a-b;
if (w>b) {
do { ieee_float_shape_type sf_u; sf_u.word = ( ha&0xfffff000 ); ( t1 ) = sf_u.value; } while (0) ;
t2 = a-t1;
w = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
} else {
a = a+a;
do { ieee_float_shape_type sf_u; sf_u.word = ( hb&0xfffff000 ); ( y1 ) = sf_u.value; } while (0) ;
y2 = b - y1;
do { ieee_float_shape_type sf_u; sf_u.word = ( ha+0x00800000 ); ( t1 ) = sf_u.value; } while (0) ;
t2 = a - t1;
w = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
}
if(k!=0) {
do { ieee_float_shape_type sf_u; sf_u.word = ( 0x3f800000+(k<<23) ); ( t1 ) = sf_u.value; } while (0) ;
return t1*w;
} else return w;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: another bug
1997-12-13 22:36 another bug Ulrich Drepper
@ 1997-12-15 20:55 ` H.J. Lu
1997-12-16 7:35 ` Ulrich Drepper
0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 1997-12-15 20:55 UTC (permalink / raw)
To: drepper; +Cc: egcs
>
> Hi,
>
> I think I found another bug which was introduced in egcs by the gcc
> 2.8 merge. So this might also effect gcc 2.8. I sincerely hope that
> none of my modifications to my local gcc repository caused this
> problem.
>
It looks like an egcs bug since gcc 2.8.0 is ok. Here is
the output.
H.J.
---
.file "e_hypotf.i"
.version "01.01"
/ GNU C version 2.8.0 (i586-unknown-linux-gnulibc1) compiled by GNU C version 2.8.0.
/ options passed: -momit-leaf-frame-pointer -O3 -fPIC
/ options enabled: -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps
/ -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
/ -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse
/ -finline-functions -finline -fkeep-static-consts -fcaller-saves
/ -fpcc-struct-return -frerun-cse-after-loop -fschedule-insns2 -fPIC
/ -fcommon -fverbose-asm -fgnu-linker -m80387 -mhard-float -mno-soft-float
/ -mieee-fp -mfp-ret-in-387 -momit-leaf-frame-pointer -mschedule-prologue
/ -mcpu=pentium -march=pentium
gcc2_compiled.:
.section .rodata
.align 4
.LC0:
.long 0x3f000000
.text
.align 4
.globl __ieee754_hypotf
.type __ieee754_hypotf,@function
__ieee754_hypotf:
pushl %esi
pushl %ebx
call .L81
.L81:
popl %ebx
addl $_GLOBAL_OFFSET_TABLE_+[.-.L81],%ebx
movl 8(%esp),%ecx
andl $2147483647,%ecx
movl 12(%esp),%edx
andl $2147483647,%edx
cmpl %ecx,%edx
jle .L12
movl %ecx,%eax
movl %edx,%ecx
movl %eax,%edx
.L12:
pushl %ecx
flds (%esp)
addl $4,%esp
pushl %edx
flds (%esp)
addl $4,%esp
movl %ecx,%eax
subl %edx,%eax
cmpl $251658240,%eax
jle .L21
faddp %st,%st(1)
jmp .L72
.align 4
.L21:
xorl %esi,%esi
cmpl $1484783616,%ecx
jle .L22
cmpl $2139095039,%ecx
jle .L76
fld %st(1)
fadd %st(1),%st
cmpl $2139095040,%ecx
jne .L77
fstp %st(0)
jmp .L24
.align 4
.L77:
fstp %st(2)
.L24:
cmpl $2139095040,%edx
jne .L80
fstp %st(1)
jmp .L72
.align 4
.L76:
fstp %st(0)
fstp %st(0)
addl $-1568669696,%ecx
addl $-1568669696,%edx
movl $60,%esi
pushl %ecx
flds (%esp)
addl $4,%esp
pushl %edx
flds (%esp)
addl $4,%esp
.L22:
cmpl $645922815,%edx
jg .L34
cmpl $8388607,%edx
jg .L79
testl %edx,%edx
je .L80
flds .LC0@GOTOFF(%ebx)
fmul %st,%st(1)
addl $-126,%esi
fmulp %st,%st(2)
jmp .L34
.align 4
.L79:
fstp %st(0)
fstp %st(0)
addl $1568669696,%ecx
addl $1568669696,%edx
addl $-60,%esi
pushl %ecx
flds (%esp)
addl $4,%esp
pushl %edx
flds (%esp)
addl $4,%esp
.L34:
fld %st(1)
fsub %st(1),%st
fcom %st(1)
fnstsw %ax
andb $69,%ah
jne .L50
fstp %st(0)
movl %ecx,%eax
andl $-4096,%eax
pushl %eax
flds (%esp)
addl $4,%esp
fld %st(2)
fld %st(2)
fchs
fxch %st(1)
fsub %st(2),%st
fxch %st(4)
fadd %st(2),%st
fxch %st(1)
fmulp %st,%st(3)
fmulp %st,%st(3)
fld %st(0)
fmulp %st,%st(1)
fxch %st(1)
fsubp %st,%st(2)
fsubp %st,%st(1)
jmp .L75
.align 4
.L50:
fxch %st(2)
fadd %st(0),%st
movl %edx,%eax
andl $-4096,%eax
pushl %eax
flds (%esp)
addl $4,%esp
fld %st(2)
fsub %st(1),%st
leal 8388608(%ecx),%eax
pushl %eax
flds (%esp)
addl $4,%esp
fld %st(0)
fmulp %st,%st(3)
fmul %st,%st(1)
fsubrp %st,%st(3)
fld %st(4)
fchs
fxch %st(3)
fmulp %st,%st(4)
fxch %st(2)
fmulp %st,%st(4)
fxch %st(1)
faddp %st,%st(2)
fxch %st(2)
fsubp %st,%st(1)
fsubrp %st,%st(1)
.L75:
#APP
fsqrt
#NO_APP
testl %esi,%esi
je .L72
movl %esi,%eax
sall $23,%eax
addl $1065353216,%eax
pushl %eax
flds (%esp)
addl $4,%esp
fmulp %st,%st(1)
jmp .L72
.align 4
.L80:
fstp %st(0)
.L72:
popl %ebx
popl %esi
ret
.Lfe1:
.size __ieee754_hypotf,.Lfe1-__ieee754_hypotf
.ident "GCC: (GNU) 2.8.0"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: another bug
1997-12-15 20:55 ` H.J. Lu
@ 1997-12-16 7:35 ` Ulrich Drepper
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 1997-12-16 7:35 UTC (permalink / raw)
To: H.J. Lu; +Cc: egcs
hjl@lucon.org (H.J. Lu) writes:
> It looks like an egcs bug since gcc 2.8.0 is ok. Here is
> the output.
I haven't looked at the code closely enough but if you reference the
report I sent you can forget it. The current egcs with the few
patches sent to the list should have fixed all problems. If Jeff
thinks he has integrated all patches and you still see a problem I can
examine where my source tree differs.
-- Uli
---------------. drepper at gnu.org ,-. Rubensstrasse 5
Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany
Cygnus Solutions `--' drepper at cygnus.com `------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-12-16 7:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-13 22:36 another bug Ulrich Drepper
1997-12-15 20:55 ` H.J. Lu
1997-12-16 7:35 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).