Article View: gnu.gcc.bug
Article #2m68k vs. asm (bug?)
From: Mark Wagner
Date: Tue, 27 Oct 1992 02:59
Date: Tue, 27 Oct 1992 02:59
31 lines
1247 bytes
1247 bytes
Given the following code on a 68k NeXT:
int getA() { return 5; }
int b = 10;
int p = 3;
int r;
main() {
int a = getA();
r = 0;
asm("movel %2,d0;mulsl %1,%0:d0;divsl %3,%0:d0":
"=d"(r): "dmsK"(a), "d"(b), "dmsK"(p), "0"(r): "d0");
printf("%d\n", r);
}
The "wrong" answer is produced when optimization is turned on.
The compile line is "cc -O foo.c -o foo".
The configuration is m68k-next-mach.
Version: ss-921018 (as well as straight 2.2.2)
Specifically, the result of the call to getA() is left in register
d0. It is immediately clobbered by the first instruction in the asm
("movel %2, d0") and then used in the second instruction of the asm
("mulsl %1, %0: d0"). Note that the register d0 is listed as being
clobbered by the asm statement.
The correct output is 2.
Technical Details
Message-ID:
<9210271859.AA09783@oz.NeXT.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!next.com!Mark_WagnerShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!next.com!Mark_Wagner From: Mark_Wagner@next.com (Mark Wagner) Subject: m68k vs. asm (bug?) Message-ID: <9210271859.AA09783@oz.NeXT.COM> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 27 Oct 1992 02:59:49 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 34