diff options
author | Ira Rosen <irar@il.ibm.com> | 2009-07-13 12:27:32 +0000 |
---|---|---|
committer | Ira Rosen <irar@gcc.gnu.org> | 2009-07-13 12:27:32 +0000 |
commit | 2f3e235bb3e7b573f4a3fa78e1a755004f64b1f6 (patch) | |
tree | 08d1a13ac124f35c431605818a96cb88ab0120ff /gcc/tree-vect-loop.c | |
parent | 7b00e31d1e201bdc2fb6518b8866bb0851261c7b (diff) | |
download | gcc-2f3e235bb3e7b573f4a3fa78e1a755004f64b1f6.tar.gz |
tree-vect-loop.c (get_initial_def_for_reduction): Ensure that the checks access only relevant statements.
* tree-vect-loop.c (get_initial_def_for_reduction): Ensure that the
checks access only relevant statements.
(vectorizable_reduction): Likewise.
From-SVN: r149576
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index c96fb04a814..1db80e43efd 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2632,6 +2632,7 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, tree init_value; REAL_VALUE_TYPE real_init_val = dconst0; int int_init_val = 0; + gimple def_stmt = NULL; gcc_assert (vectype); nunits = TYPE_VECTOR_SUBPARTS (vectype); @@ -2647,9 +2648,13 @@ get_initial_def_for_reduction (gimple stmt, tree init_val, /* In case of double reduction we only create a vector variable to be put in the reduction phi node. The actual statement creation is done in vect_create_epilog_for_reduction. */ - if (TREE_CODE (init_val) == SSA_NAME - && vinfo_for_stmt (SSA_NAME_DEF_STMT (init_val)) - && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (SSA_NAME_DEF_STMT (init_val))) + if (adjustment_def && nested_in_vect_loop + && TREE_CODE (init_val) == SSA_NAME + && (def_stmt = SSA_NAME_DEF_STMT (init_val)) + && gimple_code (def_stmt) == GIMPLE_PHI + && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)) + && vinfo_for_stmt (def_stmt) + && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def_stmt)) == vect_double_reduction_def) { *adjustment_def = NULL; @@ -3418,11 +3423,13 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, int reduc_index = 2; bool double_reduc = false, dummy; basic_block def_bb; - struct loop * def_stmt_loop; + struct loop * def_stmt_loop, *outer_loop = NULL; tree def_arg; + gimple def_arg_stmt; if (nested_in_vect_loop_p (loop, stmt)) { + outer_loop = loop; loop = loop->inner; nested_cycle = true; } @@ -3669,15 +3676,21 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, epilog_reduc_code = ERROR_MARK; } - def_bb = gimple_bb (reduc_def_stmt); - def_stmt_loop = def_bb->loop_father; - def_arg = PHI_ARG_DEF_FROM_EDGE (reduc_def_stmt, - loop_preheader_edge (def_stmt_loop)); - if (TREE_CODE (def_arg) == SSA_NAME - && vinfo_for_stmt (SSA_NAME_DEF_STMT (def_arg)) - && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (SSA_NAME_DEF_STMT (def_arg))) - == vect_double_reduction_def) - double_reduc = true; + if (nested_cycle) + { + def_bb = gimple_bb (reduc_def_stmt); + def_stmt_loop = def_bb->loop_father; + def_arg = PHI_ARG_DEF_FROM_EDGE (reduc_def_stmt, + loop_preheader_edge (def_stmt_loop)); + if (TREE_CODE (def_arg) == SSA_NAME + && (def_arg_stmt = SSA_NAME_DEF_STMT (def_arg)) + && gimple_code (def_arg_stmt) == GIMPLE_PHI + && flow_bb_inside_loop_p (outer_loop, gimple_bb (def_arg_stmt)) + && vinfo_for_stmt (def_arg_stmt) + && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def_arg_stmt)) + == vect_double_reduction_def) + double_reduc = true; + } if (double_reduc && ncopies > 1) { |