Hi Guys, Now that the sources are unfrozen I am applying the patch discussed on this thread:
https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00736.html It fixes the places where an address offset is computed in the wrong mode and needs to be converted to the correct mode. Since we cannot be sure that the offset RTL is valid outside of an address context it needs to be forced into a register first. Tested with no regressions on an x86_64-pc-linux-gnu and a rl78-elf toolchain. Cheers Nick gcc/ChangeLog 2015-04-14 Nick Clifton <ni...@redhat.com> * expr.c (expand_assignment): Force an address offset computation into a register before changing its mode. (expand_expr_real_1): Likewise. Index: expr.c =================================================================== --- expr.c (revision 222096) +++ expr.c (working copy) @@ -4879,7 +4879,13 @@ offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, EXPAND_SUM); address_mode = get_address_mode (to_rtx); if (GET_MODE (offset_rtx) != address_mode) - offset_rtx = convert_to_mode (address_mode, offset_rtx, 0); + { + /* We cannot be sure that the RTL in offset_rtx is valid outside + of a memory address context, so force it into a register + before attempting to convert it to the desired mode. */ + offset_rtx = force_operand (offset_rtx, NULL_RTX); + offset_rtx = convert_to_mode (address_mode, offset_rtx, 0); + } /* If we have an expression in OFFSET_RTX and a non-zero byte offset in BITPOS, adding the byte offset before the @@ -10258,7 +10264,13 @@ address_mode = get_address_mode (op0); if (GET_MODE (offset_rtx) != address_mode) - offset_rtx = convert_to_mode (address_mode, offset_rtx, 0); + { + /* We cannot be sure that the RTL in offset_rtx is valid outside + of a memory address context, so force it into a register + before attempting to convert it to the desired mode. */ + offset_rtx = force_operand (offset_rtx, NULL_RTX); + offset_rtx = convert_to_mode (address_mode, offset_rtx, 0); + } /* See the comment in expand_assignment for the rationale. */ if (mode1 != VOIDmode