[net.lang.c] cc flag to prevent type conversion

chongo@nsc.UUCP (10/14/83)

i would welcome a cc flag which would prevent the operations

single-float op single-float
shirt-int op short-int

from being coverted to double before doing the op.  the lack
of such a feature sludges out compute bound code.

there are times in which i will do a large amount of crunching in the 16 bit
operand length or single float range.  on machines which single operations
are faster than double ints  (most)  such a flag would speed up my programs
by a noticable amount.

chongo /\../\

chris@umcp-cs.UUCP (10/15/83)

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