Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!uw-beaver!tektronix!tekcrl!tekgvs!toma From: toma@tekgvs.TEK.COM (Thomas Almy) Newsgroups: comp.lang.c,comp.sys.m68k Subject: Re: Ackermann's function is wrong in Moto Benchmark Report Message-ID: <2309@tekgvs.TEK.COM> Date: Thu, 21-May-87 11:10:52 EDT Article-I.D.: tekgvs.2309 Posted: Thu May 21 11:10:52 1987 Date-Received: Sat, 23-May-87 14:44:30 EDT References: <16731@amdcad.AMD.COM> Reply-To: toma@tekgvs.UUCP (Thomas Almy) Organization: Tektronix, Inc., Beaverton, OR. Lines: 29 Xref: mnetor comp.lang.c:2224 comp.sys.m68k:496 In article <16731@amdcad.AMD.COM> tim@amdcad.AMD.COM (Tim Olson) writes: > >In the "Apples to Oranges" MC68020 Benchmark Report Motorola put out in >1986, the C code for Ackermann's function was shown as: [ some code deleted ] >int x,y; >{ > if (x==0) return (++y); > if (y==0) return (A(--x,1)); > return (A(--x,A(x,--y))); >} >The last line is incorrect. [ ... ] >The last line should be written: > > return (A(x-1,A(x,--y))); Not only that, but using all of those decrement operations turns the benchmark into a good compiler test (rather than a processor test). Is the C compiler smart enough to realize that storing the incremented y (in the first case) or decremented x or y (latter cases) is not necessary? I wouldn't be happy unless the benchmark was: if (x==0) return (y+1); if (y==0) return (A(x-1,1)); return(A(x-1,A(x,y-1))); Tom Almy