[patch] Fix powerpc 64 alignment problem for lwa instruction
Andrew Pinski
pinskia@physics.uc.edu
Tue Nov 7 23:11:00 GMT 2006
>
> > What about rejecting all low_sum instead? The alignment is still the correct
> ^^^^^^
> incorrect
> > check. Because we can have alignment of 16 and still have an offset which is
> > a multiple of 4.
> > Hmm, the other thing is that constraint m seems wrong for the lwa instruction,
> > I think it should be changed to Y like the load doubleword case.
The reason why I said this patch is incorrect is because the following:
#pragma pack(push, 2)
struct FixedRectangle {
int left;
int top;
int right;
int bottom;
};
#pragma pack(pop)
long getLeft (struct FixedRectangle *a)
{
return ((struct FixedRectangle*)(((char*)a)+4))->top;
}
Compile at -Os -m64, we should still get a lwa but with your patch we get a
lwz and a extsw.
The following patch keeps this regression from showing up and also fixes your orginal
testcase:
Index: predicates.md
===================================================================
--- predicates.md (revision 118565)
+++ predicates.md (working copy)
@@ -654,7 +654,9 @@ (define_predicate "lwa_operand"
&& GET_CODE (XEXP (inner, 0)) != PRE_DEC
&& (GET_CODE (XEXP (inner, 0)) != PLUS
|| GET_CODE (XEXP (XEXP (inner, 0), 1)) != CONST_INT
- || INTVAL (XEXP (XEXP (inner, 0), 1)) % 4 == 0));
+ || INTVAL (XEXP (XEXP (inner, 0), 1)) % 4 == 0)
+ && (GET_CODE (XEXP (inner, 0)) != LO_SUM
+ || (MEM_ALIGN (inner) % 32) == 0));
})
;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
The main difference is just checks the alignment for the lo_sum case instead of
the general case where we don't need to check because we have an offset in those
cases.
Thanks,
Andrew Pinski
More information about the Gcc-patches
mailing list