Article View: gnu.gcc.bug
Article #2292Inline functions + assembly can use wrong register
From: Anton Rang
Date: Tue, 14 Feb 1989 05:56
Date: Tue, 14 Feb 1989 05:56
50 lines
1725 bytes
1725 bytes
Environment: GCC version 1.33, Sun-3/280, SunOS 3.4, -O (optimize) flag.
The following program generates incorrect output (or else I'm missing
something with the asm() stuff). GCC mysteriously decides to use fp2
as the source for the cos() call. This only happens when BUG is
defined; otherwise it works fine.
/*** cut here ***/
#define BUG
static inline double sin(double angle)
{
double result;
asm("fsinx %1,%0" : "=f" (result) : "f" (angle));
return(result);
}
static inline double cos(double angle)
{
double result;
asm("fcosx %1,%0" : "=f" (result) : "f" (angle));
return(result);
}
static inline double tan(double angle)
{
double result;
asm("ftanx %1,%0" : "=f" (result) : "f" (angle));
return(result);
}
#define pi 3.1415926535
main()
{
printf("sin=%f, cos=%f, tan=%f\n", sin(pi / 4), cos(pi / 4), tan(pi / 4));
#ifdef BUG
printf("second cos=%f\n", cos(pi / 4));
#endif
}
/*** cut here ***/
+---------------------------+------------------------+----------------------+
| Anton Rang (grad student) | Things could be worse. | "Do worry...be SAD!" |
| Michigan State University | rang@cpswh.cps.msu.edu | |
+---------------------------+------------------------+----------------------+
Technical Details
Message-ID:
<1813@cps3xx.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!telly!lethe!dptcdc!jarvis.csri.toronto.edu!mailrus!eecae!cps3xx!rangShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!lethe!dptcdc!jarvis.csri.toronto.edu!mailrus!eecae!cps3xx!rang From: rang@cpsin3.cps.msu.edu (Anton Rang) Newsgroups: gnu.gcc.bug Subject: Inline functions + assembly can use wrong register Message-ID: <1813@cps3xx.UUCP> Date: 14 Feb 89 05:56:33 GMT Sender: usenet@cps3xx.UUCP Reply-To: rang@cpswh.cps.msu.edu (Anton Rang) Organization: Michigan State University, Computer Science Dept. Lines: 50