diff options
author | Steven Bosscher <steven@gcc.gnu.org> | 2012-07-23 09:26:41 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2012-07-23 09:26:41 +0000 |
commit | a7953e99920e5928e097e913e23751ab09686430 (patch) | |
tree | df7beb4a840ad1542fd80829ec8ac762bde123fe /gcc/tree-cfg.c | |
parent | 85b259cb541eda83b06ca7e4225af155cb218f3c (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@189779 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index c9187b92456..88efc785af6 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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)) { |