https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64722

--- Comment #13 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Ilya Enkovich from comment #11)
> (In reply to David Malcolm from comment #10)
> > which led to investigating this code in ix86_conditional_register_usage:
> > 4394  j = PIC_OFFSET_TABLE_REGNUM;
> > 4395  if (j != INVALID_REGNUM)
> > 4396    fixed_regs[j] = call_used_regs[j] = 1;
> > and line 4396 is bizarrely only called on the 2nd iteration, not the 1st,
> > which led me to investigate "PIC_OFFSET_TABLE_REGNUM", and discover what
> > appears to be the root cause, as described in comment #1.
> 
> Now I see.  The problem also is in ix86_conditional_register_usage that
> relies on pic_offset_table_rtx value.  As I said EBX value is used only to
> estimate costs for middle-end.  Thus we shouldn't fix reg here if pseudo pic
> register is used and correct code would be:
> 
> @@ -4388,7 +4388,7 @@ ix86_conditional_register_usage (void)
> 
>    /* The PIC register, if it exists, is fixed.  */
>    j = PIC_OFFSET_TABLE_REGNUM;
> -  if (j != INVALID_REGNUM)
> +  if (j != INVALID_REGNUM && !ix86_use_pseudo_pic_reg ())
>      fixed_regs[j] = call_used_regs[j] = 1;
> 
>    /* For 32-bit targets, squash the REX registers.  */

Ilya: I can't speak to the correctness of the above code or patch, but r220044
fixes the original issue I ran into.  Do you want me to keep this bug open, or
should we track the above in a separate PR?

Reply via email to