diff options
author | Richard Biener <rguenther@suse.de> | 2020-05-20 09:22:58 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-05-20 14:09:26 +0200 |
commit | b2f26af32b5b031fce761aa090de9476a53e6e5a (patch) | |
tree | d856e2b9fad2e5c97d99a1070047700b5b8f2d99 /gcc/tree-vect-loop.c | |
parent | 130bb4c79295487c5fc203103d80e3b754640eb4 (diff) | |
download | gcc-b2f26af32b5b031fce761aa090de9476a53e6e5a.zip gcc-b2f26af32b5b031fce761aa090de9476a53e6e5a.tar.gz gcc-b2f26af32b5b031fce761aa090de9476a53e6e5a.tar.bz2 |
tree-optimization/95219 - improve IV selection for induction
This improves code generation with SSE2 for the testcase by
making sure to only generate a single IV when the group size
is a multiple of the vector size. It also adjusts the testcase
which was passing before.
2020-05-20 Richard Biener <rguenther@suse.de>
PR tree-optimization/95219
* tree-vect-loop.c (vectorizable_induction): Reduce
group_size before computing the number of required IVs.
* gcc.dg/vect/costmodel/x86_64/costmodel-pr30843.c: Adjust.
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index f065acc..ecce348 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -7528,7 +7528,13 @@ vectorizable_induction (loop_vec_info loop_vinfo, unsigned group_size = SLP_TREE_SCALAR_STMTS (slp_node).length (); unsigned nvects = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); unsigned elts = const_nunits * nvects; - unsigned nivs = least_common_multiple (group_size, + /* Compute the number of distinct IVs we need. First reduce + group_size if it is a multiple of const_nunits so we get + one IV for a group_size of 4 but const_nunits 2. */ + unsigned group_sizep = group_size; + if (group_sizep % const_nunits == 0) + group_sizep = group_sizep / const_nunits; + unsigned nivs = least_common_multiple (group_sizep, const_nunits) / const_nunits; gcc_assert (elts % group_size == 0); tree elt = init_expr; @@ -7576,6 +7582,12 @@ vectorizable_induction (loop_vec_info loop_vinfo, SLP_TREE_VEC_STMTS (slp_node).quick_push (induction_phi_info); } + /* Fill up to the number of vectors we need for the whole group. */ + nivs = least_common_multiple (group_size, + const_nunits) / const_nunits; + for (; ivn < nivs; ++ivn) + SLP_TREE_VEC_STMTS (slp_node) + .quick_push (SLP_TREE_VEC_STMTS (slp_node)[0]); /* Re-use IVs when we can. */ if (ivn < nvects) |