]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/53881 (ICE in hoist_edge_and_branch_if_true)
authorSteven Bosscher <steven@gcc.gnu.org>
Mon, 23 Jul 2012 09:26:41 +0000 (09:26 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Mon, 23 Jul 2012 09:26:41 +0000 (09:26 +0000)
gcc/
PR tree-optimization/53881
* tree-cfg.c (group_case_labels_stmt): Look up the basic block
for each label and compare them instead of labels.

testsuite/
PR tree-optimization/53881
* gcc.dg/pr53881.c: Renamed to ...
* gcc.dg/pr53881-1.c: ... this.
* gcc.dg/pr53881-2.c: New test.

From-SVN: r189779

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr53881-1.c [moved from gcc/testsuite/gcc.dg/pr53881.c with 100% similarity]
gcc/testsuite/gcc.dg/pr53881-2.c [new file with mode: 0644]
gcc/tree-cfg.c

index 68800a6640068927f89a720f475f1c3acb9c77d9..5f498e82fd3929cacd924cdb001ede548055c1b6 100644 (file)
@@ -1,3 +1,9 @@
+2012-07-22  Steven Bosscher  <steven@gcc.gnu.org>
+
+       PR tree-optimization/53881
+       * tree-cfg.c (group_case_labels_stmt): Look up the basic block
+       for each label and compare them instead of labels.
+
 2012-07-22  Steven Bosscher <steven@gcc.gnu.org>
 
        * opts.c (common_handle_option): Do not set 
index f2bb333adbea3328bff4b1e942b11b67915ccd28..75b8d097e5f4bdefa794c6b9b2e280568f08fdc7 100644 (file)
@@ -1,3 +1,10 @@
+2012-07-22  Steven Bosscher  <steven@gcc.gnu.org>
+
+       PR tree-optimization/53881
+       * gcc.dg/pr53881.c: Renamed to ...
+       * gcc.dg/pr53881-1.c: ... this.
+       * gcc.dg/pr53881-2.c: New test.
+
 2012-07-22  Hans-Peter Nilsson  <hp@axis.com>
 
        Handle recent changes in default atomics for cris*-*-linux*.
diff --git a/gcc/testsuite/gcc.dg/pr53881-2.c b/gcc/testsuite/gcc.dg/pr53881-2.c
new file mode 100644 (file)
index 0000000..f6f8f8b
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a,b,c;
+void
+fn1 ()
+{
+  switch (a)
+    {
+    case 0:
+    case 10:
+      b=c;
+out_bcon:
+      break;
+    case 3:
+      goto out_bcon;
+    }
+}
+
index c9187b924565fc0406d6ac2d610f9f7681a5605d..88efc785af6c8b1b3e3c328762f5eb8ac6cdf57f 100644 (file)
@@ -1332,8 +1332,7 @@ group_case_labels_stmt (gimple stmt)
 {
   int old_size = gimple_switch_num_labels (stmt);
   int i, j, new_size = old_size;
-  tree default_case = NULL_TREE;
-  tree default_label = NULL_TREE;
+  basic_block default_bb = NULL;
   bool has_default;
 
   /* The default label is always the first case in a switch
@@ -1342,8 +1341,8 @@ group_case_labels_stmt (gimple stmt)
   if (!CASE_LOW (gimple_switch_default_label (stmt))
       && !CASE_HIGH (gimple_switch_default_label (stmt)))
     {
-      default_case = gimple_switch_default_label (stmt);
-      default_label = CASE_LABEL (default_case);
+      tree default_case = gimple_switch_default_label (stmt);
+      default_bb = label_to_block (CASE_LABEL (default_case));
       has_default = true;
     }
   else
@@ -1356,15 +1355,17 @@ group_case_labels_stmt (gimple stmt)
     i = 0;
   while (i < old_size)
     {
-      tree base_case, base_label, base_high;
+      tree base_case, base_high;
+      basic_block base_bb;
+
       base_case = gimple_switch_label (stmt, i);
 
       gcc_assert (base_case);
-      base_label = CASE_LABEL (base_case);
+      base_bb = label_to_block (CASE_LABEL (base_case));
 
       /* Discard cases that have the same destination as the
         default case.  */
-      if (base_label == default_label)
+      if (base_bb == default_bb)
        {
          gimple_switch_set_label (stmt, i, NULL_TREE);
          i++;
@@ -1383,13 +1384,13 @@ group_case_labels_stmt (gimple stmt)
       while (i < old_size)
        {
          tree merge_case = gimple_switch_label (stmt, i);
-         tree merge_label = CASE_LABEL (merge_case);
+         basic_block merge_bb = label_to_block (CASE_LABEL (merge_case));
          double_int bhp1 = double_int_add (tree_to_double_int (base_high),
                                            double_int_one);
 
          /* Merge the cases if they jump to the same place,
             and their ranges are consecutive.  */
-         if (merge_label == base_label
+         if (merge_bb == base_bb
              && double_int_equal_p (tree_to_double_int (CASE_LOW (merge_case)),
                                     bhp1))
            {