Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!rochester!pt.cs.cmu.edu!andrew.cmu.edu!bader+ From: bader+@andrew.cmu.edu (Miles Bader) Newsgroups: comp.sys.amiga Subject: Re: Amiga compiler optimizing test Message-ID: Date: 4 Mar 89 07:26:24 GMT References: <3531@sdsu.UUCP>, Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA Lines: 29 In-Reply-To: deven@pawl.rpi.edu (Deven Corzine) writes: > Lattice C V5.00 generated similar code; it did not factor the > expression and do the shift once only. (with or without the global > optimizer.) >... > test(x,y); > int x,y; > { > return(x*8-y*8); > } Just for reference, this is what gcc -O (which does a pretty damn good job optimizing) on a sun outputs: _addt8: link a6,#0 movel a6@(8),d0 asll #3,d0 movel a6@(12),d1 asll #3,d1 subl d1,d0 unlk a6 rts It manages to save one instruction by subtracting into the return register. I don't think this is accidental, as it manages to do the same thing with the order of the subtraction reversed. -Miles