[Bug rtl-optimization/56195] [4.8 Regression] Error: incorrect register `%rdi' used with `l' suffix (at -O2)

vmakarov at redhat dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 7 20:09:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56195

--- Comment #7 from Vladimir Makarov <vmakarov at redhat dot com> 2013-02-07 20:08:47 UTC ---
(In reply to comment #6)
> Actually, that one doesn't really work, because we have pseudo rather than hard
> reg at that point, which will never simplify.
> 
> With this:
> 
> --- lra-constraints.c.jj    2013-02-07 18:34:39.000000000 +0100
> +++ lra-constraints.c    2013-02-07 20:58:25.558920536 +0100
> @@ -421,8 +421,20 @@ get_reload_reg (enum op_type type, enum
>        if (rtx_equal_p (curr_insn_input_reloads[i].input, original)
>        && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class))
>      {
> -      *result_reg = curr_insn_input_reloads[i].reg;
> -      regno = REGNO (*result_reg);
> +      rtx reg = curr_insn_input_reloads[i].reg;
> +      regno = REGNO (reg);
> +      /* If input is equal to original and both are VOIDmode,
> +         GET_MODE (reg) might be still different from mode.
> +         Ensure we don't return *result_reg with wrong mode.  */
> +      if (GET_MODE (reg) != mode)
> +        {
> +          if (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (mode))
> +        continue;
> +          reg = lowpart_subreg (mode, reg, GET_MODE (reg));
> +          if (reg == NULL_RTX || GET_CODE (reg) != SUBREG)
> +        continue;
> +        }
> +      *result_reg = reg;
>        if (lra_dump_file != NULL)
>          {
>            fprintf (lra_dump_file, "     Reuse r%d for reload ", regno);
> 
> the assembly difference is:
> 
> -    cmpl    (%rdi), %rdi
> +    cmpl    (%rdi), %edi
> 
> which is desirable in this case, but not sure if all get_reload_reg callers
> will grok a SUBREG instead of REG returned in *result_reg.

This version of patch looks ok for me.  I have no worry about get_reload_reg
callers.  It should work fine (that is a difference from reload pass when you
should care about secondary reloads etc).

Thanks for working on this, Jakub,



More information about the Gcc-bugs mailing list