This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300: Improve loads of certain constants.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 25 Jun 2003 07:54:53 -0400 (EDT)
- Subject: [patch] h8300: Improve loads of certain constants.
Hi,
Attached is a patch to improve loads of certain constants.
On H8/300, if one wants to load a constant whose upper and lower part
are the same like 0x12341234, then gcc generates
mov.w #4660,r0
mov.w #4660,r1
This can be improved as
mov.w #4660,r0
mov.w r0,r1
Tested on h8300 port. Committed.
Kazu Hirata
2003-06-25 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (compute_mov_length): Adjust for the
new optimization.
* config/h8300/h8300.md (*movsi_h8300): Optimize the load of
an SImode constant whose upper and lower are the same.
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.241
diff -u -r1.241 h8300.c
--- h8300.c 25 Jun 2003 03:47:31 -0000 1.241
+++ h8300.c 25 Jun 2003 04:08:47 -0000
@@ -1876,6 +1876,10 @@
if ((INTVAL (src) & 0xffff) == 0)
return 6;
+
+ if ((INTVAL (src) & 0xffff)
+ == ((INTVAL (src) >> 16) & 0xffff))
+ return 6;
}
return 8;
}
Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.224
diff -u -r1.224 h8300.md
--- h8300.md 25 Jun 2003 03:47:31 -0000 1.224
+++ h8300.md 25 Jun 2003 04:08:48 -0000
@@ -396,14 +396,19 @@
}
else
{
- /* See if either half is zero. If so, use sub.w to clear
- that half. */
if (GET_CODE (operands[1]) == CONST_INT)
{
+ /* If either half is zero, use sub.w to clear that
+ half. */
if ((INTVAL (operands[1]) & 0xffff) == 0)
return \"mov.w %e1,%e0\;sub.w %f0,%f0\";
if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
return \"sub.w %e0,%e0\;mov.w %f1,%f0\";
+ /* If the upper half and the lower half are the same,
+ copy one half to the other. */
+ if ((INTVAL (operands[1]) & 0xffff)
+ == ((INTVAL (operands[1]) >> 16) & 0xffff))
+ return \"mov.w\\t%e1,%e0\;mov.w\\t%e0,%f0\";
}
return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
}