Xref: utzoo comp.unix.wizards:16705 comp.lang.c:19209 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cmcl2!edler From: edler@cmcl2.NYU.EDU (Jan Edler) Newsgroups: comp.unix.wizards,comp.lang.c Subject: Re: Optimal for loop on the 68020. Keywords: for ( i = COUNT; --i >= 0; ) Message-ID: <40063@cmcl2.NYU.EDU> Date: 6 Jun 89 21:06:02 GMT References: <11993@well.UUCP> <17891@mimsy.UUCP> Reply-To: edler@cmcl2.UUCP (Jan Edler) Followup-To: comp.unix.wizards Organization: New York University, Ultracomputer project Lines: 33 In article <17891@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <11993@well.UUCP> pokey@well.UUCP (Jef Poskanzer) writes: >>... COUNT was a small (< 127) compile-time constant. >> for ( i = COUNT; --i >= 0; ) > >[all but gcc -O -fstrength-reduce deleted] > >> moveq #COUNT,d0 >> jra tag2 >>tag1: >> >>tag2: >> dbra d0,tag1 >> clrw d0 >> subql #1,d0 >> jcc tag1 I prefer moveq #COUNT,d0 jra tag3 tag1: swap d0 tag2: tag3: dbra d0,tag2 swap d0 dbra d0,tag1 But it doesn't really make that much difference, I guess. However, the compiler shouldn't do either of these when d0 is initialized to a value < 65536. Jan Edler NYU Ultracomputer Research Laboratory edler@nyu.edu