From: Tom de Vries Date: Wed, 7 Feb 2018 10:37:55 +0000 (+0000) Subject: [openacc] Fix diff_type in expand_oacc_collapse_init X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c31bc4ac378f56593caae12bba086a98d002bb64;p=gcc.git [openacc] Fix diff_type in expand_oacc_collapse_init 2018-02-07 Tom de Vries PR libgomp/84217 * omp-expand.c (expand_oacc_collapse_init): Ensure diff_type is large enough. * c-c++-common/goacc/pr84217.c: New test. * gfortran.dg/goacc/pr84217.f90: New test. * testsuite/libgomp.oacc-c-c++-common/pr84217.c: New test. From-SVN: r257443 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7fc59143806..1caefb6aabe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-02-07 Tom de Vries + + PR libgomp/84217 + * omp-expand.c (expand_oacc_collapse_init): Ensure diff_type is large + enough. + 2018-02-07 Richard Biener PR tree-optimization/84204 diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index 90e06310d81..bb204906ea6 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -1433,6 +1433,8 @@ expand_oacc_collapse_init (const struct omp_for_data *fd, plus_type = sizetype; if (POINTER_TYPE_P (diff_type) || TYPE_UNSIGNED (diff_type)) diff_type = signed_type_for (diff_type); + if (TYPE_PRECISION (diff_type) < TYPE_PRECISION (integer_type_node)) + diff_type = integer_type_node; if (tiling) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8506abea04c..49e52ea8385 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-07 Tom de Vries + + PR libgomp/84217 + * c-c++-common/goacc/pr84217.c: New test. + * gfortran.dg/goacc/pr84217.f90: New test. + 2018-02-07 Richard Biener PR tree-optimization/84204 diff --git a/gcc/testsuite/c-c++-common/goacc/pr84217.c b/gcc/testsuite/c-c++-common/goacc/pr84217.c new file mode 100644 index 00000000000..c4f2920d88b --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/pr84217.c @@ -0,0 +1,8 @@ +void +foo (void) +{ +#pragma acc parallel loop tile (2, 3) + for (short i = 0; i < 10; ++i) + for (short j = 0; j < 10; ++j) + ; +} diff --git a/gcc/testsuite/gfortran.dg/goacc/pr84217.f90 b/gcc/testsuite/gfortran.dg/goacc/pr84217.f90 new file mode 100644 index 00000000000..cee49e9aba2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr84217.f90 @@ -0,0 +1,9 @@ +subroutine foo + integer(2) :: i, j + !$acc parallel loop tile(2,3) + do i = 1, 10 + do j = 1, 10 + end do + end do + !$acc end parallel loop +end diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index da740742d9a..91b47ce7137 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2018-02-07 Tom de Vries + + PR libgomp/84217 + * testsuite/libgomp.oacc-c-c++-common/pr84217.c: New test. + 2018-01-29 Christoph Spiel Jakub Jelinek diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c new file mode 100644 index 00000000000..18ff66a560b --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c @@ -0,0 +1,22 @@ +extern void abort (void); + +#define N 10 + +int +main (void) +{ + int a[N]; + + for (short i = 0; i < N; ++i) + a[i] = -1; + +#pragma acc parallel loop tile (2) + for (short i = 0; i < N; ++i) + a[i] = i; + + for (short i = 0; i < N; ++i) + if (a[i] != i) + abort (); + + return 0; +}