RFA: Fix PR 33306 (fallout from Tweak optabs.c's use of constant rtx_costs)

Richard Guenther richard.guenther@gmail.com
Thu Sep 6 08:50:00 GMT 2007


On 9/6/07, Richard Sandiford <richard@codesourcery.com> wrote:
> Sorry, PR 33306 is second fallout from my optabs.c patch, this time on
> Alpha.  A (const_double:TF 1.0) is an expensive constant on Alpha,
> and Alpha's divtf3 expander does not specify a mode for the operands.
> So avoid_expensive_constant ends up trying to force the constant into a
> VOIDmode register:
>
> Richard Sandiford <richard@codesourcery.com> writes:
> > +/* X is to be used in mode MODE as an operand to BINOPTAB.  If we're
> > +   optimizing, and if the operand is a constant that costs more than
> > +   1 instruction, force the constant into a register and return that
> > +   register.  Return X otherwise.  UNSIGNEDP says whether X is unsigned.  */
> > +
> > +static rtx
> > +avoid_expensive_constant (enum machine_mode mode, optab binoptab,
> > +                       rtx x, bool unsignedp)
> > +{
> > +  if (optimize
> > +      && CONSTANT_P (x)
> > +      && rtx_cost (x, binoptab->code) > COSTS_N_INSNS (1))
> > +    {
> > +      if (GET_MODE (x) != VOIDmode)
> > +     x = convert_modes (mode, VOIDmode, x, unsignedp);
> > +      x = force_reg (mode, x);
> > +    }
> > +  return x;
> > +}
> ...
> > +  /* If we are optimizing, force expensive constants into a register.  */
> > +  xop0 = avoid_expensive_constant (mode0, binoptab, xop0, unsignedp);
> > +  if (!shift_optab_p (binoptab))
> > +    xop1 = avoid_expensive_constant (mode1, binoptab, xop1, unsignedp);
>
> When mode0 or mode1 is VOIDmode, we could fall back to using the
> result mode instead.  Or avoid_expensive_constant could use the
> mode of X when the mode is VOIDmode, although this doesn't fix
> the case where X is a CONST_INT and the mode is VOIDmode.
> However, expand_binop_directly is careful to pass unmodified
> operands when the expander specifies no mode, so I think that's
> the right fix here too.
>
> Bootstrapped & regression-tested on x86_64-linux-gnu.  Serge Belyshev
> reports that it fixes C-only bootstrap on Alpha too.  OK to install?

Ok.

Thanks,
Richard.



More information about the Gcc-patches mailing list