This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Tweak optabs.c's use of constant rtx_costs
On Fri, Aug 17, 2007 at 06:05:44PM +0100, Richard Sandiford wrote:
> Rask Ingemann Lambertsen <rask@sygehus.dk> writes:
> > On Fri, Aug 17, 2007 at 04:28:18PM +0100, Richard Sandiford wrote:
> >> expand_binop has code like the following:
> >>
> >> /* If we are inside an appropriately-short loop and we are optimizing,
> >> force expensive constants into a register. */
> >> if (CONSTANT_P (op0) && optimize
> >> && rtx_cost (op0, binoptab->code) > COSTS_N_INSNS (1))
> >> {
> >> if (GET_MODE (op0) != VOIDmode)
> >> op0 = convert_modes (mode, VOIDmode, op0, unsignedp);
> >> op0 = force_reg (mode, op0);
> >> }
> >
> > There is similiar code in prepare_cmp_insn(). It interferes with
> > SELECT_CC_MODE() on targets which choose the mode of the comparison result
> > depending on the constant (if any) in the comparison.
>
> Yeah, I'd noticed the prepare_cmp_insn insn thing too; it means that
> the MIPS patch I mentioned has to treat constants with a COMPARE outer
> code specially -- giving them zero cost -- even though the port never
> actually uses COMPARE itself. I didn't actually find the MIPS check
> too gross, but I did wonder if the code was still worthwhile on targets
> that do use COMPARE. It's interesting that it's a pain for yours too.
I've updated the ia16 target I posted to use "lazy" comparison like many
other targets do; initially it would miss some optimizations because of
this. I now have a few extra lines in ia16_rtx_costs() to work around it:
/* Take counter measures against prepare_cmp_insn(). */
if (outer_code == COMPARE && *total > COSTS_N_INSNS (1))
*total = COSTS_N_INSNS (1);
--
Rask Ingemann Lambertsen