Path: utzoo!attcan!uunet!munnari!otc!metro!ipso!stcns3!stca77!peter From: peter@stca77.stc.oz (Peter Jeremy) Newsgroups: comp.arch Subject: Re: CC machines do execute 15% more instructions Message-ID: <366@stca77.stc.oz> Date: 30 Nov 88 02:01:10 GMT References: <3386@pt.cs.cmu.edu> <74435@sun.uucp> <70@armada.UUCP> <550@m3.mfci.UUCP> <2152@ficc.uu.net> <552@m3.mfci.UUCP> <76500@sun.uucp> <10643@tekecs.TEK.COM> <8523@wright.mips.COM> <78977@sun.uucp> <8768@wright.mips.COM> Reply-To: peter@stca77.stc.oz (Peter Jeremy) Organization: Alcatel-STC, Alexandria, AUSTRALIA Lines: 34 In article <8768@wright.mips.COM> earl@wright.mips.com (Earl Killian) writes: > A < B, A <= B, >A > B, A >= B (for B != 0) are not as common as you might first guess >(look up Stanford's published results). For example these are used at >the tops of loops, but they're not useful at the bottom (if you >implement loopback with <=, then your loops will fail when the >termination value is 2**31-1). Only if you are using signed 32-bit arithmetic. You need a whole new set of branch instructions for unsigned arithmetic as well. Getting a loop to execute 2**n times, where n is wordsize, is a messy process, likely to result in infinite loops if one is not careful. Stating that an instruction is not useful, because it does not have the effect that the programmer wanted when used at the extremities of the number range, is a bit specious. > At loop bottom != is the appropriate >test. (Also a global optimizer can convert A < B tests to A != B >tests in some cases.) I prefer using relational operators rather than equality operators as part of my "defensive coding" style. If A accidently gets munged due to a bug, I prefer the loop to exit, rather than wait another 2**32 (or whatever) iterations until A==B again. If I found that my compiler was "optimising" relational tests to equality tests, I would report it as a bug and scream until it was fixed - unless the compiler is going to guarantee that my code has no bugs that might corrupt A or B. -- Peter Jeremy (VK2PJ) peter@stca77.stc.oz Alcatel-STC Australia ...!uunet!stca77.stc.oz!peter 41 Mandible St peter%stca77.stc.oz@uunet.UU.NET ALEXANDRIA NSW 2015