Alan Modra <amo...@gmail.com> writes:
> This patch allows lra to reload a lo_sum address.  Given a mem with a
> lo_sum address as used by ppc32, decompose_mem_address returns an
> address_info with *base the lo_sum and *base_term the reg within the
> lo_sum.  When a lo_sum address isn't valid, we want to first try
> reloading the entire lo_sum to a new reg.  I first fixed that, then
> hit another ICE, this time in gen_int_mode.  gen_int_mode was being
> called with the mode of the memory access, not the mode of the
> address.

It seems odd that we have a lo_sum address for a mode that doesn't
accept lo_sums.  I don't think that was one of the "three" cases
anticapted in:

  /* There are three cases where the shape of *AD.INNER may now be invalid:

     1) the original address was valid, but either elimination or
     equiv_address_substitution was applied and that made
     the address invalid.

     2) the address is an invalid symbolic address created by
     force_const_to_mem.

     3) the address is a frame address with an invalid offset.

     4) the address is a frame address with an invalid base.

     All these cases involve a non-autoinc address, so there is no
     point revalidating other types.  */

It sounds from the PR comments like a valid lo_sum in a mem:SI
somehow becomes an invalid lo_sum in a mem:SD through equivalence,
is that right?  If so, was there a (subreg:SD (reg:SI ...)) in the
pre-RA insn that got "simplifed" to a (mem:SD (lo_sum ...)) during LRA?
IMO the bug's in that step if so and if lo_sum isn't valid for mem:SD.

The patch instead seems to be moving towards reloading any address
we end up with (which presumably fits one of the options above
for _some_ mode, just not in this case for the current mode).
But then there's no reason why the remaining assert:

> @@ -2916,18 +2916,18 @@ base_to_reg (struct address_info *ad)
>    rtx_insn *insn;
>    rtx_insn *last_insn = get_last_insn();
>  
> -  lra_assert (ad->base == ad->base_term && ad->disp == ad->disp_term);
> +  lra_assert (ad->disp == ad->disp_term);

would hold either.  We'd need to make base_to_reg handle every address
recognised by decompose_mem_address, including for instance cases in
which an index could be sign-extended for the original mem mode but not
for the current one.

I don't think the code was ever intended to handle anything
that complicated.  The address has to be "basically" valid,
except in the cases above.

Thanks,
Richard

Reply via email to