This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] h8300.c: Optimize code in the normal mode.


Hi,

Attached is a patch to optimize code in the normal mode.

Currently, GCC overestimates the length of the instruction

  mov.l @_g,er0

as 8 bytes in the normal mode even though it actually only takes 6
bytes.  This is because GCC thinks that @_g is a 32-bit address, but
in the normal mode, every address is 16-bit wide.

The patch catches the above case as well as a constant address with a
displacement like @(_g+4), resulting in tighter length calculation.

Tested on h8300-hms.  Committed.

Kazu Hirata

2004-01-26  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300.c (h8300_tiny_constant_address_p): Accept
	constant addresses in the normal mode.

Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.265
diff -u -r1.265 h8300.c
--- h8300.c	26 Jan 2004 20:21:11 -0000	1.265
+++ h8300.c	26 Jan 2004 20:29:05 -0000
@@ -4437,8 +4437,11 @@
   switch (GET_CODE (x))
     {
     case SYMBOL_REF:
-      /* We accept symbols declared with tiny_data.  */
-      return (SYMBOL_REF_FLAGS (x) & SYMBOL_FLAG_TINY_DATA) != 0;
+      /* In the normal mode, any symbol fits in the 16-bit absolute
+	 address range.  We also accept symbols declared with
+	 tiny_data.  */
+      return (TARGET_NORMAL_MODE
+	      || (SYMBOL_REF_FLAGS (x) & SYMBOL_FLAG_TINY_DATA) != 0);
 
     case CONST_INT:
       addr = INTVAL (x);
@@ -4447,6 +4450,9 @@
 		  && (IN_RANGE (addr, h1, h2) || IN_RANGE (addr, h3, h4)))
 	      || (TARGET_H8300S
 		  && (IN_RANGE (addr, s1, s2) || IN_RANGE (addr, s3, s4))));
+
+    case CONST:
+      return TARGET_NORMAL_MODE;
 
     default:
       return 0;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]