[openacc] Fix diff_type in expand_oacc_collapse_init
authorTom de Vries <tom@codesourcery.com>
Wed, 7 Feb 2018 10:37:55 +0000 (10:37 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Wed, 7 Feb 2018 10:37:55 +0000 (10:37 +0000)
2018-02-07  Tom de Vries  <tom@codesourcery.com>

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

gcc/ChangeLog
gcc/omp-expand.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/goacc/pr84217.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/goacc/pr84217.f90 [new file with mode: 0644]
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c-c++-common/pr84217.c [new file with mode: 0644]

index 7fc5914380650ad66a7537aca9ed60a66400361b..1caefb6aabe9496684000c7dc7a29b457c56934e 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-07  Tom de Vries  <tom@codesourcery.com>
+
+       PR libgomp/84217
+       * omp-expand.c (expand_oacc_collapse_init): Ensure diff_type is large
+       enough.
+
 2018-02-07  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84204
index 90e06310d81a95a2413a740e542bec354f95c622..bb204906ea64efa94a78b42bbc606c0e61f29192 100644 (file)
@@ -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)
        {
index 8506abea04ca7f0df350d168c9e873d0963dca3c..49e52ea8385e127603fdf2b2cc23ef1b39cd37f7 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-07  Tom de Vries  <tom@codesourcery.com>
+
+       PR libgomp/84217
+       * c-c++-common/goacc/pr84217.c: New test.
+       * gfortran.dg/goacc/pr84217.f90: New test.
+
 2018-02-07  Richard Biener  <rguenther@suse.de>
 
        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 (file)
index 0000000..c4f2920
--- /dev/null
@@ -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 (file)
index 0000000..cee49e9
--- /dev/null
@@ -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
index da740742d9a4a76d6e299447663af5491baf4399..91b47ce713731e413c60b2aef4f6e9fb2321912d 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-07  Tom de Vries  <tom@codesourcery.com>
+
+       PR libgomp/84217
+       * testsuite/libgomp.oacc-c-c++-common/pr84217.c: New test.
+
 2018-01-29  Christoph Spiel  <cspiel@freenet.de>
            Jakub Jelinek  <jakub@redhat.com>
 
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 (file)
index 0000000..18ff66a
--- /dev/null
@@ -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;
+}