diff options
author | alalaw01 <alalaw01@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-18 12:46:54 +0000 |
---|---|---|
committer | alalaw01 <alalaw01@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-18 12:46:54 +0000 |
commit | c45a20be2fcacc8ce1b71129d8fd0be845931b4c (patch) | |
tree | 1c0d8f2af9b412a04be41c417f3b798442f229cd | |
parent | fa75ab556a6b26b343e958922c2b3e4804783046 (diff) | |
download | gcc-c45a20be2fcacc8ce1b71129d8fd0be845931b4c.tar.gz |
Enhance SCEV to follow copies of SSA_NAMEs.
(Fixes missed vectorization of gcc.dg/vect/pr65947-2.c.)
* tree-scalar-evolution.c (follow_copies_to_constant): New.
(analyze_initial_condition, analyze_scalar_evolution_1): Call previous.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232509 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/tree-scalar-evolution.c | 50 |
2 files changed, 38 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 26d7af09aed..8e2b6e6849f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-01-18 Alan Lawrence <alan.lawrence@arm.com> + * tree-scalar-evolution.c (follow_copies_to_constant): New. + (analyze_initial_condition, analyze_scalar_evolution_1): Call previous. + +2016-01-18 Alan Lawrence <alan.lawrence@arm.com> + PR target/63679 * tree-ssa-scopedtables.c (avail_expr_hash): Hash MEM_REF and ARRAY_REF using get_ref_base_and_extent. diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 2bfc50fd016..c36a0398db6 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1522,6 +1522,34 @@ analyze_evolution_in_loop (gphi *loop_phi_node, return evolution_function; } +/* Looks to see if VAR is a copy of a constant (via straightforward assignments + or degenerate phi's). If so, returns the constant; else, returns VAR. */ + +static tree +follow_copies_to_constant (tree var) +{ + tree res = var; + while (TREE_CODE (res) == SSA_NAME) + { + gimple *def = SSA_NAME_DEF_STMT (res); + if (gphi *phi = dyn_cast <gphi *> (def)) + { + if (tree rhs = degenerate_phi_result (phi)) + res = rhs; + else + break; + } + else if (gimple_assign_single_p (def)) + /* Will exit loop if not an SSA_NAME. */ + res = gimple_assign_rhs1 (def); + else + break; + } + if (CONSTANT_CLASS_P (res)) + return res; + return var; +} + /* Given a loop-phi-node, return the initial conditions of the variable on entry of the loop. When the CCP has propagated constants into the loop-phi-node, the initial condition is @@ -1574,21 +1602,9 @@ analyze_initial_condition (gphi *loop_phi_node) if (init_cond == chrec_not_analyzed_yet) init_cond = chrec_dont_know; - /* During early loop unrolling we do not have fully constant propagated IL. - Handle degenerate PHIs here to not miss important unrollings. */ - if (TREE_CODE (init_cond) == SSA_NAME) - { - gimple *def = SSA_NAME_DEF_STMT (init_cond); - if (gphi *phi = dyn_cast <gphi *> (def)) - { - tree res = degenerate_phi_result (phi); - if (res != NULL_TREE - /* Only allow invariants here, otherwise we may break - loop-closed SSA form. */ - && is_gimple_min_invariant (res)) - init_cond = res; - } - } + /* We may not have fully constant propagated IL. Handle degenerate PHIs here + to not miss important early loop unrollings. */ + init_cond = follow_copies_to_constant (init_cond); if (dump_file && (dump_flags & TDF_SCEV)) { @@ -1968,8 +1984,8 @@ analyze_scalar_evolution_1 (struct loop *loop, tree var, tree res) if (bb == NULL || !flow_bb_inside_loop_p (loop, bb)) { - /* Keep the symbolic form. */ - res = var; + /* Keep symbolic form, but look through obvious copies for constants. */ + res = follow_copies_to_constant (var); goto set_and_end; } |