This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

[Xtensa] fix a performance problem in GAS


Sterling Augustine did some profiling of GAS and found that for some inputs the Xtensa port was spending a lot of time repeatedly finding the maximum pipeline stage number. He fixed GAS to save this value and only compute it once. Just for good measure, I also fixed it in the xtensa-isa.c code. I tested both changes by running the testsuites for an xtensa-elf target. Committed.

bfd/
2008-03-03  Bob Wilson  <bob.wilson@acm.org>
	
	* xtensa-isa.c (xtensa_isa_num_pipe_stages): Make max_stage static and
	only compute its value once.

gas/
2008-03-03  Sterling Augustine  <sterling@tensilica.com>
	    Bob Wilson  <bob.wilson@acm.org>
	
	* config/tc-xtensa.c (xtensa_num_pipe_stages): New.
	(md_begin): Initialize it.
	(resources_conflict): Use it.
Index: bfd/xtensa-isa.c
===================================================================
RCS file: /cvs/src/src/bfd/xtensa-isa.c,v
retrieving revision 1.10
diff -u -r1.10 xtensa-isa.c
--- bfd/xtensa-isa.c	3 Jul 2007 14:26:43 -0000	1.10
+++ bfd/xtensa-isa.c	3 Mar 2008 23:10:35 -0000
@@ -1,5 +1,5 @@
 /* Configurable Xtensa ISA support.
-   Copyright 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -411,7 +411,12 @@
   xtensa_opcode opcode;
   xtensa_funcUnit_use *use;
   int num_opcodes, num_uses;
-  int i, stage, max_stage = XTENSA_UNDEFINED;
+  int i, stage;
+  static int max_stage = XTENSA_UNDEFINED;
+
+  /* Only compute the value once.  */
+  if (max_stage != XTENSA_UNDEFINED)
+    return max_stage + 1;
 
   num_opcodes = xtensa_isa_num_opcodes (isa);
   for (opcode = 0; opcode < num_opcodes; opcode++)
Index: gas/config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.98
diff -u -r1.98 tc-xtensa.c
--- gas/config/tc-xtensa.c	5 Feb 2008 19:39:08 -0000	1.98
+++ gas/config/tc-xtensa.c	3 Mar 2008 23:10:40 -0000
@@ -79,6 +79,7 @@
 
 static vliw_insn cur_vinsn;
 
+unsigned xtensa_num_pipe_stages;
 unsigned xtensa_fetch_width = XCHAL_INST_FETCH_WIDTH;
 
 static enum debug_info_type xt_saved_debug_type = DEBUG_NONE;
@@ -5084,6 +5085,8 @@
   xtensa_rsr_lcount_opcode = xtensa_opcode_lookup (isa, "rsr.lcount");
   xtensa_waiti_opcode = xtensa_opcode_lookup (isa, "waiti");
 
+  xtensa_num_pipe_stages = xtensa_isa_num_pipe_stages (isa);
+
   init_op_placement_info_table ();
 
   /* Set up the assembly state.  */
@@ -6006,7 +6009,7 @@
     {
       xtensa_isa isa = xtensa_default_isa;
       rt = new_resource_table
-	(isa, xtensa_isa_num_pipe_stages (isa),
+	(isa, xtensa_num_pipe_stages,
 	 xtensa_isa_num_funcUnits (isa),
 	 (unit_num_copies_func) xtensa_funcUnit_num_copies,
 	 (opcode_num_units_func) xtensa_opcode_num_funcUnit_uses,

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