+2012-07-09 Steven Bosscher <steven@gcc.gnu.org>
+
+ PR tree-optimization/53887
+ * tree-cfg.c (group_case_labels_stmt): Make non-static.
+ * tree-flow.h (group_case_labels_stmt): Add prototype.
+ * tree-switch-conversion.c (process_switch): Use group_case_labels_stmt
+ to pre-process every switch.
+
2012-07-09 Jason Merrill <jason@redhat.com>
PR c++/53882
+2012-07-09 Steven Bosscher <steven@gcc.gnu.org>
+
+ PR tree-optimization/53887
+ * gcc.dg/pr53887.c: New test.
+
2012-07-09 Jason Merrill <jason@redhat.com>
PR c++/53882
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+enum
+{ Failed, NoError, NoDiskette }
+a;
+int b, c;
+void
+fn1 ()
+{
+ if (c)
+ a << 1;
+ switch (b)
+ {
+ default:
+ a << 1;
+ case 0:
+ b = 0;
+ case 1:
+ case NoDiskette:
+ ;
+ }
+}
+
static edge find_taken_edge_cond_expr (basic_block, tree);
static edge find_taken_edge_switch_expr (basic_block, tree);
static tree find_case_label_for_value (gimple, tree);
-static void group_case_labels_stmt (gimple);
void
init_empty_tree_cfg_for_function (struct function *fn)
the ones jumping to the same label.
Eg. three separate entries 1: 2: 3: become one entry 1..3: */
-static void
+void
group_case_labels_stmt (gimple stmt)
{
int old_size = gimple_switch_num_labels (stmt);
extern void print_loops (FILE *, int);
extern void print_loops_bb (FILE *, basic_block, int, int);
extern void cleanup_dead_labels (void);
+extern void group_case_labels_stmt (gimple);
extern void group_case_labels (void);
extern gimple first_stmt (basic_block);
extern gimple last_stmt (basic_block);
{
struct switch_conv_info info;
- /* Degenerate case with only a default label should never happen. */
- gcc_checking_assert (gimple_switch_num_labels (swtch) > 1);
+ /* Group case labels so that we get the right results from the heuristics
+ that decide on the code generation approach for this switch. */
+ group_case_labels_stmt (swtch);
+
+ /* If this switch is now a degenerate case with only a default label,
+ there is nothing left for us to do. */
+ if (gimple_switch_num_labels (swtch) < 2)
+ return "switch is a degenerate case";
collect_switch_conv_info (swtch, &info);