[patch] Fix powerpc 64 alignment problem for lwa instruction

Dale Johannesen dalej@apple.com
Tue Nov 7 21:53:00 GMT 2006


On Nov 7, 2006, at 12:56 PM, Andrew Pinski wrote:

>> We, at Apple, found a ppc64 code generation problem where lwa_operand
>> routine didn't check the alignment of a memory operand being 32 bits
>> aligned or not.
>>
>> The following patch has been tested on ppc MacOS with "make all", "--
>> enable-languages=c,c++,objc,obj-c++", and regression tested with a  
>> top-
>> level "make check-gcc" with no regression.
>>
>> gcc/ChangeLog:
>>
>> 	* gcc/config/rs6000/predicates.md (lwa_operand): Check the  
>> alignment of
>> 	a memory operand is 32 bits aligned or not.
>
> This is the wrong fix, the memory alignment is not the issue here  
> but the offset
> field has to be multiple of 4.  This is according to the ISA  
> documents.

The memory alignment feeds into the offset field, try the testcase:

(-static or -mdynamic-no-pic):
         lwa r3,lo16(_mybox)(r2)

(-pic):
         lwa r3,lo16(_mybox-"L00000000002$pb")(r2)

&_mybox is only 2-byte aligned, although it may randomly be a  
multiple of 4 in practice.



More information about the Gcc-patches mailing list