Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!seismo!rlgvax!cvl!umcp-cs!chris From: chris@umcp-cs.UUCP Newsgroups: net.bugs.4bsd,net.lang.c Subject: Re: cc flag to prevent type conversion Message-ID: <3133@umcp-cs.UUCP> Date: Sat, 15-Oct-83 05:21:42 EDT Article-I.D.: umcp-cs.3133 Posted: Sat Oct 15 05:21:42 1983 Date-Received: Sun, 16-Oct-83 13:18:04 EDT References: <461@nsc.uucp> Organization: Univ. of Maryland, Computer Science Dept. Lines: 34 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@umcp-cs ARPA: chris.umcp-cs@UDel-Relay