Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!claris!aimt!phil From: phil@aimt.UU.NET (Phil Gustafson) Newsgroups: comp.arch Subject: Re: SPARC vs MC68040 Summary: Fooling optimizers Message-ID: <3262@aimt.UU.NET> Date: 21 Feb 90 04:10:13 GMT References: <8859@portia.Stanford.EDU> <5190@convex.convex.com> <43279@ames.arc.nasa.gov> Organization: Famed Parquet Floor Lines: 35 In article <43279@ames.arc.nasa.gov>, lamaster@ames.arc.nasa.gov (Hugh LaMaster) writes: > Reminds me of about 10 years ago, when I wrote some programs to test > branch speeds. I had to add some bogus assignments and outputs which were > never executed, but might have been, in order to get the CDC and Cray > compilers of the time to create the loop. And that was *ten years ago*. > If someone ever puts AI into a compiler, we might as well give up on > benchmarking :-) > > Hugh LaMaster, m/s 233-9, UUCP ames!lamaster Yes. I was responsible for helping make a [nameless] commercial benchmark optimizer resistant. Each test required a bogus assignment and output. One very simple but effective technique involved reading _all_ the constants used by the program from an external file to make sure the compilers didn't do the arithmetic once at compilation time and never do it again. The constant values were listed in comments in the source code -- I figured that if the compiler could optimize using the comments it deserved to win :-} . The same trick might well help with the famous dhrystone strcmp problem. [Aside-- I keep hearing apocryphal stories about compilers that looked for such strings as "dongarra" in source code and acted accordingly. I'd appre- ciate mail from anyone who knows of a real compiler or preprocessor that did this.] -- Opinions outside attributed quotations are mine alone. Satirical material may not be labeled as such. I don't work at this site anymore -- they just let me read their news. -- -- Phil Gustafson, Graphics/UN*X Consultant {uunet,ames!coherent}!aimt!phil phil@aimt.uu.net 1550 Martin Ave, San Jose, Ca 95126