This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: possible bug in gcc-2.95.2


> The bug occurs on intel architecture, using assembly instructions
> (floating point instructions fdivp,fdivrp,fsubp,fsubrp). It appears that
> these are translated incorrectly at compile-time.

Thanks for your bug report. This is not a bug in gcc, but in your
code. If you invoke "gcc -S", you can see the assembler code
generated. You'll find out that the compiler puts the instructions
as-is into the assembler file. If something was wrong, it would be
either a bug in the assembler, or a bug in the processor :-)

In your demo file, you write

> More precisely, with gcc,'fsubp' should calculate st(1)-st(0), but
> it actually calculates st(0)-st(1).

This is not what my Intel 486 documentation says. As the explanation
for FSUBP, it says

# FSUBP ST(i),ST           Replace ST(i) with ST-ST(i), pop ST.
# FSUB                     Replace ST(1) with ST-ST(1), pop ST.

If you run objdump --disassemble on the resulting executable, you'll
see

 8048739:       9b db e3                finit  
 804873c:       db 00                   fildl  (%eax)
 804873e:       db 40 04                fildl  0x4(%eax)
 8048741:       de e1                   fsubp  %st,%st(1)
 8048743:       db 58 08                fistpl 0x8(%eax)
 
and later

 80487cf:       9b db e3                finit  
 80487d2:       db 00                   fildl  (%eax)
 80487d4:       db 40 04                fildl  0x4(%eax)
 80487d7:       de e9                   fsubrp %st,%st(1)
 80487d9:       db 58 08                fistpl 0x8(%eax)
 80487dc:       9b                      fwait

So what you want to use if fsubrp; my documentation says

# FSUBR/FSUBRP/FISUBR  - Reverse Subtract

Hope this helps,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]