From f9ffade09c3cc13eb1a199a24517b9b1909c6e80 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 21 Jul 2015 19:15:13 +0000 Subject: [PATCH] ssa-iterators.h (has_zero_uses, [...]): Implement as straight loops. 2015-07-21 Andrew MacLeod * 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 --- gcc/ChangeLog | 9 ++++++ gcc/ssa-iterators.h | 62 +++++++++++++++++------------------------ gcc/tree-ssa-operands.c | 19 ++----------- 3 files changed, 37 insertions(+), 53 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e6915a1070..240cbefe500 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-07-21 Andrew MacLeod + + * 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 Bernhard Reutner-Fischer diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h index 4f0057f1408..a9bf6990fa3 100644 --- a/gcc/ssa-iterators.h +++ b/gcc/ssa-iterators.h @@ -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)); - - /* A single use_operand means there is no items in the list. */ - if (ptr == ptr->next) - return true; + const ssa_use_operand_t *const head = &(SSA_NAME_IMM_USE_NODE (var)); + const ssa_use_operand_t *ptr; - /* 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; + for (ptr = head->next; ptr != head; ptr = ptr->next) + if (USE_STMT (ptr) && !is_gimple_debug (USE_STMT (ptr))) + 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)); - - /* 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); -} - - + 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; + } + + 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; diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index a132679a9c2..b1e3f99337a 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -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; } + -- 2.30.2