Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!apple!bloom-beacon!usc!pollux.usc.edu!addison From: addison@pollux.usc.edu (Richard Addison) Newsgroups: comp.sys.amiga.tech Subject: Re: Another Manx v3.6 bug Summary: Stupid sign extensions Keywords: code generation,C,stupid,corn flakes Message-ID: <17762@usc.edu> Date: 11 Jun 89 23:15:13 GMT References: <14328@watdragon.waterloo.edu> <14395@watdragon.waterloo.edu> Sender: news@usc.edu Reply-To: addison@pollux.usc.edu (Richard Addison) Organization: University of Southern California, Los Angeles, CA Lines: 24 In article <14395@watdragon.waterloo.edu> ehoogerbeets@rose.waterloo.edu (Edwin Hoogerbeets) writes: >In article <14328@watdragon.waterloo.edu> ehoogerbeets@rose.waterloo.edu (Edwin Hoogerbeets) writes: >% I know it is pretty gross >% C code, but it occurs in GnuGrep (fish 204), and probably other Gnu >% code. > ... > ext.w d0 ; sign extend it to a word [?????] > ... > ext.w d0 ; sign extend it to a word [?????] > ext.l d0 ; sign extend it to a long [2*?????] This brings up something that I've always found horribly stupid. I've seen C compilers use ext.w (followed by ext.l if ints are long) to test to see if a char is equal to 0, or to compare two chars, or to add, subtract two chars when the result will end up in a char. These are very clearly instances of unnecessary promotion: the additional high-order bits will never effect the lower-order bits. Caveat: I haven't been looking as closely at the code generation of the most current versions of Manx and Lattice because I have the source level debuggers. I don't know if they are still as weird about this unnecesarry code generation. Richard Addison "Jim: Life is not a dream." -- Spock, Star Trek V: The Final (?) Frontier