This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: Fix PR 33306 (fallout from Tweak optabs.c's use of constant rtx_costs)
- From: Richard Sandiford <richard at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 06 Sep 2007 09:06:11 +0100
- Subject: RFA: Fix PR 33306 (fallout from Tweak optabs.c's use of constant rtx_costs)
- References: <87y7gaji3x.fsf@firetop.home>
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?
Richard
gcc/
PR middle-end/33306
* optabs.c (avoid_expensive_constant): Do nothing if MODE is VOIDmode.
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c (revision 128145)
+++ gcc/optabs.c (working copy)
@@ -1359,7 +1359,8 @@ commutative_optab_p (optab binoptab)
avoid_expensive_constant (enum machine_mode mode, optab binoptab,
rtx x, bool unsignedp)
{
- if (optimize
+ if (mode != VOIDmode
+ && optimize
&& CONSTANT_P (x)
&& rtx_cost (x, binoptab->code) > COSTS_N_INSNS (1))
{