ssa-iterators.h (has_zero_uses, [...]): Implement as straight loops.

2015-07-21  Andrew MacLeod  <amacleod@redhat.com>

	* ssa-iterators.h (has_zero_uses, has_single_use): Implement as
	straight loops.
	(single_imm_use): Check for iterator node.
	(num_imm_uses): Likewise.
	* tree-ssa-operands.c (has_zero_uses_1): Delete.
	(single_imm_use_1): Check for iterator node.

From-SVN: r226051
This commit is contained in:
Andrew MacLeod 2015-07-21 19:15:13 +00:00 committed by Andrew Macleod
parent 324000329b
commit f9ffade09c
3 changed files with 35 additions and 51 deletions

View File

@ -1,3 +1,12 @@
2015-07-21 Andrew MacLeod <amacleod@redhat.com>
* ssa-iterators.h (has_zero_uses, has_single_use): Implement as
straight loops.
(single_imm_use): Check for iterator node.
(num_imm_uses): Likewise.
* tree-ssa-operands.c (has_zero_uses_1): Delete.
(single_imm_use_1): Check for iterator node.
2015-07-21 Mike Frysinger <vapier@gentoo.org>
Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

View File

@ -114,7 +114,6 @@ struct imm_use_iterator
extern bool has_zero_uses_1 (const ssa_use_operand_t *head);
extern bool single_imm_use_1 (const ssa_use_operand_t *head,
use_operand_p *use_p, gimple *stmt);
@ -379,42 +378,36 @@ next_readonly_imm_use (imm_use_iterator *imm)
static inline bool
has_zero_uses (const_tree var)
{
const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
const ssa_use_operand_t *const head = &(SSA_NAME_IMM_USE_NODE (var));
const ssa_use_operand_t *ptr;
/* A single use_operand means there is no items in the list. */
if (ptr == ptr->next)
return true;
for (ptr = head->next; ptr != head; ptr = ptr->next)
if (USE_STMT (ptr) && !is_gimple_debug (USE_STMT (ptr)))
return false;
/* If there are debug stmts, we have to look at each use and see
whether there are any nondebug uses. */
if (!MAY_HAVE_DEBUG_STMTS)
return false;
return has_zero_uses_1 (ptr);
return true;
}
/* Return true if VAR has a single nondebug use. */
static inline bool
has_single_use (const_tree var)
{
const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
const ssa_use_operand_t *const head = &(SSA_NAME_IMM_USE_NODE (var));
const ssa_use_operand_t *ptr;
bool single = false;
for (ptr = head->next; ptr != head; ptr = ptr->next)
if (USE_STMT(ptr) && !is_gimple_debug (USE_STMT (ptr)))
{
if (single)
return false;
else
single = true;
}
/* If there aren't any uses whatsoever, we're done. */
if (ptr == ptr->next)
return false;
/* If there's a single use, check that it's not a debug stmt. */
if (ptr == ptr->next->next)
return !is_gimple_debug (USE_STMT (ptr->next));
/* If there are debug stmts, we have to look at each of them. */
if (!MAY_HAVE_DEBUG_STMTS)
return false;
return single_imm_use_1 (ptr, NULL, NULL);
return single;
}
/* If VAR has only a single immediate nondebug use, return true, and
set USE_P and STMT to the use pointer and stmt of occurrence. */
static inline bool
@ -434,7 +427,7 @@ single_imm_use (const_tree var, use_operand_p *use_p, gimple *stmt)
/* If there's a single use, check that it's not a debug stmt. */
if (ptr == ptr->next->next)
{
if (!is_gimple_debug (USE_STMT (ptr->next)))
if (USE_STMT (ptr->next) && !is_gimple_debug (USE_STMT (ptr->next)))
{
*use_p = ptr->next;
*stmt = ptr->next->loc.stmt;
@ -444,10 +437,6 @@ single_imm_use (const_tree var, use_operand_p *use_p, gimple *stmt)
goto return_false;
}
/* If there are debug stmts, we have to look at each of them. */
if (!MAY_HAVE_DEBUG_STMTS)
goto return_false;
return single_imm_use_1 (ptr, use_p, stmt);
}
@ -461,10 +450,11 @@ num_imm_uses (const_tree var)
if (!MAY_HAVE_DEBUG_STMTS)
for (ptr = start->next; ptr != start; ptr = ptr->next)
num++;
if (USE_STMT (ptr))
num++;
else
for (ptr = start->next; ptr != start; ptr = ptr->next)
if (!is_gimple_debug (USE_STMT (ptr)))
if (USE_STMT (ptr) && !is_gimple_debug (USE_STMT (ptr)))
num++;
return num;

View File

@ -1304,22 +1304,6 @@ unlink_stmt_vdef (gimple stmt)
SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vuse) = 1;
}
/* Return true if the var whose chain of uses starts at PTR has no
nondebug uses. */
bool
has_zero_uses_1 (const ssa_use_operand_t *head)
{
const ssa_use_operand_t *ptr;
for (ptr = head->next; ptr != head; ptr = ptr->next)
if (!is_gimple_debug (USE_STMT (ptr)))
return false;
return true;
}
/* Return true if the var whose chain of uses starts at PTR has a
single nondebug use. Set USE_P and STMT to that single nondebug
use, if so, or to NULL otherwise. */
@ -1330,7 +1314,7 @@ single_imm_use_1 (const ssa_use_operand_t *head,
ssa_use_operand_t *ptr, *single_use = 0;
for (ptr = head->next; ptr != head; ptr = ptr->next)
if (!is_gimple_debug (USE_STMT (ptr)))
if (USE_STMT(ptr) && !is_gimple_debug (USE_STMT (ptr)))
{
if (single_use)
{
@ -1348,3 +1332,4 @@ single_imm_use_1 (const ssa_use_operand_t *head,
return single_use;
}