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]

Re: [PATCH] Fix PR tree-opt/17343, cases do not combine with default



On Oct 1, 2004, at 11:01 AM, Diego Novillo wrote:


On Fri, 2004-10-01 at 01:19, Andrew Pinski wrote:

	* tree-cfg.c (group_case_labels): Make sure that the last
	case was a default and if so get the label.
	When the label we looking at is the default, decrement the
	new_size.

Looks OK. Any chance you can add a test for this?

And this is what I applied after being reminded by Steven B. that the default label is always the last entry in the switch statement after gimplification.

Thanks,
Andrew Pinski

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.60
diff -u -p -r2.60 tree-cfg.c
--- tree-cfg.c	30 Sep 2004 18:27:25 -0000	2.60
+++ tree-cfg.c	1 Oct 2004 15:17:39 -0000
@@ -935,7 +935,12 @@ group_case_labels (void)
 	  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);
+	  tree default_case = TREE_VEC_ELT (labels, old_size - 1);
+ 	  tree default_label;
+
+	  /* The default lable is always the last case in a switch
+	     statement after gimplification.  */
+	  default_label = CASE_LABEL (default_case);

 	  /* Look for possible opportunities to merge cases.
 	     Ignore the last element of the label vector because it
@@ -955,6 +960,7 @@ group_case_labels (void)
 		{
 		  TREE_VEC_ELT (labels, i) = NULL_TREE;
 		  i++;
+		  new_size--;
 		  continue;
 		}


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