Subject: Re: Building for both ARM V4 and ARM V5 systems
To: Toru Nishimura <locore64@alkyltechnology.com>
From: Richard Earnshaw <Richard.Earnshaw@buzzard.freeserve.co.uk>
List: port-arm
Date: 08/07/2006 07:45:33
On Mon, 07 Aug 2006 09:50:00 +0900, "Toru Nishimura" wrote:
> > GCC stopped generating unaligned word 
> > accesses of any kind on ARM in gcc-3.4.  This is to ensure that code built 
> > for legacy cpus will continue to work correctly on v6 devices which 
> > support traditional unaligned memory access semantics.
> 
> And the C compiler changes tactics to integer access when "stronger
> optimisation flag" is specified.  The compiler uses corner case instruction
> which is sometimes incompatible extension for various ARM.  If changing
> O flag brings different results, it's likely inappropriate compile condition.
> 

I'm sorry, but this is just complete and utter nonsense.

First of all, for a non-volatile variable, the compiler is free to use any 
memory access sequences it deems fit.  For a volatile access the compiler 
will never change the width of the requested access.  However, if you try 
to compile for ARMv3 there are no instructions that can directly access a 
16-bit quantity.  In that case you have two possible choices: use multiple 
narrower accesses; or use one access of a wider object, possibly with a 
read-modify-write sequence for a store.  Either is permitted in this case 
because the semantics of volatile on an object of unsupported size just 
aren't well-defined.

However, GCC has always used only the load and store halfword operations 
to access 16-bit volatile objects when the architecture is v4 or higher.  
If you have any evidence to the contrary you should file a bug report with 
a testcase so that the problem can be identified and fixed.

R.