rang@cpsin3.cps.msu.edu (Anton Rang) (02/14/89)
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 | | +---------------------------+------------------------+----------------------+