Date: Thu, 28 Nov 1996 12:11:13 +0000 From: Bill Currie Subject: Re: Optimization To: Glen Miner Cc: djgpp AT delorie DOT com Reply-to: billc AT blackmagic DOT tait DOT co DOT nz Message-id: <329D8161.5637@blackmagic.tait.co.nz> Organization: Tait Electronics NZ MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: Glen Miner wrote: > How well will djgpp deal with two dimentional arrays? Say I'm stepping > through char MyArray[9][9] like so: > > for (x = 0; x < 6; x++) > for (y = 0; y < 7; y++) > MyArray [x][y] = SomeValue; > > Will it be smart and index it by a pointer so that it doesn't have to > recalculate the address every time? Actually, gcc will do one better and either get the hardware to calculate the offsets in 1 or 2 instructions (=2/4clocks on 386,1/2 on 486(?)) or, because all bounds are constants, do some realy niffty indexing. Try using loop unrolling which is NOT done by default (--funroll-loops I think, you will need to verify that), this is a perfect candidate for the above. BTW you should see what it does to (val is unsigned long) x=(val<<3)|(val>>29)! 2.2.2 did anyway, I'll have to check if 2.7.2.1 does the same thing (hint, 1 intruction!). Bill -- Leave others their otherness.