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]

MIPS: "bal" micro-optimization


Hello,

 MIPS startup files use "bal . + 8" to get the value of the PC.  This 
clearly shows the code in question is not interested in actually taking 
the branch as a side effect.  Replacing these instructions with "bltzal 
$0, . + 8" keeps the code retrieving the PC into $ra, yet the branch is 
not taken saving an unnecessary pipeline flush.

2005-05-03  Maciej W. Rozycki  <macro@linux-mips.org>

	* config/mips/mips.h (TRAMPOLINE_TEMPLATE): Use "bltzal" instead 
	of "bal" to save a pipeline flush.
	(CRT_CALL_STATIC_FUNCTION): Likewise.

 Please apply.

  Maciej

gcc-4.0.0-mips-bltzal.patch
diff -up --recursive --new-file gcc-4.0.0.macro/gcc/config/mips/mips.h gcc-4.0.0/gcc/config/mips/mips.h
--- gcc-4.0.0.macro/gcc/config/mips/mips.h	2005-04-15 07:00:18.000000000 +0000
+++ gcc-4.0.0/gcc/config/mips/mips.h	2005-05-03 15:00:17.000000000 +0000
@@ -2370,7 +2370,7 @@ typedef struct mips_args {
 #define TRAMPOLINE_TEMPLATE(STREAM)					 \
 {									 \
   fprintf (STREAM, "\t.word\t0x03e00821\t\t# move   $1,$31\n");		\
-  fprintf (STREAM, "\t.word\t0x04110001\t\t# bgezal $0,.+8\n");		\
+  fprintf (STREAM, "\t.word\t0x04100001\t\t# bltzal $0,.+8\n");		\
   fprintf (STREAM, "\t.word\t0x00000000\t\t# nop\n");			\
   if (ptr_mode == DImode)						\
     {									\
@@ -2997,7 +2997,7 @@ while (0)
 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)	\
    asm (SECTION_OP "\n\
 	.set noreorder\n\
-	bal 1f\n\
+	bltzal $0, 1f\n\
 	nop\n\
 1:	.cpload $31\n\
 	.set reorder\n\
@@ -3009,7 +3009,7 @@ while (0)
 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)	\
    asm (SECTION_OP "\n\
 	.set noreorder\n\
-	bal 1f\n\
+	bltzal $0, 1f\n\
 	nop\n\
 1:	.set reorder\n\
 	.cpsetup $31, $2, 1b\n\


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