aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-02-07 15:46:17 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-02-07 15:46:17 +0000
commitb210f45f527eb017810af815bbb97a8f6939385f (patch)
tree26538f6f069f23a2c3756540d4f8743f7e052695 /gcc/tree-vect-loop.c
parent43e4df5a0bed4833a4812746e5554ed057b6dfd4 (diff)
downloadgcc-b210f45f527eb017810af815bbb97a8f6939385f.zip
gcc-b210f45f527eb017810af815bbb97a8f6939385f.tar.gz
gcc-b210f45f527eb017810af815bbb97a8f6939385f.tar.bz2
re PR tree-optimization/84037 (Speed regression of polyhedron benchmark since r256644)
2018-02-07 Richard Biener <rguenther@suse.de> PR tree-optimization/84037 * tree-vectorizer.h (struct _loop_vec_info): Add ivexpr_map member. (cse_and_gimplify_to_preheader): Declare. (vect_get_place_in_interleaving_chain): Likewise. * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Initialize ivexpr_map. (_loop_vec_info::~_loop_vec_info): Delete it. (cse_and_gimplify_to_preheader): New function. * tree-vect-slp.c (vect_get_place_in_interleaving_chain): Export. * tree-vect-stmts.c (vectorizable_store): CSE base and steps. (vectorizable_load): Likewise. For grouped stores always base the IV on the first element. * tree-vect-loop-manip.c (vect_loop_versioning): Unshare versioning condition before gimplifying. From-SVN: r257453
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index c530168..3a51147 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -1128,6 +1128,7 @@ _loop_vec_info::_loop_vec_info (struct loop *loop_in)
unaligned_dr (NULL),
peeling_for_alignment (0),
ptr_mask (0),
+ ivexpr_map (NULL),
slp_unrolling_factor (1),
single_scalar_iteration_cost (0),
vectorizable (false),
@@ -1251,10 +1252,38 @@ _loop_vec_info::~_loop_vec_info ()
free (bbs);
release_vec_loop_masks (&masks);
+ delete ivexpr_map;
loop->aux = NULL;
}
+/* Return an invariant or register for EXPR and emit necessary
+ computations in the LOOP_VINFO loop preheader. */
+
+tree
+cse_and_gimplify_to_preheader (loop_vec_info loop_vinfo, tree expr)
+{
+ if (is_gimple_reg (expr)
+ || is_gimple_min_invariant (expr))
+ return expr;
+
+ if (! loop_vinfo->ivexpr_map)
+ loop_vinfo->ivexpr_map = new hash_map<tree_operand_hash, tree>;
+ tree &cached = loop_vinfo->ivexpr_map->get_or_insert (expr);
+ if (! cached)
+ {
+ gimple_seq stmts = NULL;
+ cached = force_gimple_operand (unshare_expr (expr),
+ &stmts, true, NULL_TREE);
+ if (stmts)
+ {
+ edge e = loop_preheader_edge (LOOP_VINFO_LOOP (loop_vinfo));
+ gsi_insert_seq_on_edge_immediate (e, stmts);
+ }
+ }
+ return cached;
+}
+
/* Return true if we can use CMP_TYPE as the comparison type to produce
all masks required to mask LOOP_VINFO. */