public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Remove cases that have the same destination as the default case
@ 2004-07-07 22:44 Steven Bosscher
  2004-07-07 22:50 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Bosscher @ 2004-07-07 22:44 UTC (permalink / raw)
  To: gcc-patches

Hi,

I think this one is pretty obvious.  When a case leads to the same
label as the default case, it is redundant, so we can remove it.

Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK?

Gr.
Steven


Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.24
diff -c -3 -p -r2.24 tree-cfg.c
*** tree-cfg.c	30 Jun 2004 21:11:26 -0000	2.24
--- tree-cfg.c	4 Jul 2004 20:56:30 -0000
*************** group_case_labels (void)
*** 937,942 ****
--- 937,943 ----
  	  tree labels = SWITCH_LABELS (stmt);
  	  int old_size = TREE_VEC_LENGTH (labels);
  	  int i, j, new_size = old_size;
+ 	  tree default_label = TREE_VEC_ELT (labels, old_size - 1);
  
  	  /* Look for possible opportunities to merge cases.
  	     Ignore the last element of the label vector because it
*************** group_case_labels (void)
*** 950,957 ****
  	      if (! base_case)
  		abort ();
  
- 	      type = TREE_TYPE (CASE_LOW (base_case));
  	      base_label = CASE_LABEL (base_case);
  	      base_high = CASE_HIGH (base_case) ?
  		CASE_HIGH (base_case) : CASE_LOW (base_case);
  
--- 951,968 ----
  	      if (! base_case)
  		abort ();
  
  	      base_label = CASE_LABEL (base_case);
+ 
+ 	      /* Discard cases that have the same destination as the
+ 		 default case.  */
+ 	      if (base_label == default_label)
+ 		{
+ 		  TREE_VEC_ELT (labels, i) = NULL_TREE;
+ 		  i++;
+ 		  continue;
+ 		}
+ 
+ 	      type = TREE_TYPE (CASE_LOW (base_case));
  	      base_high = CASE_HIGH (base_case) ?
  		CASE_HIGH (base_case) : CASE_LOW (base_case);
  

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Remove cases that have the same destination as the default case
  2004-07-07 22:44 Remove cases that have the same destination as the default case Steven Bosscher
@ 2004-07-07 22:50 ` Richard Henderson
  2004-07-07 23:03   ` Steven Bosscher
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2004-07-07 22:50 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: gcc-patches

On Thu, Jul 08, 2004 at 12:11:10AM +0200, Steven Bosscher wrote:
> 
> 

Nice patch.  ChangeLog entry needs some work though.  ;-)


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Remove cases that have the same destination as the default case
  2004-07-07 22:50 ` Richard Henderson
@ 2004-07-07 23:03   ` Steven Bosscher
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Bosscher @ 2004-07-07 23:03 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches

On Thursday 08 July 2004 00:14, Richard Henderson wrote:
> On Thu, Jul 08, 2004 at 12:11:10AM +0200, Steven Bosscher wrote:
>
>
>
> Nice patch.  ChangeLog entry needs some work though.  ;-)

Whoops :-)

	* tree-cfg (group_case_labels): Remove case labels that have the
	same target as the default case.

Gr.
Steven

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-07 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-07 22:44 Remove cases that have the same destination as the default case Steven Bosscher
2004-07-07 22:50 ` Richard Henderson
2004-07-07 23:03   ` Steven Bosscher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).