> if (offset) > { > machine_mode address_mode; > rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, > EXPAND_SUM); > > gcc_assert (MEM_P (op0)); > > address_mode = get_address_mode (op0); > if (GET_MODE (offset_rtx) != address_mode) > offset_rtx = convert_to_mode (address_mode, offset_rtx, 0); > > The problem here is that convert_to_mode() may decide to offload > offset_rtx into another reg and then extend the reg to address_mode, > but it assumes that offset_rtx is a valid rtl expression for the > target.
Note that the very same code is in expand_assignment, so they probably should be kept in sync. > The patch adds a second call to expand_expr(), giving the address mode > as the suggested mode, and using a normal expansion, rather than > EXPAND_SUM. This might work, but even if it does not the rtl in > offset_rtx will be valid in a non-address context so that whatever > convert_to_mode does will still remain valid. I don't think that we want to expand twice the same expression. What about calling force_operand on offset_rtx right before convert_to_mode? -- Eric Botcazou