On 30/11/15 17:48, Jakub Jelinek wrote:
On Mon, Nov 30, 2015 at 05:36:25PM +0100, Tom de Vries wrote:
+int
+main (void)
+{
+ unsigned results[nEvents];
+ unsigned pData[nEvents];
+ unsigned coeff = 2;
+
+ init (&results[0], &pData[0]);
+
+#pragma omp parallel for
+ for (int idx = 0; idx < (int)nEvents; idx++)
+ results[idx] = coeff * pData[idx];
Could you please add another testcase, where you have say pData
and some other pointer that init sets to alias with pData, and verify
that such loop (would need to be say normal loop inside #pragma omp single
or master) is not vectorized?
I've:
- added a simpler (not vectorizer-based) version of the testcase as
pr46032-2.c, and
- copied pr46032-2.c to pr46032-3.c and modified it such that two
pointers are aliasing
Committed to trunk.
Thanks,
- Tom
Add gcc.dg/pr46032-{2,3}.c test-cases
2015-11-30 Tom de Vries <t...@codesourcery.com>
* gcc.dg/pr46032-2.c: New test.
* gcc.dg/pr46032-3.c: New test.
---
gcc/testsuite/gcc.dg/pr46032-2.c | 29 +++++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/pr46032-3.c | 28 ++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/pr46032-2.c b/gcc/testsuite/gcc.dg/pr46032-2.c
new file mode 100644
index 0000000..e110880
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46032-2.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp -std=c99 -fipa-pta -fdump-tree-optimized" } */
+
+#define N 2
+
+int
+foo (void)
+{
+ int a[N], b[N], c[N];
+ int *ap = &a[0];
+ int *bp = &b[0];
+ int *cp = &c[0];
+
+#pragma omp parallel for
+ for (unsigned int idx = 0; idx < N; idx++)
+ {
+ ap[idx] = 1;
+ bp[idx] = 2;
+ cp[idx] = ap[idx];
+ }
+
+ return *cp;
+}
+
+/* { dg-final { scan-tree-dump-times "\\] = 1;" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\] = 2;" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\] = _\[0-9\]*;" 0 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\] = " 3 "optimized" } } */
+
diff --git a/gcc/testsuite/gcc.dg/pr46032-3.c b/gcc/testsuite/gcc.dg/pr46032-3.c
new file mode 100644
index 0000000..a4af7ec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46032-3.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp -std=c99 -fipa-pta -fdump-tree-optimized" } */
+
+#define N 2
+
+int
+foo (void)
+{
+ int a[N], c[N];
+ int *ap = &a[0];
+ int *bp = &a[0];
+ int *cp = &c[0];
+
+#pragma omp parallel for
+ for (unsigned int idx = 0; idx < N; idx++)
+ {
+ ap[idx] = 1;
+ bp[idx] = 2;
+ cp[idx] = ap[idx];
+ }
+
+ return *cp;
+}
+
+/* { dg-final { scan-tree-dump-times "\\] = 1;" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\] = 2;" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\] = _\[0-9\]*;" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\] = " 3 "optimized" } } */