This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] combine: Query can_change_dest_mode before changing dest mode
On Thu, Nov 24, 2016 at 11:04:13AM +0100, Georg-Johann Lay wrote:
> >@@ -11287,7 +11287,8 @@ change_zero_ext (rtx pat)
> > else if (GET_CODE (x) == ZERO_EXTEND
> > && SCALAR_INT_MODE_P (mode)
> > && REG_P (XEXP (x, 0))
> >- && HARD_REGISTER_P (XEXP (x, 0)))
> >+ && HARD_REGISTER_P (XEXP (x, 0))
> >+ && can_change_dest_mode (XEXP (x, 0), 0, mode))
> > {
> > size = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0)));
> > x = gen_rtx_REG (mode, REGNO (XEXP (x, 0)));
>
> IIUC, the will also avoid changing, for example, QI to HI if HI occupies
> more hard regs than QI? Great!
Only for hard registers, but this code only handles hard registers anyway.
>From can_change_dest_mode:
/* Allow hard registers if the new mode is legal, and occupies no more
registers than the old mode. */
if (regno < FIRST_PSEUDO_REGISTER)
return (HARD_REGNO_MODE_OK (regno, mode)
&& REG_NREGS (x) >= hard_regno_nregs[regno][mode]);
Segher