Commit 39426ab7 by Peter Bergner

tree-cfg.c (group_case_labels_stmt): Merge scanning and compressing loops.

	* tree-cfg.c (group_case_labels_stmt): Merge scanning and compressing
	loops.  Remove now unneeded calls to gimple_switch_set_label() that
	just set removed labels to NULL_TREE.

From-SVN: r249847
parent 059ab149
2017-06-30 Peter Bergner <bergner@vnet.ibm.com>
* tree-cfg.c (group_case_labels_stmt): Merge scanning and compressing
loops. Remove now unneeded calls to gimple_switch_set_label() that
just set removed labels to NULL_TREE.
2017-06-30 Aldy Hernandez <aldyh@redhat.com> 2017-06-30 Aldy Hernandez <aldyh@redhat.com>
* tree-ssanames.c (set_range_info_raw): Abstract from ... * tree-ssanames.c (set_range_info_raw): Abstract from ...
...@@ -16,7 +22,7 @@ ...@@ -16,7 +22,7 @@
For V16FI and V8SF_256 iterators, don't test if both operands are MEM For V16FI and V8SF_256 iterators, don't test if both operands are MEM
if <mask_applied>. For VI4F_256 iterator, use <store_mask_predicate> if <mask_applied>. For VI4F_256 iterator, use <store_mask_predicate>
instead of register_operand and <store_mask_constraint> instead of v for instead of register_operand and <store_mask_constraint> instead of v for
the input operand. Make sure both operands aren't MEMs for if not the input operand. Make sure both operands aren't MEMs for if not
<mask_applied>. <mask_applied>.
2017-06-30 Sylvestre Ledru <sylvestre@debian.org> 2017-06-30 Sylvestre Ledru <sylvestre@debian.org>
......
...@@ -1679,13 +1679,13 @@ bool ...@@ -1679,13 +1679,13 @@ bool
group_case_labels_stmt (gswitch *stmt) group_case_labels_stmt (gswitch *stmt)
{ {
int old_size = gimple_switch_num_labels (stmt); int old_size = gimple_switch_num_labels (stmt);
int i, j, base_index, new_size = old_size; int i, next_index, new_size;
basic_block default_bb = NULL; basic_block default_bb = NULL;
default_bb = label_to_block (CASE_LABEL (gimple_switch_default_label (stmt))); default_bb = label_to_block (CASE_LABEL (gimple_switch_default_label (stmt)));
/* Look for possible opportunities to merge cases. */ /* Look for possible opportunities to merge cases. */
i = 1; new_size = i = 1;
while (i < old_size) while (i < old_size)
{ {
tree base_case, base_high; tree base_case, base_high;
...@@ -1699,23 +1699,21 @@ group_case_labels_stmt (gswitch *stmt) ...@@ -1699,23 +1699,21 @@ group_case_labels_stmt (gswitch *stmt)
/* Discard cases that have the same destination as the default case. */ /* Discard cases that have the same destination as the default case. */
if (base_bb == default_bb) if (base_bb == default_bb)
{ {
gimple_switch_set_label (stmt, i, NULL_TREE);
i++; i++;
new_size--;
continue; continue;
} }
base_high = CASE_HIGH (base_case) base_high = CASE_HIGH (base_case)
? CASE_HIGH (base_case) ? CASE_HIGH (base_case)
: CASE_LOW (base_case); : CASE_LOW (base_case);
base_index = i++; next_index = i + 1;
/* Try to merge case labels. Break out when we reach the end /* Try to merge case labels. Break out when we reach the end
of the label vector or when we cannot merge the next case of the label vector or when we cannot merge the next case
label with the current one. */ label with the current one. */
while (i < old_size) while (next_index < old_size)
{ {
tree merge_case = gimple_switch_label (stmt, i); tree merge_case = gimple_switch_label (stmt, next_index);
basic_block merge_bb = label_to_block (CASE_LABEL (merge_case)); basic_block merge_bb = label_to_block (CASE_LABEL (merge_case));
wide_int bhp1 = wi::add (base_high, 1); wide_int bhp1 = wi::add (base_high, 1);
...@@ -1727,9 +1725,7 @@ group_case_labels_stmt (gswitch *stmt) ...@@ -1727,9 +1725,7 @@ group_case_labels_stmt (gswitch *stmt)
base_high = CASE_HIGH (merge_case) ? base_high = CASE_HIGH (merge_case) ?
CASE_HIGH (merge_case) : CASE_LOW (merge_case); CASE_HIGH (merge_case) : CASE_LOW (merge_case);
CASE_HIGH (base_case) = base_high; CASE_HIGH (base_case) = base_high;
gimple_switch_set_label (stmt, i, NULL_TREE); next_index++;
new_size--;
i++;
} }
else else
break; break;
...@@ -1742,23 +1738,22 @@ group_case_labels_stmt (gswitch *stmt) ...@@ -1742,23 +1738,22 @@ group_case_labels_stmt (gswitch *stmt)
edge base_edge = find_edge (gimple_bb (stmt), base_bb); edge base_edge = find_edge (gimple_bb (stmt), base_bb);
if (base_edge != NULL) if (base_edge != NULL)
remove_edge_and_dominated_blocks (base_edge); remove_edge_and_dominated_blocks (base_edge);
gimple_switch_set_label (stmt, base_index, NULL_TREE); i = next_index;
new_size--; continue;
} }
}
/* Compress the case labels in the label vector, and adjust the if (new_size < i)
length of the vector. */ gimple_switch_set_label (stmt, new_size,
for (i = 0, j = 0; i < new_size; i++) gimple_switch_label (stmt, i));
{ i = next_index;
while (! gimple_switch_label (stmt, j)) new_size++;
j++;
gimple_switch_set_label (stmt, i,
gimple_switch_label (stmt, j++));
} }
gcc_assert (new_size <= old_size); gcc_assert (new_size <= old_size);
gimple_switch_set_num_labels (stmt, new_size);
if (new_size < old_size)
gimple_switch_set_num_labels (stmt, new_size);
return new_size < old_size; return new_size < old_size;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment