Optimal for loop on the 68020.
Jan Edler
edler at cmcl2.NYU.EDU
Wed Jun 7 07:06:02 AEST 1989
In article <17891 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>In article <11993 at well.UUCP> pokey at 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:
>> <loop body>
>>tag2:
>> dbra d0,tag1
>> clrw d0
>> subql #1,d0
>> jcc tag1
I prefer
moveq #COUNT,d0
jra tag3
tag1: swap d0
tag2: <loop body>
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 at nyu.edu
More information about the Comp.lang.c
mailing list