This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: arm.md: arm_arch4 & LDRH vs LDRB


On Tue, May 16, 2000 at 07:03:19PM -0700, Igor Shevlyakov wrote:
> Hi folks,
> 
> I'm trying to understand is there a problem with code generation under ARM or
> not and would appreciate your comments.
> 
> Could you tell me why LDRH is using for possibly unaligned half-word data
> acesses while ARM "Architecture Reference Manual" states that "If the address
> is not hald-word aligned result is UNPREDICTABLE".
> 
> I tried to run simple test case on StrongArm-110 and some ARM7 CPUs and got
> two different behaviors but both are incorrect.
> 
> Maybe 2 LDRB instructions should be used when address is not known to be
> aligned.

Given the arm defines:

	/* Non-zero if move instructions will actually fail to work
	   when given unaligned data.  */
	#define STRICT_ALIGNMENT 1

That means the compiler will align things so that any pointer created by the
compiler (without unions, casts, etc.) is properly aligned.  This is fairly
standard for many machines.  When the compiler knows the that things are
unalgined (such as with the aligned(1) attribute), it will generate slower code
(such as doing two byte loads and a shift/or).  In all other cases, the
compiler assumes the pointer is appropriate aligned.  As you noticed, different
implementations of hardware do different things.

-- 
Michael Meissner, Cygnus Solutions, a Red Hat company.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]