diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-10 13:46:27 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-10 13:46:27 +0000 |
commit | b5698e04177beac04606786418092a79dce5f359 (patch) | |
tree | c2b4709a3f92857670cb47250ae665dc6acc197b /gcc/tree-loop-distribution.c | |
parent | 17b9476e1ecf66ab2cab1e4174c1a610a8e4a6c2 (diff) | |
download | gcc-b5698e04177beac04606786418092a79dce5f359.tar.gz |
2011-11-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/51070
* tree-loop-distribution.c (generate_builtin): Do not replace
the loop with a builtin if the partition contains statements which
results are used outside of the loop.
(pass_loop_distribution): Verify and collect.
* gcc.dg/torture/pr51070.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181255 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-loop-distribution.c')
-rw-r--r-- | gcc/tree-loop-distribution.c | 103 |
1 files changed, 56 insertions, 47 deletions
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 810b974b256..0daef06b954 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -63,6 +63,48 @@ static bitmap remaining_stmts; predecessor a node that writes to memory. */ static bitmap upstream_mem_writes; +/* Returns true when DEF is an SSA_NAME defined in LOOP and used after + the LOOP. */ + +static bool +ssa_name_has_uses_outside_loop_p (tree def, loop_p loop) +{ + imm_use_iterator imm_iter; + use_operand_p use_p; + + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, def) + if (loop != loop_containing_stmt (USE_STMT (use_p))) + return true; + + return false; +} + +/* Returns true when STMT defines a scalar variable used after the + loop. */ + +static bool +stmt_has_scalar_dependences_outside_loop (gimple stmt) +{ + tree name; + + switch (gimple_code (stmt)) + { + case GIMPLE_ASSIGN: + name = gimple_assign_lhs (stmt); + break; + + case GIMPLE_PHI: + name = gimple_phi_result (stmt); + break; + + default: + return false; + } + + return TREE_CODE (name) == SSA_NAME + && ssa_name_has_uses_outside_loop_p (name, loop_containing_stmt (stmt)); +} + /* Update the PHI nodes of NEW_LOOP. NEW_LOOP is a duplicate of ORIG_LOOP. */ @@ -330,10 +372,18 @@ generate_builtin (struct loop *loop, bitmap partition, bool copy_p) { gimple stmt = gsi_stmt (bsi); - if (gimple_code (stmt) != GIMPLE_LABEL - && !is_gimple_debug (stmt) - && bitmap_bit_p (partition, x++) - && is_gimple_assign (stmt) + if (gimple_code (stmt) == GIMPLE_LABEL + || is_gimple_debug (stmt)) + continue; + + if (!bitmap_bit_p (partition, x++)) + continue; + + /* If the stmt has uses outside of the loop fail. */ + if (stmt_has_scalar_dependences_outside_loop (stmt)) + goto end; + + if (is_gimple_assign (stmt) && !is_gimple_reg (gimple_assign_lhs (stmt))) { /* Don't generate the builtins when there are more than @@ -824,48 +874,6 @@ fuse_partitions_with_similar_memory_accesses (struct graph *rdg, } } -/* Returns true when DEF is an SSA_NAME defined in LOOP and used after - the LOOP. */ - -static bool -ssa_name_has_uses_outside_loop_p (tree def, loop_p loop) -{ - imm_use_iterator imm_iter; - use_operand_p use_p; - - FOR_EACH_IMM_USE_FAST (use_p, imm_iter, def) - if (loop != loop_containing_stmt (USE_STMT (use_p))) - return true; - - return false; -} - -/* Returns true when STMT defines a scalar variable used after the - loop. */ - -static bool -stmt_has_scalar_dependences_outside_loop (gimple stmt) -{ - tree name; - - switch (gimple_code (stmt)) - { - case GIMPLE_ASSIGN: - name = gimple_assign_lhs (stmt); - break; - - case GIMPLE_PHI: - name = gimple_phi_result (stmt); - break; - - default: - return false; - } - - return TREE_CODE (name) == SSA_NAME - && ssa_name_has_uses_outside_loop_p (name, loop_containing_stmt (stmt)); -} - /* Returns true when STMT will be code generated in a partition of RDG different than PART and that will not be code generated as a builtin. */ @@ -1311,6 +1319,7 @@ struct gimple_opt_pass pass_loop_distribution = 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ + TODO_ggc_collect + | TODO_verify_ssa /* todo_flags_finish */ } }; |