re PR middle-end/53887 (ICE in hoist_edge_and_branch_if_true, at tree-switch-conversion.c:79)

gcc/
	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.

testsuite/
	PR tree-optimization/53887
	* gcc.dg/pr53887.c: New test.

From-SVN: r189389
This commit is contained in:
Steven Bosscher 2012-07-09 18:53:35 +00:00
parent 06e3e32bcd
commit 238065a73b
6 changed files with 47 additions and 4 deletions

View File

@ -1,3 +1,11 @@
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

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,24 @@
/* { 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:
;
}
}

View File

@ -125,7 +125,6 @@ static edge find_taken_edge_computed_goto (basic_block, tree);
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)
@ -1331,7 +1330,7 @@ cleanup_dead_labels (void)
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);

View File

@ -428,6 +428,7 @@ extern void debug_loop_num (unsigned, int);
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);

View File

@ -1339,8 +1339,14 @@ process_switch (gimple swtch)
{
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);