aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-omp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-27 09:22:07 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-27 09:22:07 +0200
commit2084b5f42a4432da8b0625f9c669bf690ec46468 (patch)
treeb600a0ba8491e143aec0a29d2b0a761a02673917 /gcc/c-family/c-omp.c
parent6b0f35299bd1468ebc13b900a73b7cac6181a2aa (diff)
downloadgcc-2084b5f42a4432da8b0625f9c669bf690ec46468.zip
gcc-2084b5f42a4432da8b0625f9c669bf690ec46468.tar.gz
gcc-2084b5f42a4432da8b0625f9c669bf690ec46468.tar.bz2
openmp: Allow non-rectangular loops with pointer iterators
This patch handles pointer iterators for non-rectangular loops. They are more limited than integral iterators of non-rectangular loops, in particular only var-outer, var-outer + a2, a2 + var-outer or var-outer - a2 can appear in lb or ub where a2 is some integral loop invariant expression, so no e.g. multiplication etc. 2021-10-27 Jakub Jelinek <jakub@redhat.com> gcc/ * omp-expand.c (expand_omp_for_init_counts): Handle non-rectangular iterators with pointer types. (expand_omp_for_init_vars, extract_omp_for_update_vars): Likewise. gcc/c-family/ * c-omp.c (c_omp_check_loop_iv_r): Don't clear 3rd bit for POINTER_PLUS_EXPR. (c_omp_check_nonrect_loop_iv): Handle POINTER_PLUS_EXPR. (c_omp_check_loop_iv): Set kind even if the iterator is non-integral. gcc/testsuite/ * c-c++-common/gomp/loop-8.c: New test. * c-c++-common/gomp/loop-9.c: New test. libgomp/ * testsuite/libgomp.c/loop-26.c: New test. * testsuite/libgomp.c/loop-27.c: New test.
Diffstat (limited to 'gcc/c-family/c-omp.c')
-rw-r--r--gcc/c-family/c-omp.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 32db226..fad0606 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -1358,6 +1358,7 @@ c_omp_check_loop_iv_r (tree *tp, int *walk_subtrees, void *data)
&& TREE_CODE (*tp) != PLUS_EXPR
&& TREE_CODE (*tp) != MINUS_EXPR
&& TREE_CODE (*tp) != MULT_EXPR
+ && TREE_CODE (*tp) != POINTER_PLUS_EXPR
&& !CONVERT_EXPR_P (*tp))
{
*walk_subtrees = 0;
@@ -1477,6 +1478,18 @@ c_omp_check_nonrect_loop_iv (tree *tp, struct c_omp_check_loop_iv_data *d,
}
a2 = integer_zero_node;
break;
+ case POINTER_PLUS_EXPR:
+ a1 = TREE_OPERAND (t, 0);
+ a2 = TREE_OPERAND (t, 1);
+ while (CONVERT_EXPR_P (a1))
+ a1 = TREE_OPERAND (a1, 0);
+ if (DECL_P (a1) && c_omp_is_loop_iterator (a1, d) >= 0)
+ {
+ a2 = TREE_OPERAND (t, 1);
+ t = a1;
+ break;
+ }
+ break;
default:
break;
}
@@ -1599,10 +1612,7 @@ c_omp_check_loop_iv (tree stmt, tree declv, walk_tree_lh lh)
data.fail = true;
}
/* Handle non-rectangular loop nests. */
- if (TREE_CODE (stmt) != OACC_LOOP
- && (TREE_CODE (TREE_OPERAND (init, 1)) == TREE_VEC
- || INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (init, 1))))
- && i > 0)
+ if (TREE_CODE (stmt) != OACC_LOOP && i > 0)
kind = 4;
data.kind = kind;
data.idx = i;