Article View: gnu.gcc.bug
Article #2671fix for 386 fp subtraction bug
From: James Clark
Date: Tue, 23 May 1989 11:41
Date: Tue, 23 May 1989 11:41
53 lines
1873 bytes
1873 bytes
I reported a problem with 386 floating point subtraction to you
yesterday. The problem was that this program:
double foo()
{
return 1.0;
}
main()
{
double x = 5.0;
x -= foo();
printf("%g\n", x);
}
output -4 rather than 4 when compiled by gcc 1.35 configured for the
386 with gas.
The following patch seems to fix this problem:
*** out-i386.c Tue May 23 11:57:18 1989
--- aux-output.c Tue May 23 12:01:15 1989
***************
*** 140,150 ****
/* Here we want the "reversed" insn, fsubr or fdivr.
But there is an assembler bug in all 80386 assemblers
which exchanges the meanings of fsubr and fsub, and of fdivr and fdiv!
So use the "unreversed" opcode (which will assemble into
the "reversed" insn). */
! rev = op;
while (*rev && *rev != '%')
fputc (*rev++, asm_out_file);
/* fp_pop_level--; */
--- 140,150 ----
/* Here we want the "reversed" insn, fsubr or fdivr.
But there is an assembler bug in all 80386 assemblers
which exchanges the meanings of fsubr and fsub, and of fdivr and fdiv!
So use the "unreversed" opcode (which will assemble into
the "reversed" insn). */
! /* rev = op; */
while (*rev && *rev != '%')
fputc (*rev++, asm_out_file);
/* fp_pop_level--; */
I don't completely understand what's going on here, but the patch
works on all the examples that I've tried.
James Clark
jjc@jclark.uucp
Technical Details
Message-ID:
<8905231141.AA15908@jclark.uucp>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!UUNET.UU.NET!jclark!jjcShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!UUNET.UU.NET!jclark!jjc From: jclark!jjc@UUNET.UU.NET (James Clark) Newsgroups: gnu.gcc.bug Subject: fix for 386 fp subtraction bug Message-ID: <8905231141.AA15908@jclark.uucp> Date: 23 May 89 11:41:30 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 53