Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!mcdphx!hrc!gtephx!robertsw From: robertsw@...!asuvax!gtephx (Wild Rider) Newsgroups: comp.arch Subject: Re: Loop instructions Message-ID: <1991Apr24.005419.2975@...!asuvax!gtephx> Date: 24 Apr 91 00:54:19 GMT References: <1991Apr16.152438.3445@waikato.ac.nz> <12739@pt.cs.cmu.edu> Reply-To: robertsw@gtephx.UUCP (Wild Rider) Organization: AG (formerly GTE) Comm. Sys., Phx, AZ Lines: 37 In article <12739@pt.cs.cmu.edu> lindsay@gandalf.cs.cmu.edu (Donald Lindsay) writes: >In article <1991Apr16.152438.3445@waikato.ac.nz> > ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes: >>On the 68000 family, the DBcc loop instructions decrement the 16-bit count >>register and stop looping when it reaches -1 (or 65535), not 0. > >Compiler writers dislike this instruction, but not because of the >test semantics. The killer is that the count is 16 bits, on a machine >where variables and expressions are naturally 32 bits. This means >that the compiler can only use the instruction when it possesses >range information. (sound of u.s.s. enterprise red-alert siren going off ... ) ("phasors locked on target, sir") uh, not exactly. are you a compiler writer, mr. lindsay? if not, where did you get your info? for your own edification, run any of sun's ancient c compilers on some looping code & check the generated output (hint: cc -O -S loops.c)... it's not at all difficult to use the dbcc instructions _in conjunction with subtract & bcc instructions following the dbcc_ to employ a full 32-bit counter in a loop that also takes advantage of the dbcc instruction for most of the work. remember, too, that this trick (cough, cough) was employed years ago with plain vanilla sun cc compilers; we're not talking cutting edge by _any_ stretch of the imagination. if gcc doesn't use this little shortcut, take the codegen people out back & put them out of their misery... >Don D.C.Lindsay Carnegie Mellon Robotics Institute cheers && happy compiling, wild rider -- Wallace Roberts, AG (formerly GTE) Communication Systems, Phoenix, AZ UUCP: ...!{ncar!noao!asuvax | uunet!zardoz!hrc | att}!gtephx!robertsw Internet: gtephx!robertsw@asuvax.eas.asu.edu Bike: '82 GS1100L Suz voice: (602)581-4555 fax: (602)582-7624 Cage: '89 Mustang GT