diff options
Diffstat (limited to 'gcc/emit-rtl.c')
-rw-r--r-- | gcc/emit-rtl.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 294577c..b1429da 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1869,19 +1869,29 @@ change_address_1 (rtx memref, enum machine_mode mode, rtx addr, int validate) rtx change_address (rtx memref, enum machine_mode mode, rtx addr) { - rtx new = change_address_1 (memref, mode, addr, 1); + rtx new = change_address_1 (memref, mode, addr, 1), size; enum machine_mode mmode = GET_MODE (new); + unsigned int align; + + size = mmode == BLKmode ? 0 : GEN_INT (GET_MODE_SIZE (mmode)); + align = mmode == BLKmode ? BITS_PER_UNIT : GET_MODE_ALIGNMENT (mmode); /* If there are no changes, just return the original memory reference. */ if (new == memref) - return new; + { + if (MEM_ATTRS (memref) == 0 + || (MEM_EXPR (memref) == NULL + && MEM_OFFSET (memref) == NULL + && MEM_SIZE (memref) == size + && MEM_ALIGN (memref) == align)) + return new; + + new = gen_rtx_MEM (mmode, addr); + MEM_COPY_ATTRIBUTES (new, memref); + } MEM_ATTRS (new) - = get_mem_attrs (MEM_ALIAS_SET (memref), 0, 0, - mmode == BLKmode ? 0 : GEN_INT (GET_MODE_SIZE (mmode)), - (mmode == BLKmode ? BITS_PER_UNIT - : GET_MODE_ALIGNMENT (mmode)), - mmode); + = get_mem_attrs (MEM_ALIAS_SET (memref), 0, 0, size, align, mmode); return new; } |