re PR c++/71257 (OpenMP declare simd linear with ref modifier doesn't accept referenc...
authorJakub Jelinek <jakub@redhat.com>
Tue, 24 May 2016 16:19:43 +0000 (18:19 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 24 May 2016 16:19:43 +0000 (18:19 +0200)
PR c++/71257
* tree-vect-stmts.c (vectorizable_simd_clone_call): Handle
SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP like
SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP.  Add
SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP and
SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP cases explicitly.

* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_LINEAR>:
For OMP_CLAUSE_LINEAR_REF don't require type to be
integral or pointer.

* g++.dg/vect/simd-clone-6.cc: New test.
* g++.dg/gomp/declare-simd-6.C: New test.

From-SVN: r236648

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/declare-simd-6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/vect/simd-clone-6.cc [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 0ca7e794ef78e9471d2b036f8de563775e63ad60..1b81d4106f838938e1a72921965bcbb5110dfb01 100644 (file)
@@ -1,3 +1,12 @@
+2016-05-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71257
+       * tree-vect-stmts.c (vectorizable_simd_clone_call): Handle
+       SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP like
+       SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP.  Add
+       SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP and
+       SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP cases explicitly.
+
 2016-05-24  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71240
index eaf42b83f1c67350b438969b8c3b5b3d78a9ade8..c77dee6dfb7c43606c75819a81a8d8c0cb8e4a06 100644 (file)
@@ -1,3 +1,10 @@
+2016-05-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71257
+       * semantics.c (finish_omp_clauses) <case OMP_CLAUSE_LINEAR>:
+       For OMP_CLAUSE_LINEAR_REF don't require type to be
+       integral or pointer.
+
 2016-05-24  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/70434
index 06dee5a66698bd16233520892e72fbf1ebe3e834..21ef42f5534da50f66958c6483f9140cdc0b8b83 100644 (file)
@@ -5881,7 +5881,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
                      break;
                    }
                }
-             else
+             else if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF)
                {
                  if (!INTEGRAL_TYPE_P (type)
                      && TREE_CODE (type) != POINTER_TYPE)
index 2f66ad1d8e86e48c3bab9dd9205cc1c7aca80c2f..c0a271cefd9e206369c46851f6a5c15c2c1cc893 100644 (file)
@@ -1,5 +1,9 @@
 2016-05-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71257
+       * g++.dg/vect/simd-clone-6.cc: New test.
+       * g++.dg/gomp/declare-simd-6.C: New test.
+
        PR middle-end/70434
        PR c/69504
        * c-c++-common/vector-subscript-5.c (foo): Move ; out of the ifdef.
diff --git a/gcc/testsuite/g++.dg/gomp/declare-simd-6.C b/gcc/testsuite/g++.dg/gomp/declare-simd-6.C
new file mode 100644 (file)
index 0000000..09137ee
--- /dev/null
@@ -0,0 +1,37 @@
+// PR c++/71257
+// { dg-do compile }
+// { dg-options "-fopenmp-simd" }
+
+struct S { int a; };
+#pragma omp declare simd linear(val(a):2)
+int f1 (int &a);
+#pragma omp declare simd linear(uval(a):2)
+unsigned short f2 (unsigned short &a);
+#pragma omp declare simd linear(ref(a):1)
+int f3 (long long int &a);
+#pragma omp declare simd linear(a:1)
+int f4 (int &a);
+#pragma omp declare simd linear(val(a))
+int f5 (int a);
+#pragma omp declare simd linear(uval(a):2)             // { dg-error "modifier applied to non-reference variable" }
+int f6 (unsigned short a);
+#pragma omp declare simd linear(ref(a):1)              // { dg-error "modifier applied to non-reference variable" }
+int f7 (unsigned long int a);
+#pragma omp declare simd linear(a:1)
+int f8 (int a);
+#pragma omp declare simd linear(val(a):2)              // { dg-error "applied to non-integral non-pointer variable" }
+int f9 (S &a);
+#pragma omp declare simd linear(uval(a):2)             // { dg-error "applied to non-integral non-pointer variable" }
+int f10 (S &a);
+#pragma omp declare simd linear(ref(a):1)              // { dg-bogus "applied to non-integral non-pointer variable" }
+int f11 (S &a);
+#pragma omp declare simd linear(a:1)                   // { dg-error "applied to non-integral non-pointer variable" }
+int f12 (S &a);
+#pragma omp declare simd linear(val(a))                        // { dg-error "applied to non-integral non-pointer variable" }
+int f13 (S a);
+#pragma omp declare simd linear(uval(a):2)             // { dg-error "modifier applied to non-reference variable" }
+int f14 (S a);
+#pragma omp declare simd linear(ref(a):1)              // { dg-error "modifier applied to non-reference variable" }
+int f15 (S a);
+#pragma omp declare simd linear(a:1)                   // { dg-error "applied to non-integral non-pointer variable" }
+int f16 (S a);
diff --git a/gcc/testsuite/g++.dg/vect/simd-clone-6.cc b/gcc/testsuite/g++.dg/vect/simd-clone-6.cc
new file mode 100644 (file)
index 0000000..fb00e88
--- /dev/null
@@ -0,0 +1,43 @@
+// PR c++/71257
+// { dg-require-effective-target vect_simd_clones }
+// { dg-additional-options "-fopenmp-simd -fno-inline" }
+// { dg-additional-options "-mavx" { target avx_runtime } }
+
+#include "../../gcc.dg/vect/tree-vect.h"
+
+#define N 1024
+struct S { int a; };
+int c[N], e[N], f[N];
+S d[N];
+
+#pragma omp declare simd linear(ref(b, c) : 1)
+int
+foo (int a, S &b, int &c)
+{
+  return a + b.a + c;
+}
+
+void
+do_main ()
+{
+  int i;
+  for (i = 0; i < N; i++)
+    {
+      c[i] = i;
+      d[i].a = 2 * i;
+      f[i] = 3 * i;
+    }
+  #pragma omp simd
+  for (i = 0; i < N; i++)
+    e[i] = foo (c[i], d[i], f[i]);
+  for (i = 0; i < N; i++)
+    if (e[i] != 6 * i)
+      __builtin_abort ();
+}
+
+int
+main ()
+{
+  check_vect ();
+  return 0;
+}
index d9e9cbbba5c258afb12d29d98dfb52f68819ae6a..f11f22e3eb8667533cc85f7b41839fdee2d3e942 100644 (file)
@@ -3012,8 +3012,10 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
     {
       STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (bestn->decl);
       for (i = 0; i < nargs; i++)
-       if (bestn->simdclone->args[i].arg_type
-           == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP)
+       if ((bestn->simdclone->args[i].arg_type
+            == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP)
+           || (bestn->simdclone->args[i].arg_type
+               == SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP))
          {
            STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_grow_cleared (i * 3
                                                                        + 1);
@@ -3148,6 +3150,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
              vargs.safe_push (op);
              break;
            case SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP:
+           case SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP:
              if (j == 0)
                {
                  gimple_seq stmts;
@@ -3211,6 +3214,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
                  vargs.safe_push (new_temp);
                }
              break;
+           case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP:
+           case SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP:
            case SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP:
            case SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP:
            case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP: