summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-04 15:06:44 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-04 15:06:44 +0000
commitf77a1eec66f4c47d01572e112d91ba3760793026 (patch)
tree0c901052e51eec2dc4b4dd82f3082695c9b8e2f6
parenta0ae08f729ab7107cc731c2a84bf5107a8fc898f (diff)
downloadgcc-f77a1eec66f4c47d01572e112d91ba3760793026.tar.gz
2013-04-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/56826 * tree-vect-slp.c (vect_build_slp_tree): Compute ncopies more accurately. * gcc.dg/vect/pr56826.c: New testcase. * gcc.dg/vect/O3-pr36098.c: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197486 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/vect/O3-pr36098.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr56826.c41
-rw-r--r--gcc/tree-vect-slp.c10
5 files changed, 60 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 09f5ff5478a..970c0d97fd1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2013-04-04 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/56826
+ * tree-vect-slp.c (vect_build_slp_tree): Compute ncopies
+ more accurately.
+
+2013-04-04 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/56213
* tree-vect-data-refs.c (vect_check_strided_load): Remove.
(vect_analyze_data_refs): Allow all non-nested loads as
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 06f6c981bf9..a65b101de03 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2013-04-04 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/56826
+ * gcc.dg/vect/pr56826.c: New testcase.
+ * gcc.dg/vect/O3-pr36098.c: Adjust.
+
2013-04-04 Tejas Belagod <tejas.belagod@arm.com>
* gcc.target/aarch64/inc/asm-adder-clobber-lr.c: Remove duplication.
diff --git a/gcc/testsuite/gcc.dg/vect/O3-pr36098.c b/gcc/testsuite/gcc.dg/vect/O3-pr36098.c
index 9e87b2372db..b0b8e3c9466 100644
--- a/gcc/testsuite/gcc.dg/vect/O3-pr36098.c
+++ b/gcc/testsuite/gcc.dg/vect/O3-pr36098.c
@@ -17,5 +17,5 @@ void foo (int ncons, t_sortblock *sb, int *iatom)
iatom[m]=sb[i].iatom[m];
}
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr56826.c b/gcc/testsuite/gcc.dg/vect/pr56826.c
new file mode 100644
index 00000000000..7a5c5ff4008
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr56826.c
@@ -0,0 +1,41 @@
+extern void abort (void);
+
+typedef struct {
+ int a[3];
+ int num;
+} t1;
+t1 B[100];
+int A[300];
+
+void __attribute__((noinline,noclone))
+bar (int *A, t1 *B, int n)
+{
+ int i;
+ int *a = A;
+ for (i=0; i<n; i++, a+=3)
+ {
+ a[0] = B[i].a[0];
+ a[1] = B[i].a[1];
+ a[2] = B[i].a[2];
+ }
+}
+
+int main()
+{
+ int i;
+ for (i=0; i<100; i++)
+ {
+ B[i].num = i;
+ B[i].a[0] = i * 3;
+ B[i].a[1] = i * 3 + 1;
+ B[i].a[2] = i * 3 + 2;
+ __asm__ volatile ("");
+ }
+ bar (&A[0], &B[0], 100);
+ for (i=0; i<300; i++)
+ if (A[i] != i)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index a9cf6920cf6..4a5317dc3ce 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -470,7 +470,6 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
tree lhs;
bool stop_recursion = false, need_same_oprnds = false;
tree vectype, scalar_type, first_op1 = NULL_TREE;
- unsigned int ncopies;
optab optab;
int icode;
enum machine_mode optab_op2_mode;
@@ -577,8 +576,6 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
vectorization_factor = *max_nunits;
}
- ncopies = vectorization_factor / TYPE_VECTOR_SUBPARTS (vectype);
-
if (is_gimple_call (stmt))
{
rhs_code = CALL_EXPR;
@@ -741,12 +738,15 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
else
{
/* Load. */
+ unsigned unrolling_factor
+ = least_common_multiple
+ (*max_nunits, group_size) / group_size;
/* FORNOW: Check that there is no gap between the loads
and no gap between the groups when we need to load
multiple groups at once.
??? We should enhance this to only disallow gaps
inside vectors. */
- if ((ncopies > 1
+ if ((unrolling_factor > 1
&& GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt
&& GROUP_GAP (vinfo_for_stmt (stmt)) != 0)
|| (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) != stmt
@@ -767,6 +767,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
/* Check that the size of interleaved loads group is not
greater than the SLP group size. */
+ unsigned ncopies
+ = vectorization_factor / TYPE_VECTOR_SUBPARTS (vectype);
if (loop_vinfo
&& GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt
&& ((GROUP_SIZE (vinfo_for_stmt (stmt))