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]

[C PATCH] Switch optimize


Hi,
Here's a patch which reorders the conversion sequence of the index on
a switch jump table. This removes an additional truncation and improves
i86 code (at least).

old i86
        movzbl  8(%ebp), %eax
        subb    $32, %al
        movsbl  %al,%edx
        addb    $32, %al
        cmpl    $25, %edx
        ja      .L11
        jmp     *.L12(,%edx,4)

new i86
        movsbl  8(%ebp),%eax
        leal    -32(%eax), %edx
        cmpl    $25, %edx
        ja      .L11
        jmp     *.L12(,%edx,4)

ok? booted&tested on i686-pc-linux-gnu

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-05-29  Nathan Sidwell  <nathan@codesourcery.com>

	* stmt (expand_end_case): Reorder conversion sequence for jump
	table to avoid extra truncations.

Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.146
diff -c -3 -p -r1.146 stmt.c
*** stmt.c	2000/05/25 16:33:32	1.146
--- stmt.c	2000/05/29 08:52:22
*************** expand_end_case (orig_index)
*** 5571,5580 ****
  #ifdef HAVE_tablejump
  	  if (! win && HAVE_tablejump)
  	    {
! 	      index_expr = convert (thiscase->data.case_stmt.nominal_type,
! 				    fold (build (MINUS_EXPR, index_type,
! 						 index_expr, minval)));
! 	      index_type = TREE_TYPE (index_expr);
  	      index = expand_expr (index_expr, NULL_RTX, VOIDmode, 0);
  	      emit_queue ();
  	      index = protect_from_queue (index, 0);
--- 5571,5580 ----
  #ifdef HAVE_tablejump
  	  if (! win && HAVE_tablejump)
  	    {
! 	      index_type = thiscase->data.case_stmt.nominal_type;
! 	      index_expr = fold (build (MINUS_EXPR, index_type,
! 			         convert (index_type, index_expr),
! 				 convert (index_type, minval)));
  	      index = expand_expr (index_expr, NULL_RTX, VOIDmode, 0);
  	      emit_queue ();
  	      index = protect_from_queue (index, 0);

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