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]: Avoid basic block reordering for 68HC1X when -Os


Hi!

When optimising for size the basic block reordering makes the resulting
code larger.  Since size is critical for HC11/HC12, it is best to
disable it when -Os.  Such disabling only concerns HC11/HC12 port.

I've committed the following patch on mainline and 3_1 branch.

	Stephane

2002-06-28  Stephane Carrez  <stcarrez@nerim.fr>

	* config/m68hc11/m68hc11.h (OPTIMIZATION_OPTIONS): Define.
	* config/m68hc11/m68hc11-protos.h (m68hc11_optimization_options):
	Declare.
	* config/m68hc11/m68hc11.c (m68hc11_optimization_options): New,
	do not reorder basic blocks at the end when optimizing for size.

Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.45
diff -u -p -r1.45 m68hc11.c
--- config/m68hc11/m68hc11.c	28 Jun 2002 20:26:16 -0000	1.45
+++ config/m68hc11/m68hc11.c	28 Jun 2002 20:41:00 -0000
@@ -288,6 +288,21 @@ m68hc11_override_options ()
 }
 
 
+int
+m68hc11_optimization_options (level, size)
+     int level ATTRIBUTE_UNUSED;
+     int size;
+{
+  /* When optimizing for size, do not reorder basic blocks because
+     it duplicates some insns for speed and this results in larder code.
+     This reordering can still be enabled but explicitly.  */
+  if (size)
+    {
+      flag_reorder_blocks = 0;
+    }
+  return 0;
+}
+
 void
 m68hc11_conditional_register_usage ()
 {
Index: config/m68hc11/m68hc11.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.h,v
retrieving revision 1.44
diff -u -p -r1.44 m68hc11.h
--- config/m68hc11/m68hc11.h	12 Jun 2002 03:06:18 -0000	1.44
+++ config/m68hc11/m68hc11.h	28 Jun 2002 20:41:02 -0000
@@ -1,7 +1,7 @@
 /* Definitions of target machine for GNU compiler.
    Motorola 68HC11 and 68HC12.
    Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-   Contributed by Stephane Carrez (stcarrez@worldnet.fr)
+   Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
 This file is part of GNU CC.
 
@@ -213,6 +213,10 @@ extern const char *m68hc11_soft_reg_coun
    `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
 
 #define OVERRIDE_OPTIONS	m68hc11_override_options ();
+
+/* Define this to change the optimizations performed by default.  */
+#define OPTIMIZATION_OPTIONS(LEVEL, SIZE) \
+m68hc11_optimization_options(LEVEL, SIZE)
 
 
 /* Define cost parameters for a given processor variant.  */
Index: config/m68hc11/m68hc11-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11-protos.h,v
retrieving revision 1.16
diff -u -p -r1.16 m68hc11-protos.h
--- config/m68hc11/m68hc11-protos.h	4 Jun 2002 07:09:08 -0000	1.16
+++ config/m68hc11/m68hc11-protos.h	28 Jun 2002 20:41:02 -0000
@@ -1,6 +1,6 @@
 /* Prototypes for exported functions defined in m68hc11.c
    Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-   Contributed by Stephane Carrez (stcarrez@worldnet.fr)
+   Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
 This file is part of GNU CC.
 
@@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA.  */
 
 
 extern int m68hc11_override_options PARAMS((void));
+extern int m68hc11_optimization_options PARAMS((int,int));
 extern void m68hc11_conditional_register_usage PARAMS((void));
 extern int hard_regno_mode_ok PARAMS((int, enum machine_mode));
 

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