]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-vect-transform.c (vect_model_simple_cost): Return immediately if stmt is pure...
authorVictor Kaplansky <victork@il.ibm.com>
Wed, 6 Aug 2008 16:26:46 +0000 (16:26 +0000)
committerVictor Kaplansky <victork@gcc.gnu.org>
Wed, 6 Aug 2008 16:26:46 +0000 (16:26 +0000)
2008-08-06  Victor Kaplansky  <victork@il.ibm.com>
            Ira Rosen  <irar@il.ibm.com>

        * tree-vect-transform.c (vect_model_simple_cost): Return
        immediately if stmt is pure SLP.
        (vect_model_store_cost): Ditto.
        (vect_model_load_cost): Ditto.
        (vectorizable_store): Remove PURE_SLP check before call
        to vect_model_store_cost.
        (vect_model_store_cost): When checking whether stmt describe
        strided access, add a check that it is not slp_node.

Testsute

* gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c: New test.

Co-Authored-By: Ira Rosen <irar@il.ibm.com>
From-SVN: r138815

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c [new file with mode: 0644]
gcc/tree-vect-transform.c

index 47226532a561036293dabcd9040a68d1c2d7791d..e9a060604c08d80aec7b93ad359325312036c85d 100644 (file)
@@ -1,3 +1,15 @@
+2008-08-06  Victor Kaplansky  <victork@il.ibm.com>
+           Ira Rosen  <irar@il.ibm.com>
+
+       * tree-vect-transform.c (vect_model_simple_cost): Return
+       immediately if stmt is pure SLP.
+       (vect_model_store_cost): Ditto.
+       (vect_model_load_cost): Ditto.
+       (vectorizable_store): Remove PURE_SLP check before call
+       to vect_model_store_cost.
+       (vect_model_store_cost): When checking whether stmt describe
+       strided access, add a check that it is not slp_node.
+
 2008-08-06  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        PR 8715
index ad00fee706c26df696f72a319a30c0d1981ce253..ea0a55b2af9f7ca6fbe9fcab69f6367bf1ea68c4 100644 (file)
@@ -1,3 +1,7 @@
+2008-08-06  Victor Kaplansky  <victork@il.ibm.com>
+
+       * gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c: New test.
+
 2008-08-06  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        PR 8715
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c
new file mode 100644 (file)
index 0000000..376c7e4
--- /dev/null
@@ -0,0 +1,74 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "../../tree-vect.h"
+
+struct mystr {
+  int f1;
+  int f2;
+};
+
+struct mystr af[16] = {
+  10, 11, 12, 13, 14, 15, 16, 17,
+  20, 21, 22, 23, 24, 25, 26, 27,
+  30, 31, 32, 33, 34, 35, 36, 37,
+  40, 41, 42, 43, 44, 45, 46, 47
+};
+
+struct mystr bf[16] = {
+  12, 13, 14, 15, 16, 17, 18, 19,
+  22, 23, 24, 25, 26, 27, 28, 29,
+  32, 33, 34, 35, 36, 37, 38, 39,
+  42, 43, 44, 45, 46, 47, 48, 49
+};
+
+struct mystr cf[16];
+
+int res1[16] = {
+  22, 26, 30, 34, 42, 46, 50, 54,
+  62, 66, 70, 74, 82, 86, 90, 94,
+};
+
+int res2[16] = {
+  24, 28, 32, 36, 44, 48, 52, 56,
+  64, 68, 72, 76, 84, 88, 92, 96,
+};
+
+__attribute__ ((noinline)) void
+foo (void)
+{
+  int i;
+
+  for (i = 0; i < 16; i++)
+  {
+    cf[i].f1 = af[i].f1 + bf[i].f1;
+    cf[i].f2 = af[i].f2 + bf[i].f2;
+  }
+}
+
+
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+  foo ();
+
+  /* Check resiults. */ 
+  for (i = 0; i < 16; i++)
+    {
+      if (cf[i].f1 != res1[i])
+       abort ();
+      if (cf[i].f2 != res2[i])
+        abort ();
+
+    }
+  return 0;
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorization not profitable" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect"  } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index e466594f0cf34d2fac0f8b85d7e316139c9daa77..9d3d40a70fab244c8ebebf3d55884f2077eb4efe 100644 (file)
@@ -580,6 +580,10 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies,
   int i;
   int inside_cost = 0, outside_cost = 0;
 
+  /* The SLP costs were already calculated during SLP tree build.  */
+  if (PURE_SLP_STMT (stmt_info))
+    return;
+
   inside_cost = ncopies * TARG_VEC_STMT_COST;
 
   /* FORNOW: Assuming maximum 2 args per stmts.  */
@@ -629,11 +633,15 @@ vect_model_store_cost (stmt_vec_info stmt_info, int ncopies,
   int group_size;
   int inside_cost = 0, outside_cost = 0;
 
+  /* The SLP costs were already calculated during SLP tree build.  */
+  if (PURE_SLP_STMT (stmt_info))
+    return;
+
   if (dt == vect_constant_def || dt == vect_invariant_def)
     outside_cost = TARG_SCALAR_TO_VEC_COST;
 
   /* Strided access?  */
-  if (DR_GROUP_FIRST_DR (stmt_info)) 
+  if (DR_GROUP_FIRST_DR (stmt_info) && !slp_node
     group_size = vect_cost_strided_group_size (stmt_info);
   /* Not a strided access.  */
   else
@@ -683,6 +691,10 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, slp_tree slp_node)
   struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info), *first_dr;
   int inside_cost = 0, outside_cost = 0;
 
+  /* The SLP costs were already calculated during SLP tree build.  */
+  if (PURE_SLP_STMT (stmt_info))
+    return;
+
   /* Strided accesses?  */
   first_stmt = DR_GROUP_FIRST_DR (stmt_info);
   if (first_stmt && !slp_node)
@@ -4865,8 +4877,7 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = store_vec_info_type;
-      if (!PURE_SLP_STMT (stmt_info))
-       vect_model_store_cost (stmt_info, ncopies, dt, NULL);
+      vect_model_store_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }