Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: soundex algorithm wanted Message-ID: <6909@sun.uucp> Date: Thu, 4-Sep-86 16:50:39 EDT Article-I.D.: sun.6909 Posted: Thu Sep 4 16:50:39 1986 Date-Received: Fri, 5-Sep-86 04:40:50 EDT References: <27@houligan.UUCP> <672@bnrmtv.UUCP> <1239@whuxl.UUCP> <3266@umcp-cs.UUCP> Organization: Sun Microsystems, Inc. Lines: 54 > All the compilers I have used ignore the `register' on `register > char' declarations. This was a change made to the System III compiler for 4(3?)BSD. The claim was that the compiler produced "poor, and sometimes incorrect, code" for register variables less than 32 bits long. The System V compiler, like the System III compiler, puts "char" and "short" data into registers. I have no idea whether the S5 compiler produces the "poor, and sometimes incorrect, code" mentioned or not, as I don't know what the code in question was. > Are there any extant compilers for which the latter will generate *worse* > code? Script started on Thu Sep 4 13:41:45 1986 gorodish$ cat foo.c foo() { register char c; register int i; if (i == 'c') bar(); if (c == 'c') bar(); } gorodish$ cc -S -O foo.c gorodish$ cat foo.s ...(boring preamble deleted)... moveq #99,d1 cmpl d1,d6 jne L14 jbsr _bar L14: cmpb #99,d7 jne LE12 jbsr _bar LE12: moveml a6@(-8),#192 unlk a6 rts gorodish$ Script done on Thu Sep 4 13:42:01 1986 As the M68000 Programmer's Reference Manual says for CMPI, "The size of the immediate data matches the operation size", so it uses a scratch register and a "moveq"/"cmp.l" pair rather than a "cmpi.l". Even given that, it'd rather compare 8 bits of immediate data against 8 bits in a register than compare 32 bits of data against 32 bits in a register, especially on the M68XXX for XXX < 020. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)