aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rosen <irar@il.ibm.com>2009-01-08 07:59:40 +0000
committerIra Rosen <irar@gcc.gnu.org>2009-01-08 07:59:40 +0000
commit82567e3386ed9d11a425f12d822ed1ee6b1c949b (patch)
tree5cd604855fe17a73ebe3eb589b7ab54b64ac8d70
parent9982752346aac68d257d258332591df1f7b7817d (diff)
downloadgcc-82567e3386ed9d11a425f12d822ed1ee6b1c949b.zip
gcc-82567e3386ed9d11a425f12d822ed1ee6b1c949b.tar.gz
gcc-82567e3386ed9d11a425f12d822ed1ee6b1c949b.tar.bz2
re PR tree-optimization/37194 (Autovectorization of small constant iteration loop degrades performance)
PR tree-optimization/37194 * tree-vect-transform.c (vect_estimate_min_profitable_iters): Don't add the cost of cost model guard in prologue to scalar outside cost in case of known number of iterations. From-SVN: r143183
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-pr37194.c28
-rw-r--r--gcc/tree-vect-transform.c29
4 files changed, 52 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 29c4ba4a..3365290 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2009-01-08 Ira Rosen <irar@il.ibm.com>
+
+ PR tree-optimization/37194
+ * tree-vect-transform.c (vect_estimate_min_profitable_iters):
+ Don't add the cost of cost model guard in prologue to scalar
+ outside cost in case of known number of iterations.
+
2009-01-07 Nathan Froyd <froydnj@codesourcery.com>
Alan Modra <amodra@bigpond.net.au>
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b7d3e7..0c6c3a7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-08 Ira Rosen <irar@il.ibm.com>
+
+ PR tree-optimization/37194
+ * gcc.dg/vect/costmodel/ppc/costmodel-pr37194.c: New test.
+
2009-01-07 Jakub Jelinek <jakub@redhat.com>
PR c++/38725
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-pr37194.c b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-pr37194.c
new file mode 100644
index 0000000..76c7850
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-pr37194.c
@@ -0,0 +1,28 @@
+/* { dg-require-effective-target vect_float } */
+/* { dg-do compile } */
+
+#include <stdlib.h>
+#include "../../tree-vect.h"
+
+__attribute__ ((noinline)) void
+ggSpectrum_Set8(float * data, float d)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ data[i] = d;
+}
+
+__attribute__ ((noinline)) void
+ggSpectrum_Set20(float * data, float d)
+{
+ int i;
+
+ for (i = 0; i < 20; i++)
+ data[i] = d;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c
index 2db0167..5b3344a 100644
--- a/gcc/tree-vect-transform.c
+++ b/gcc/tree-vect-transform.c
@@ -122,7 +122,6 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo)
int vec_outside_cost = 0;
int scalar_single_iter_cost = 0;
int scalar_outside_cost = 0;
- bool runtime_test = false;
int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
@@ -141,15 +140,7 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo)
return 0;
}
- /* If the number of iterations is unknown, or the
- peeling-for-misalignment amount is unknown, we will have to generate
- a runtime test to test the loop count against the threshold. */
- if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
- || (byte_misalign < 0))
- runtime_test = true;
-
/* Requires loop versioning tests to handle misalignment. */
-
if (VEC_length (gimple, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo)))
{
/* FIXME: Make cost depend on complexity of individual check. */
@@ -240,12 +231,11 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo)
"peeling for alignment is unknown .");
/* If peeled iterations are unknown, count a taken branch and a not taken
- branch per peeled loop. Even if scalar loop iterations are known,
- vector iterations are not known since peeled prologue iterations are
- not known. Hence guards remain the same. */
+ branch per peeled loop. Even if scalar loop iterations are known,
+ vector iterations are not known since peeled prologue iterations are
+ not known. Hence guards remain the same. */
peel_guard_costs += 2 * (TARG_COND_TAKEN_BRANCH_COST
- + TARG_COND_NOT_TAKEN_BRANCH_COST);
-
+ + TARG_COND_NOT_TAKEN_BRANCH_COST);
}
else
{
@@ -337,7 +327,12 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo)
conditions/branch directions. Change the estimates below to
something more reasonable. */
- if (runtime_test)
+ /* If the number of iterations is known and we do not do versioning, we can
+ decide whether to vectorize at compile time. Hence the scalar version
+ do not carry cost model guard costs. */
+ if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ || VEC_length (gimple, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo))
+ || VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)))
{
/* Cost model check occurs at versioning. */
if (VEC_length (gimple, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo))
@@ -345,8 +340,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo)
scalar_outside_cost += TARG_COND_NOT_TAKEN_BRANCH_COST;
else
{
- /* Cost model occurs at prologue generation. */
- if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
+ /* Cost model check occurs at prologue generation. */
+ if (LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0)
scalar_outside_cost += 2 * TARG_COND_TAKEN_BRANCH_COST
+ TARG_COND_NOT_TAKEN_BRANCH_COST;
/* Cost model check occurs at epilogue generation. */