This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp3] Fix collapsed omp for loop with pointer iterator(s) in lastprivate
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 4 Jun 2008 04:39:01 -0400
- Subject: [gomp3] Fix collapsed omp for loop with pointer iterator(s) in lastprivate
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
While working on tuplification of the OpenMP 3.0 stuff, I've noticed
missed POINTER_PLUS_EXPR in an assert.
2008-06-04 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (gimplify_omp_for): Allow POINTER_PLUS_EXPR
in assertion.
* testsuite/libgomp.c/loop-9.c: New test.
--- gcc/gimplify.c.jj 2008-05-16 14:51:34.000000000 +0200
+++ gcc/gimplify.c 2008-06-04 10:32:26.000000000 +0200
@@ -5564,7 +5564,8 @@ gimplify_omp_for (tree *expr_p, tree *pr
gcc_assert (GIMPLE_STMT_OPERAND (t, 0) == var);
t = GIMPLE_STMT_OPERAND (t, 1);
gcc_assert (TREE_CODE (t) == PLUS_EXPR
- || TREE_CODE (t) == MINUS_EXPR);
+ || TREE_CODE (t) == MINUS_EXPR
+ || TREE_CODE (t) == POINTER_PLUS_EXPR);
gcc_assert (TREE_OPERAND (t, 0) == var);
t = build2 (TREE_CODE (t), TREE_TYPE (decl), decl,
TREE_OPERAND (t, 1));
--- libgomp/testsuite/libgomp.c/loop-9.c.jj 2008-06-04 10:30:43.000000000 +0200
+++ libgomp/testsuite/libgomp.c/loop-9.c 2008-06-04 10:31:07.000000000 +0200
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+char buf[8] = "01234567";
+char buf2[8] = "23456789";
+
+int
+main (void)
+{
+ char *p, *q;
+ int sum = 0;
+ #pragma omp parallel for collapse (2) reduction (+:sum) lastprivate (p, q)
+ for (p = buf; p < &buf[8]; p++)
+ for (q = &buf2[0]; q <= buf2 + 7; q++)
+ sum += (*p - '0') + (*q - '0');
+ if (p != &buf[8] || q != buf2 + 8 || sum != 576)
+ abort ();
+ return 0;
+}
Jakub