Fix PR/14084

Jim Wilson wilson@specifixinc.com
Thu Feb 19 03:41:00 GMT 2004


Josef Zlomek wrote:
> I have noticed a problem with REG_OFFSET on powerpc64.
> When variable is stored in register in mode larger than the variable
> and then variable is used in original mode using subreg
> the REG_OFFSET after simplification of subreg is wrong.

I think this patch is more complicated than it needs to be.  What we 
need to do here is convert a subreg offset into a mem offset.  This is 
the inverse of the usual big-endian correction that converts a mem 
offset into a subreg offset.

subreg_lowpart_offset does the mem->reg offset conversion, assuming that 
the mem offset is zero.

Thus, if subreg_lowpart_offset == byte, then it must be the case that 
REG_OFFSET should be zero.  I see no need for the rest of the code.

This doesn't solve the general problem though, as REG_OFFSET will still 
be wrong in all other cases.  We can fix that by doing an actual 
reg->mem offset conversion.  I think if you take subreg_lowpart_offset 
and replace all of the += with -=, then you get a function that converts 
a reg offset to a mem offset.  Add an argument offset, instead of 
initializing it to zero.  Given, outermode==DImode, innermode=SImode, 
UNITS_PER_WORD==8, and offset==byte==4, that will return 0 which is what 
we want.   We can do this calculation before calling gen_rtx_REG_offset 
so that we only have to call it once.

There are two places in the compiler that call gen_rtx_REG_offset, and 
you are only fixing one of them.  They should both be fixed.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc-patches mailing list