Commit a30fe4b6 by Richard Biener Committed by Richard Biener

bitmap.c (bitmap_elem_to_freelist): Set indx to -1.

2016-10-07  Richard Biener  <rguenther@suse.de>

	* bitmap.c (bitmap_elem_to_freelist): Set indx to -1.
	* bitmap.h (bmp_iter_set): When advancing to the next element
	check that we didn't remove the current one.
	(bmp_iter_and): Likewise.
	(bmp_iter_and_compl): Likewise.
	* tree-ssa.c (release_defs_bitset): Do not remove worklist bit
	we currently iterate on but keep a one-level queue.
	* sched-deps.c (remove_from_deps): Do not clear current bit
	but keep a one-level queue.

From-SVN: r240859
parent a93cdc5c
2016-10-07 Richard Biener <rguenther@suse.de>
* bitmap.c (bitmap_elem_to_freelist): Set indx to -1.
* bitmap.h (bmp_iter_set): When advancing to the next element
check that we didn't remove the current one.
(bmp_iter_and): Likewise.
(bmp_iter_and_compl): Likewise.
* tree-ssa.c (release_defs_bitset): Do not remove worklist bit
we currently iterate on but keep a one-level queue.
* sched-deps.c (remove_from_deps): Do not clear current bit
but keep a one-level queue.
2016-10-07 Jakub Jelinek <jakub@redhat.com> 2016-10-07 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/77664 PR tree-optimization/77664
......
...@@ -66,6 +66,7 @@ bitmap_elem_to_freelist (bitmap head, bitmap_element *elt) ...@@ -66,6 +66,7 @@ bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
bitmap_obstack *bit_obstack = head->obstack; bitmap_obstack *bit_obstack = head->obstack;
elt->next = NULL; elt->next = NULL;
elt->indx = -1;
if (bit_obstack) if (bit_obstack)
{ {
elt->prev = bit_obstack->elements; elt->prev = bit_obstack->elements;
......
...@@ -618,6 +618,9 @@ bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no) ...@@ -618,6 +618,9 @@ bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
bi->word_no++; bi->word_no++;
} }
/* Make sure we didn't remove the element while iterating. */
gcc_checking_assert (bi->elt1->indx != -1U);
/* Advance to the next element. */ /* Advance to the next element. */
bi->elt1 = bi->elt1->next; bi->elt1 = bi->elt1->next;
if (!bi->elt1) if (!bi->elt1)
...@@ -664,6 +667,9 @@ bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no) ...@@ -664,6 +667,9 @@ bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no)
/* Advance to the next identical element. */ /* Advance to the next identical element. */
do do
{ {
/* Make sure we didn't remove the element while iterating. */
gcc_checking_assert (bi->elt1->indx != -1U);
/* Advance elt1 while it is less than elt2. We always want /* Advance elt1 while it is less than elt2. We always want
to advance one elt. */ to advance one elt. */
do do
...@@ -674,6 +680,9 @@ bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no) ...@@ -674,6 +680,9 @@ bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no)
} }
while (bi->elt1->indx < bi->elt2->indx); while (bi->elt1->indx < bi->elt2->indx);
/* Make sure we didn't remove the element while iterating. */
gcc_checking_assert (bi->elt2->indx != -1U);
/* Advance elt2 to be no less than elt1. This might not /* Advance elt2 to be no less than elt1. This might not
advance. */ advance. */
while (bi->elt2->indx < bi->elt1->indx) while (bi->elt2->indx < bi->elt1->indx)
...@@ -726,11 +735,17 @@ bmp_iter_and_compl (bitmap_iterator *bi, unsigned *bit_no) ...@@ -726,11 +735,17 @@ bmp_iter_and_compl (bitmap_iterator *bi, unsigned *bit_no)
bi->word_no++; bi->word_no++;
} }
/* Make sure we didn't remove the element while iterating. */
gcc_checking_assert (bi->elt1->indx != -1U);
/* Advance to the next element of elt1. */ /* Advance to the next element of elt1. */
bi->elt1 = bi->elt1->next; bi->elt1 = bi->elt1->next;
if (!bi->elt1) if (!bi->elt1)
return false; return false;
/* Make sure we didn't remove the element while iterating. */
gcc_checking_assert (! bi->elt2 || bi->elt2->indx != -1U);
/* Advance elt2 until it is no less than elt1. */ /* Advance elt2 until it is no less than elt1. */
while (bi->elt2 && bi->elt2->indx < bi->elt1->indx) while (bi->elt2 && bi->elt2->indx < bi->elt1->indx)
bi->elt2 = bi->elt2->next; bi->elt2 = bi->elt2->next;
......
...@@ -3992,8 +3992,14 @@ remove_from_deps (struct deps_desc *deps, rtx_insn *insn) ...@@ -3992,8 +3992,14 @@ remove_from_deps (struct deps_desc *deps, rtx_insn *insn)
removed = remove_from_dependence_list (insn, &deps->last_pending_memory_flush); removed = remove_from_dependence_list (insn, &deps->last_pending_memory_flush);
deps->pending_flush_length -= removed; deps->pending_flush_length -= removed;
unsigned to_clear = -1U;
EXECUTE_IF_SET_IN_REG_SET (&deps->reg_last_in_use, 0, i, rsi) EXECUTE_IF_SET_IN_REG_SET (&deps->reg_last_in_use, 0, i, rsi)
{ {
if (to_clear != -1U)
{
CLEAR_REGNO_REG_SET (&deps->reg_last_in_use, to_clear);
to_clear = -1U;
}
struct deps_reg *reg_last = &deps->reg_last[i]; struct deps_reg *reg_last = &deps->reg_last[i];
if (reg_last->uses) if (reg_last->uses)
remove_from_dependence_list (insn, &reg_last->uses); remove_from_dependence_list (insn, &reg_last->uses);
...@@ -4005,8 +4011,10 @@ remove_from_deps (struct deps_desc *deps, rtx_insn *insn) ...@@ -4005,8 +4011,10 @@ remove_from_deps (struct deps_desc *deps, rtx_insn *insn)
remove_from_dependence_list (insn, &reg_last->clobbers); remove_from_dependence_list (insn, &reg_last->clobbers);
if (!reg_last->uses && !reg_last->sets && !reg_last->implicit_sets if (!reg_last->uses && !reg_last->sets && !reg_last->implicit_sets
&& !reg_last->clobbers) && !reg_last->clobbers)
CLEAR_REGNO_REG_SET (&deps->reg_last_in_use, i); to_clear = i;
} }
if (to_clear != -1U)
CLEAR_REGNO_REG_SET (&deps->reg_last_in_use, to_clear);
if (CALL_P (insn)) if (CALL_P (insn))
{ {
......
...@@ -551,58 +551,70 @@ release_defs_bitset (bitmap toremove) ...@@ -551,58 +551,70 @@ release_defs_bitset (bitmap toremove)
most likely run in slightly superlinear time, rather than the most likely run in slightly superlinear time, rather than the
pathological quadratic worst case. */ pathological quadratic worst case. */
while (!bitmap_empty_p (toremove)) while (!bitmap_empty_p (toremove))
EXECUTE_IF_SET_IN_BITMAP (toremove, 0, j, bi) {
{ unsigned to_remove_bit = -1U;
bool remove_now = true; EXECUTE_IF_SET_IN_BITMAP (toremove, 0, j, bi)
tree var = ssa_name (j); {
gimple *stmt; if (to_remove_bit != -1U)
imm_use_iterator uit; {
bitmap_clear_bit (toremove, to_remove_bit);
FOR_EACH_IMM_USE_STMT (stmt, uit, var) to_remove_bit = -1U;
{ }
ssa_op_iter dit;
def_operand_p def_p;
/* We can't propagate PHI nodes into debug stmts. */ bool remove_now = true;
if (gimple_code (stmt) == GIMPLE_PHI tree var = ssa_name (j);
|| is_gimple_debug (stmt)) gimple *stmt;
continue; imm_use_iterator uit;
/* If we find another definition to remove that uses FOR_EACH_IMM_USE_STMT (stmt, uit, var)
the one we're looking at, defer the removal of this {
one, so that it can be propagated into debug stmts ssa_op_iter dit;
after the other is. */ def_operand_p def_p;
FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, dit, SSA_OP_DEF)
{ /* We can't propagate PHI nodes into debug stmts. */
tree odef = DEF_FROM_PTR (def_p); if (gimple_code (stmt) == GIMPLE_PHI
|| is_gimple_debug (stmt))
continue;
/* If we find another definition to remove that uses
the one we're looking at, defer the removal of this
one, so that it can be propagated into debug stmts
after the other is. */
FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, dit, SSA_OP_DEF)
{
tree odef = DEF_FROM_PTR (def_p);
if (bitmap_bit_p (toremove, SSA_NAME_VERSION (odef))) if (bitmap_bit_p (toremove, SSA_NAME_VERSION (odef)))
{ {
remove_now = false; remove_now = false;
break; break;
} }
} }
if (!remove_now) if (!remove_now)
BREAK_FROM_IMM_USE_STMT (uit); BREAK_FROM_IMM_USE_STMT (uit);
} }
if (remove_now) if (remove_now)
{ {
gimple *def = SSA_NAME_DEF_STMT (var); gimple *def = SSA_NAME_DEF_STMT (var);
gimple_stmt_iterator gsi = gsi_for_stmt (def); gimple_stmt_iterator gsi = gsi_for_stmt (def);
if (gimple_code (def) == GIMPLE_PHI) if (gimple_code (def) == GIMPLE_PHI)
remove_phi_node (&gsi, true); remove_phi_node (&gsi, true);
else else
{ {
gsi_remove (&gsi, true); gsi_remove (&gsi, true);
release_defs (def); release_defs (def);
} }
to_remove_bit = j;
}
}
if (to_remove_bit != -1U)
bitmap_clear_bit (toremove, to_remove_bit);
}
bitmap_clear_bit (toremove, j);
}
}
} }
/* Verify virtual SSA form. */ /* Verify virtual SSA form. */
......
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