cc flag to prevent type conversion
chris at umcp-cs.UUCP
chris at umcp-cs.UUCP
Sat Oct 15 19:21:42 AEST 1983
CC *almost* does floating point single precision multiplies in single
precision.
The following code fragment
float f1, f2;
double d;
f1 = f1 * f2;
d = f1 * f2;
generates, on 4.1BSD using pcc,
mulf3 -8(fp),-4(fp),r0
cvtfd r0,r0
cvtdf r0,-4(fp) # this is f1 = f1 * f2
mulf3 -8(fp),-4(fp),r0
cvtfd r0,r0
movd r0,-16(fp) # this is d = f1 * f2
The first is silly. It *does the multiply in single precision* (hear
that Fortran fans?), but stupidly converts to double and then back to
float. (The optimizer doesn't catch it either.)
However, the second is just plain *wrong*. The multiply should have
been done in double precision! The other way loses precision.
Anyone feel like hacking pcc guts?
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris.umcp-cs at UDel-Relay
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list