This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Optimize loading of special constants on h8300.
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] Optimize loading of special constants on h8300.
- From: Kazu Hirata <kazu at hxi dot com>
Hi,
Attached is a patch to optimize loading of several special
constants on h8300 port.
Without the patch, gcc uses the straightforward mov.l when the
following constants are loaded.
0x0000ffff
0x0000fffe
0xffff0000
0xfffe0000
0x00010000
0x00020000
The patch makes the above constants be loaded by zeroing a register
followed by an increment or decrement insn.
Testing with newlib shows several instances of 65536 (0x00010000) are
optimized.
Since the cc for the alternative in question is defined to be clobber
when loading a constant to a reg:SI, applying a patch does not have
any bad side effect.
Tested on the h8300 port. OK to apply?
Thanks,
Kazu Hirata
2001-08-29 Kazu Hirata <kazu@hxi.com>
* h8300.md (movsi_h8300hs): Optimize loading of several
special constants.
Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.31
diff -c -p -r1.31 h8300.md
*** h8300.md 2001/07/23 21:46:38 1.31
--- h8300.md 2001/08/04 05:22:54
***************
*** 436,447 ****
return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
}
! /* Now look for small negative numbers. We can subtract them
! from zero to get the desired constant. */
! if (val == -4 || val == -2 || val == -1)
{
! operands[1] = GEN_INT (-INTVAL (operands[1]));
! return \"sub.l\\t%S0,%S0\;subs\\t%1,%S0\";
}
}
}
--- 493,523 ----
return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
}
! /* Look for constants that can be obtained by subs, inc, and
! dec to 0. */
! switch (val)
{
! case 0xffffffff:
! return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
! case 0xfffffffe:
! return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
! case 0xfffffffc:
! return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
!
! case 0x0000ffff:
! return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
! case 0x0000fffe:
! return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
!
! case 0xffff0000:
! return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
! case 0xfffe0000:
! return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
!
! case 0x00010000:
! return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
! case 0x00020000:
! return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
}
}
}