Fix diff_type in expand_oacc_for char iter_type
authorTom de Vries <tom@codesourcery.com>
Mon, 7 Aug 2017 17:06:11 +0000 (17:06 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 7 Aug 2017 17:06:11 +0000 (17:06 +0000)
2017-08-07  Tom de Vries  <tom@codesourcery.com>

PR middle-end/78266
* omp-expand.c (expand_oacc_for): Ensure diff_type is large enough.

* testsuite/libgomp.oacc-c-c++-common/vprop-2.c: New test.
* testsuite/libgomp.oacc-c-c++-common/vprop.c: Remove xfail.

From-SVN: r250925

gcc/ChangeLog
gcc/omp-expand.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-c-c++-common/vprop-2.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c-c++-common/vprop.c

index 7579f410ea86949c62228b2379c97f99bbe3151f..2f1a274db16642b1bee5dddbc824fe9d30b69a41 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-07  Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/78266
+       * omp-expand.c (expand_oacc_for): Ensure diff_type is large enough.
+
 2017-08-07  Martin Liska  <mliska@suse.cz>
 
        * config/mips/mips.c: Include attribs.h.
index 0a0098af6695219ca15251aa22cdc9469a8e5459..0f635070a2136b44b61e4db9bf407f7aa9c7b3fd 100644 (file)
@@ -5328,6 +5328,8 @@ expand_oacc_for (struct omp_region *region, struct omp_for_data *fd)
     }
   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;
 
   basic_block entry_bb = region->entry; /* BB ending in OMP_FOR */
   basic_block exit_bb = region->exit; /* BB ending in OMP_RETURN */
index 0e6258ff87a3af8d98e52ae21c5e24df057d40f1..62d4f27d2f34251b3edcd54ce350bcbe3bb0ea1e 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-07  Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/78266
+       * testsuite/libgomp.oacc-c-c++-common/vprop-2.c: New test.
+       * testsuite/libgomp.oacc-c-c++-common/vprop.c: Remove xfail.
+
 2017-07-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/45784
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/vprop-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/vprop-2.c
new file mode 100644 (file)
index 0000000..046ac68
--- /dev/null
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+
+#include <assert.h>
+
+#define DO_PRAGMA(x) _Pragma (#x)
+
+#define test(idx,type,ngangs)                           \
+  void                                                  \
+  test_##idx ()                                         \
+  {                                                     \
+    int b[100];                                         \
+                                                        \
+    for (unsigned int i = 0; i < 100; i++)              \
+      b[i] = 0;                                         \
+                                                        \
+    DO_PRAGMA(acc parallel num_gangs (ngangs) copy (b)) \
+      {                                                 \
+        _Pragma("acc loop gang")                        \
+          for (type j = 0; j < 5; j++)                  \
+            {                                           \
+              _Pragma("acc loop vector")                \
+                for (unsigned int i = 0; i < 20; i++)   \
+                  b[j * 20 + i] = -2;                   \
+            }                                           \
+      }                                                 \
+                                                        \
+    for (unsigned int i = 0; i < 100; i++)              \
+      assert (b[i] == -2);                              \
+  }
+
+test (0, signed char, 256)
+test (1, unsigned char, 256)
+test (2, signed short, 65535)
+test (3, unsigned short, 65535)
+
+int
+main ()
+{
+  test_0 ();
+  test_1 ();
+  test_2 ();
+  test_3 ();
+
+  return 0;
+}
index 0ac0cf62e45b5d864b5ba6c537db225765a7d754..e4dd682e84f04926c88073bf434ba1a6eb9edff9 100644 (file)
@@ -1,5 +1,4 @@
 /* { dg-do run } */
-/* { dg-xfail-run-if "PR78266" { openacc_nvidia_accel_selected } } */
 
 #include <assert.h>