From: Richard Biener Date: Tue, 10 Nov 2015 09:43:54 +0000 (+0000) Subject: re PR tree-optimization/56118 (Piecewise vector / complex initialization from constan... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a6524bba206a001a83e60548007f92c701cd0a86;p=gcc.git re PR tree-optimization/56118 (Piecewise vector / complex initialization from constants not combined) 2015-11-10 Richard Biener PR tree-optimization/56118 * tree-vect-slp.c (vect_bb_vectorization_profitable_p): Make equal cost favor vectorized version. * gcc.target/i386/pr56118.c: New testcase. From-SVN: r230091 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5a7e44cf292..68163747ca1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-10 Richard Biener + + PR tree-optimization/56118 + * tree-vect-slp.c (vect_bb_vectorization_profitable_p): Make equal + cost favor vectorized version. + 2015-11-10 Kyrylo Tkachov * config/aarch64/aarch64.md (cc): New define_expand. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c258f4404e..bbaf9a347c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-10 Richard Biener + + PR tree-optimization/56118 + * gcc.target/i386/pr56118.c: New testcase. + 2015-11-10 Kyrylo Tkachov * gcc.target/aarch64/cond_op_imm_1.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr56118.c b/gcc/testsuite/gcc.target/i386/pr56118.c new file mode 100644 index 00000000000..11a543cafe8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr56118.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse2" } */ + +#include + +__m128d f() +{ + __m128d r={3,4}; + r[0]=1; + r[1]=2; + return r; +} + +/* We want to "vectorize" this to a aligned vector load from the + constant pool. */ + +/* { dg-final { scan-assembler "movapd" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 954b85ef8bc..6dda2ec9eae 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2317,9 +2317,12 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo) dump_printf (MSG_NOTE, " Scalar cost of basic block: %d\n", scalar_cost); } - /* Vectorization is profitable if its cost is less than the cost of scalar - version. */ - if (vec_outside_cost + vec_inside_cost >= scalar_cost) + /* Vectorization is profitable if its cost is more than the cost of scalar + version. Note that we err on the vector side for equal cost because + the cost estimate is otherwise quite pessimistic (constant uses are + free on the scalar side but cost a load on the vector side for + example). */ + if (vec_outside_cost + vec_inside_cost > scalar_cost) return false; return true;