This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Avoid calling convert_to_mode with invalid rtl.
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, dj at redhat dot com
- Date: Mon, 16 Mar 2015 09:29:13 +0100
- Subject: Re: RFC: Avoid calling convert_to_mode with invalid rtl.
- Authentication-results: sourceware.org; auth=none
- References: <87k2ylqgh8 dot fsf at redhat dot com>
> 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