* another IEE related problem @ 1997-11-19 19:21 Ulrich Drepper 1997-12-10 3:32 ` Bernd Schmidt 0 siblings, 1 reply; 6+ messages in thread From: Ulrich Drepper @ 1997-11-19 19:21 UTC (permalink / raw) To: egcs Hi, Compiling this little piece of code on a ix86 machine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ extern inline float bar (float x) { float res; asm ("fsqrt" : "=t" (res) : "0" (x)); return res; } extern float fabsf (float); float foo (float x) { float res = fabsf (bar (x)); return res; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The generated code with -O3 -momit-leaf-frame-pointer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foo: flds 4(%esp) #APP fsqrt #NO_APP ret ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is wrong. In the real code I added the `fabs' in full knowledge of the situation. The problem is that according to IEEE sqrt(-0.0) == -0.0 and so I get a wrong result. I don't know why gcc thinks the fabs call is redundant (it should not be able to analyze the asm statement) but in any case it is plainly wrong. Another bug preventing the glibc test suite to be passed. -- Uli ---------------. drepper at gnu.org ,-. Rubensstrasse 5 Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany Cygnus Solutions `--' drepper at cygnus.com `------------------------ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: another IEE related problem 1997-11-19 19:21 another IEE related problem Ulrich Drepper @ 1997-12-10 3:32 ` Bernd Schmidt 1997-12-10 7:26 ` Ulrich Drepper ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Bernd Schmidt @ 1997-12-10 3:32 UTC (permalink / raw) To: Ulrich Drepper; +Cc: egcs, kenner > Compiling this little piece of code on a ix86 machine > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > extern inline float > bar (float x) > { > float res; > asm ("fsqrt" : "=t" (res) : "0" (x)); > return res; > } > extern float fabsf (float); > > float > foo (float x) > { > float res = fabsf (bar (x)); > return res; > } > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The generated code with -O3 -momit-leaf-frame-pointer > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > foo: > flds 4(%esp) > #APP > fsqrt > #NO_APP > ret > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [the fabs statement is missing] This is a bug in the combiner. When trying to simplify an (ABS:SF (ASM_OPERANDS ...)) expression it thinks that the ASM_OPERANDS is always positive. This can be fixed with the patch I have appended. > Another bug preventing the glibc test suite to be passed. Ulrich, do you have more unsolved bugs that affect glibc? Bernd *** ./combine.c.orig-1 Tue Dec 9 10:53:39 1997 --- ./combine.c Tue Dec 9 10:55:52 1997 *************** simplify_rtx (x, op0_mode, last, in_dest *** 4092,4101 **** case XOR: return simplify_logical (x, last); ! case ABS: /* (abs (neg <foo>)) -> (abs <foo>) */ if (GET_CODE (XEXP (x, 0)) == NEG) SUBST (XEXP (x, 0), XEXP (XEXP (x, 0), 0)); /* If operand is something known to be positive, ignore the ABS. */ if (GET_CODE (XEXP (x, 0)) == FFS || GET_CODE (XEXP (x, 0)) == ABS --- 4092,4106 ---- case XOR: return simplify_logical (x, last); ! case ABS: /* (abs (neg <foo>)) -> (abs <foo>) */ if (GET_CODE (XEXP (x, 0)) == NEG) SUBST (XEXP (x, 0), XEXP (XEXP (x, 0), 0)); + + /* If the mode of the operand is VOIDmode (i.e. if it is ASM_OPERANDS), + do nothing. */ + if (GET_MODE (XEXP (x, 0)) == VOIDmode) + break; /* If operand is something known to be positive, ignore the ABS. */ if (GET_CODE (XEXP (x, 0)) == FFS || GET_CODE (XEXP (x, 0)) == ABS ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: another IEE related problem 1997-12-10 3:32 ` Bernd Schmidt @ 1997-12-10 7:26 ` Ulrich Drepper 1997-12-10 10:58 ` Ulrich Drepper 1997-12-10 19:56 ` Jeffrey A Law 2 siblings, 0 replies; 6+ messages in thread From: Ulrich Drepper @ 1997-12-10 7:26 UTC (permalink / raw) To: Bernd Schmidt; +Cc: egcs, kenner Bernd Schmidt <crux@starsky.Informatik.RWTH-Aachen.DE> writes: > This is a bug in the combiner. When trying to simplify an > (ABS:SF (ASM_OPERANDS ...)) expression it thinks that the ASM_OPERANDS is > always positive. > This can be fixed with the patch I have appended. Thanks a lot, I'll try the patch. > Ulrich, do you have more unsolved bugs that affect glibc? Yes, the current egcs snapshot fails to compile the dynamic linker. So far I'm not able to reproduce it in less than 100kB source code. I'm working on this. Thanks, -- Uli ---------------. drepper at gnu.org ,-. Rubensstrasse 5 Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany Cygnus Solutions `--' drepper at cygnus.com `------------------------ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: another IEE related problem 1997-12-10 3:32 ` Bernd Schmidt 1997-12-10 7:26 ` Ulrich Drepper @ 1997-12-10 10:58 ` Ulrich Drepper 1997-12-10 19:56 ` Jeffrey A Law 2 siblings, 0 replies; 6+ messages in thread From: Ulrich Drepper @ 1997-12-10 10:58 UTC (permalink / raw) To: Bernd Schmidt; +Cc: egcs, kenner Bernd Schmidt <crux@starsky.Informatik.RWTH-Aachen.DE> writes: > This can be fixed with the patch I have appended. Yes, it fixes at least my problems. Jeff, could you add the patch? -- Uli ---------------. drepper at gnu.org ,-. Rubensstrasse 5 Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany Cygnus Solutions `--' drepper at cygnus.com `------------------------ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: another IEE related problem 1997-12-10 3:32 ` Bernd Schmidt 1997-12-10 7:26 ` Ulrich Drepper 1997-12-10 10:58 ` Ulrich Drepper @ 1997-12-10 19:56 ` Jeffrey A Law 1997-12-10 19:28 ` Ulrich Drepper 2 siblings, 1 reply; 6+ messages in thread From: Jeffrey A Law @ 1997-12-10 19:56 UTC (permalink / raw) To: egcs; +Cc: Ulrich Drepper, kenner In message < Pine.SOL.3.90.971210122825.25453C-100000@starsky.informatik.rwth-aachen.de >you write: It seems to me that this code would be cleaner if you checked directly for ASM_OPERANDS instead of indirectly via a VOIDmode operand. I also think your change would prevent optimizing away an abs if you had something like this: (set (reg x) (const_int 5)) (set (reg y) (abs (reg x)) Ulrich can you try this patch instead? * combine.c (simplify_rtx, case ABS): Do nothing for ASM_OPERANDS. Index: combine.c =================================================================== RCS file: /cvs/cvsfiles/egcs/gcc/combine.c,v retrieving revision 1.9 diff -c -3 -p -r1.9 combine.c *** combine.c 1997/12/07 00:28:07 1.9 --- combine.c 1997/12/11 01:09:22 *************** simplify_rtx (x, op0_mode, last, in_dest *** 4097,4102 **** --- 4097,4105 ---- if (GET_CODE (XEXP (x, 0)) == NEG) SUBST (XEXP (x, 0), XEXP (XEXP (x, 0), 0)); + if (GET_CODE (XEXP (x, 0)) == ASM_OPERANDS) + return x; + /* If operand is something known to be positive, ignore the ABS. */ if (GET_CODE (XEXP (x, 0)) == FFS || GET_CODE (XEXP (x, 0)) == ABS || ((GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0))) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: another IEE related problem 1997-12-10 19:56 ` Jeffrey A Law @ 1997-12-10 19:28 ` Ulrich Drepper 0 siblings, 0 replies; 6+ messages in thread From: Ulrich Drepper @ 1997-12-10 19:28 UTC (permalink / raw) To: law; +Cc: egcs, kenner Jeffrey A Law <law@hurl.cygnus.com> writes: > Ulrich can you try this patch instead? > > * combine.c (simplify_rtx, case ABS): Do nothing for ASM_OPERANDS. This patch works as well. -- Uli ---------------. drepper at gnu.org ,-. Rubensstrasse 5 Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany Cygnus Solutions `--' drepper at cygnus.com `------------------------ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1997-12-10 19:56 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-11-19 19:21 another IEE related problem Ulrich Drepper 1997-12-10 3:32 ` Bernd Schmidt 1997-12-10 7:26 ` Ulrich Drepper 1997-12-10 10:58 ` Ulrich Drepper 1997-12-10 19:56 ` Jeffrey A Law 1997-12-10 19:28 ` 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).