aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-07-29 09:49:11 +0200
committerJakub Jelinek <jakub@redhat.com>2022-07-29 09:49:11 +0200
commit97d32048c04e9787fccadc4bae1c042754503e34 (patch)
treefc4aa18b0034c09ed0614d1757add4a0fbaedcaa /libgomp
parent4796d16de657d7c2720471e61432de0f4a5cb6df (diff)
downloadgcc-97d32048c04e9787fccadc4bae1c042754503e34.zip
gcc-97d32048c04e9787fccadc4bae1c042754503e34.tar.gz
gcc-97d32048c04e9787fccadc4bae1c042754503e34.tar.bz2
openmp: Fix up handling of non-rectangular simd loops with pointer type iterators [PR106449]
There were 2 issues visible on this new testcase, one that we didn't have special POINTER_TYPE_P handling in a few spots of expand_omp_simd - for pointers we need to use POINTER_PLUS_EXPR and need to have the non-pointer part in sizetype, for non-rectangular loop on the other side we can rely on multiplication factor 1, pointers can't be multiplied, without those changes we'd ICE. The other issue was that we put n2 expression directly into a comparison in a condition and regimplified that, for the &a[512] case that and with gimplification being destructed that unfortunately meant modification of original fd->loops[?].n2. Fixed by unsharing the expression. This was causing a runtime failure on the testcase. 2022-07-29 Jakub Jelinek <jakub@redhat.com> PR middle-end/106449 * omp-expand.cc (expand_omp_simd): Fix up handling of pointer iterators in non-rectangular simd loops. Unshare fd->loops[i].n2 or n2 before regimplifying it inside of a condition. * testsuite/libgomp.c-c++-common/pr106449.c: New test.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/testsuite/libgomp.c-c++-common/pr106449.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr106449.c b/libgomp/testsuite/libgomp.c-c++-common/pr106449.c
new file mode 100644
index 0000000..ea3cd82
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/pr106449.c
@@ -0,0 +1,62 @@
+/* PR middle-end/106449 */
+/* { dg-do run } */
+
+void
+foo (void)
+{
+ int a[1024], *b[65536];
+ int *p, *q, **r = &b[0], i;
+ #pragma omp simd collapse(2) linear(r : 2)
+ for (p = &a[0]; p < &a[512]; p++)
+ for (q = p + 64; q < p + 128; q++)
+ {
+ *r++ = p;
+ *r++ = q;
+ }
+ for (i = 0; i < 32768; i++)
+ if (b[2 * i] != &a[i / 64] || b[2 * i + 1] != &a[(i / 64) + 64 + (i % 64)])
+ __builtin_abort ();
+}
+
+void
+bar (int n, int m)
+{
+ int a[1024], *b[65536];
+ int *p, *q, **r = &b[0], i;
+ #pragma omp parallel for simd collapse(2) linear(r : 2)
+ for (p = &a[0]; p < &a[512]; p++)
+ for (q = p + n; q < p + m; q++)
+ {
+ *r++ = p;
+ *r++ = q;
+ }
+ for (i = 0; i < 32768; i++)
+ if (b[2 * i] != &a[i / 64] || b[2 * i + 1] != &a[(i / 64) + 64 + (i % 64)])
+ __builtin_abort ();
+}
+
+void
+baz (int n, int m)
+{
+ int a[1024], *b[8192];
+ int *p, *q, **r = &b[0], i;
+ #pragma omp parallel for simd collapse(2) linear(r : 2)
+ for (p = &a[0]; p < &a[512]; p += 4)
+ for (q = p + n; q < p + m; q += 2)
+ {
+ *r++ = p;
+ *r++ = q;
+ }
+ for (i = 0; i < 4096; i++)
+ if (b[2 * i] != &a[(i / 32) * 4] || b[2 * i + 1] != &a[(i / 32) * 4 + 64 + (i % 32) * 2])
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo ();
+ bar (64, 128);
+ baz (64, 128);
+ return 0;
+}