[comp.lang.c] pcc Codegeneration

firth@sei.cmu.edu (Robert Firth) (03/19/88)

In article <10702@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:

[old pcc versions fail when converting unsigned to float]

] Donn Seeley has fixed this in recent versions of the 4BSD
] compilers.  The 4.3BSD compiler turns
] 
] 	main(){
] 		register unsigned u = 0xf0000000;
] 		register float f = u;
] 		printf("%u %u\n", u, (unsigned)f);
] 	}
] 
] into
] 
] 	movl	$-268435456,r11		# u = 0xf0000000;
] 	movl	r11,r10			# begin f = u:
] 	jbsc	$31,r10,L99999		# was it negative?
] 	cvtlf	r10,r10			# it was not negative; convert
] 	jbr	L99998			# and done
] L99999:
] 	cvtlf	r10,r10			# it was negative but is no longer
] 	addf2	$0f2.147483648e9,r10	# so convert and add 1<<31.
] L99998:
	...


Sigh!  It seems pcc code generation is as sloppy as it ever was.

Wouldn't this be a lot simpler, faster, and easier to generate?

	CVTLF src, reg
	BGEQ  1$
	ADDF2 #2**32,reg
    1$: