aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-expand.c
diff options
context:
space:
mode:
authorHafiz Abid Qadeer <abidh@codesourcery.com>2021-04-08 17:31:30 +0100
committerHafiz Abid Qadeer <abidh@codesourcery.com>2021-04-11 14:44:22 +0100
commitac200799acb5cd2fb9e1758f6bf5fff1978daaeb (patch)
tree960956aed6d5a0a036df588e1a75f0cf0f1277b0 /gcc/omp-expand.c
parentcdb23bba5c48ede5a6163900f8bf423746b70bee (diff)
downloadgcc-ac200799acb5cd2fb9e1758f6bf5fff1978daaeb.zip
gcc-ac200799acb5cd2fb9e1758f6bf5fff1978daaeb.tar.gz
gcc-ac200799acb5cd2fb9e1758f6bf5fff1978daaeb.tar.bz2
[OpenACC] Fix an ICE where a loop with GT condition is collapsed.
We have seen an ICE both on trunk and devel/omp/gcc-10 branches which can be reprodued with this simple testcase. It occurs if an OpenACC loop has a collapse clause and any of the loop being collapsed uses GT or GE condition. This issue is specific to OpenACC. int main (void) { int ix, iy; int dim_x = 16, dim_y = 16; { for (iy = dim_y - 1; iy > 0; --iy) for (ix = dim_x - 1; ix > 0; --ix) ; } } The problem is caused by a failing assertion in expand_oacc_collapse_init. It checks that cond_code for fd->loop should be same as cond_code for all the loops that are being collapsed. As the cond_code for fd->loop is LT_EXPR with collapse clause (set at the end of omp_extract_for_data), this assertion forces that all the loop in collapse clause should use < operator. There does not seem to be anything in the code which demands this condition as loop with > condition works ok otherwise. I digged old mailing list a bit but could not find any discussion on this change. Looking at the code, expand_oacc_for checks that fd->loop->cond_code is either LT_EXPR or GT_EXPR. I guess the original intention was to have similar checks on the loop which are being collapsed. But the way check was written does not acheive that. I have fixed it by modifying the check in the assertion to be same as check on fd->loop->cond_code. I tested goacc and libgomp (with nvptx offloading) and did not see any regression. I have added new tests to check collapse with GT/GE condition. PR middle-end/98088 gcc/ * omp-expand.c (expand_oacc_collapse_init): Update condition in a gcc_assert. gcc/testsuite/ * c-c++-common/goacc/collapse-2.c: New. libgomp/ * testsuite/libgomp.oacc-c-c++-common/collapse-2.c: Add check for loop with GT/GE condition. * testsuite/libgomp.oacc-c-c++-common/collapse-3.c: Likewise.
Diffstat (limited to 'gcc/omp-expand.c')
-rw-r--r--gcc/omp-expand.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 7559ec8..dc797f9 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -1541,7 +1541,7 @@ expand_oacc_collapse_init (const struct omp_for_data *fd,
tree iter_type = TREE_TYPE (loop->v);
tree plus_type = iter_type;
- gcc_assert (loop->cond_code == fd->loop.cond_code);
+ gcc_assert (loop->cond_code == LT_EXPR || loop->cond_code == GT_EXPR);
if (POINTER_TYPE_P (iter_type))
plus_type = sizetype;