www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/27/18:23:26

Date: Thu, 28 Nov 1996 12:11:13 +0000
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: Optimization
To: Glen Miner <gminer AT ca DOT newbridge DOT com>
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
References: <Pine DOT SUN DOT 3 DOT 90 DOT 961127125213 DOT 12832A-100000 AT coop10>

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019