Path: utzoo!yunexus!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!ukma!tut.cis.ohio-state.edu!toad.com!gnu From: gnu@toad.com Newsgroups: gnu.gcc.bug Subject: Re: "Redundant" test instructions in GCC 1.34 on m68k (and SPARC bug) Message-ID: <8903231904.AA16897@hop.toad.com> Date: 23 Mar 89 19:04:12 GMT Article-I.D.: hop.8903231904.AA16897 References: <8903230625.AA03410@Gang-of-Four.Stanford.EDU> Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 21 The reason for the "redundant" test is in case the add overflows. The 68K is "smart" and will still jump "greater than" if the add overflowed into what appears to be a negative number (because it notices that the V bit is set). We have to defeat that so that if (a+b < 0) and c = a+b; if (c < 0) work the same, and so you get the same result when optimizing and not. The compiler attempts to track whether overflow might be set, to avoid the extra test when possible (e.g. if the last op was "or" rather than "add"). The SPARC sets condition codes the same way as the 68000, but its machine description does not properly handle this case. Try Joe's test program on the Sparc, setting i to 2147483647 and j to 5. When unoptimized, it says the result is negative; when optimized, positive. John Gilmore