re PR tree-optimization/56118 (Piecewise vector / complex initialization from constan...
authorRichard Biener <rguenther@suse.de>
Tue, 10 Nov 2015 09:43:54 +0000 (09:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 10 Nov 2015 09:43:54 +0000 (09:43 +0000)
2015-11-10  Richard Biener  <rguenther@suse.de>

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr56118.c [new file with mode: 0644]
gcc/tree-vect-slp.c

index 5a7e44cf29204825ce47975e4e25c2dc71e505b5..68163747ca153ab74850a260206ead2d17523112 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56118
+       * tree-vect-slp.c (vect_bb_vectorization_profitable_p): Make equal
+       cost favor vectorized version.
+
 2015-11-10  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/aarch64/aarch64.md (<neg_not_op><mode>cc): New define_expand.
index 5c258f4404ef277bc5609f6b0bb7a1fc58cab876..bbaf9a347c8e9566bad3b0cc8b836a4b30b90dd8 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56118
+       * gcc.target/i386/pr56118.c: New testcase.
+
 2015-11-10  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * 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 (file)
index 0000000..11a543c
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -msse2" } */
+
+#include <emmintrin.h>
+
+__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" } } */
index 954b85ef8bce45e4ad817ba7daee6f58b738eebb..6dda2ec9eae1f52486fa9e13c7243a9e4c7cb601 100644 (file)
@@ -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;