re PR tree-optimization/64909 (Missed vectorization with bdver1)
authorRichard Biener <rguenther@suse.de>
Tue, 10 Feb 2015 11:48:47 +0000 (11:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 10 Feb 2015 11:48:47 +0000 (11:48 +0000)
2015-02-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/64909
* tree-vect-loop.c (vect_estimate_min_profitable_iters): Properly
pass a scalar-stmt count estimate to the cost model.
* tree-vect-data-refs.c (vect_peeling_hash_get_lowest_cost): Likewise.

* gcc.dg/vect/costmodel/x86_64/costmodel-pr64909.c: New testcase.

From-SVN: r220580

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr64909.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop.c

index 888ceb4c975b5d9815b665980ffa578c47b7fd93..7f3816c3e705d89d6e88a09eef15bac494da643e 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64909
+       * tree-vect-loop.c (vect_estimate_min_profitable_iters): Properly
+       pass a scalar-stmt count estimate to the cost model.
+       * tree-vect-data-refs.c (vect_peeling_hash_get_lowest_cost): Likewise.
+
 2015-02-10  Alexander Monakov  <amonakov@ispras.ru>
 
        * doc/invoke.texi (-fvar-tracking-assignments): Clarify that VTA is
index 9bb681c6193b30832d86e5d0ef1f67fb43b6ec90..15d5e2d67cd8daec49044e40afa401905a397c07 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64909
+       * gcc.dg/vect/costmodel/x86_64/costmodel-pr64909.c: New testcase.
+
 2015-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gcc.dg/signbit-sa.c: New test.
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr64909.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr64909.c
new file mode 100644 (file)
index 0000000..0f9feac
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-mtune=bdver1" } */
+
+unsigned short a[32];
+unsigned int b[32];
+void t()
+{
+  int i;
+  for (i=0;i<12;i++)
+    b[i]=a[i];
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 302f2df2af21fb9508476276900671dc82cdc572..2c74060d793a08ad41e687d6f94c4d35ba130274 100644 (file)
@@ -1184,10 +1184,13 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
     }
 
   single_iter_cost = vect_get_single_scalar_iteration_cost (loop_vinfo);
-  outside_cost += vect_get_known_peeling_cost (loop_vinfo, elem->npeel,
-                                              &dummy, single_iter_cost,
-                                              &prologue_cost_vec,
-                                              &epilogue_cost_vec);
+  outside_cost += vect_get_known_peeling_cost
+    (loop_vinfo, elem->npeel, &dummy,
+     /* ???  We use this cost as number of stmts with scalar_stmt cost,
+       thus divide by that.  This introduces rounding errors, thus better 
+       introduce a new cost kind (raw_cost?  scalar_iter_cost?). */
+     single_iter_cost / vect_get_stmt_cost (scalar_stmt),
+     &prologue_cost_vec, &epilogue_cost_vec);
 
   /* Prologue and epilogue costs are added to the target model later.
      These costs depend only on the scalar iteration cost, the
index c5f1c29cbe29ddfd7bd677a1f3a438afed95cd43..3e7c701e636b685d21ac2561348c98707350338f 100644 (file)
@@ -2834,6 +2834,11 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
      statements.  */
 
   scalar_single_iter_cost = vect_get_single_scalar_iteration_cost (loop_vinfo);
+  /* ???  Below we use this cost as number of stmts with scalar_stmt cost,
+     thus divide by that.  This introduces rounding errors, thus better
+     introduce a new cost kind (raw_cost?  scalar_iter_cost?). */
+  int scalar_single_iter_stmts
+    = scalar_single_iter_cost / vect_get_stmt_cost (scalar_stmt);
 
   /* Add additional cost for the peeled instructions in prologue and epilogue
      loop.
@@ -2868,10 +2873,10 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
       /* FORNOW: Don't attempt to pass individual scalar instructions to
         the model; just assume linear cost for scalar iterations.  */
       (void) add_stmt_cost (target_cost_data,
-                           peel_iters_prologue * scalar_single_iter_cost,
+                           peel_iters_prologue * scalar_single_iter_stmts,
                            scalar_stmt, NULL, 0, vect_prologue);
       (void) add_stmt_cost (target_cost_data, 
-                           peel_iters_epilogue * scalar_single_iter_cost,
+                           peel_iters_epilogue * scalar_single_iter_stmts,
                            scalar_stmt, NULL, 0, vect_epilogue);
     }
   else
@@ -2887,7 +2892,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
 
       (void) vect_get_known_peeling_cost (loop_vinfo, peel_iters_prologue,
                                          &peel_iters_epilogue,
-                                         scalar_single_iter_cost,
+                                         scalar_single_iter_stmts,
                                          &prologue_cost_vec,
                                          &epilogue_cost_vec);