Path: utzoo!mnetor!uunet!husc6!bbn!rochester!PT.CS.CMU.EDU!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.c Subject: pcc Codegeneration Message-ID: <4650@aw.sei.cmu.edu> Date: 18 Mar 88 16:40:01 GMT References: <5020@nsc.nsc.com> <10702@mimsy.UUCP> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 35 Keywords: conversions 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$: