From: Jakub Jelinek Date: Wed, 8 Jul 2015 20:29:26 +0000 (+0200) Subject: c-omp.c (c_omp_declare_simd_clauses_to_numbers): If all clauses are to be removed... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b03b462f1ffdef448aa666d8079cd047bcddee77;p=gcc.git c-omp.c (c_omp_declare_simd_clauses_to_numbers): If all clauses are to be removed, return NULL rather than original clauses list. * c-omp.c (c_omp_declare_simd_clauses_to_numbers): If all clauses are to be removed, return NULL rather than original clauses list. * decl.c (grokfndecl): Handle flag_openmp_simd like flag_openmp. * pt.c (apply_late_template_attributes): Likewise. * g++.dg/vect/vect.exp: Run also simd* tests. * gcc.dg/vect/tree-vect.h (abort, exit): For C++ use extern "C". (check_vect): Fix up get_cpuid call for C++. * g++.dg/vect/simd-clone-1.cc: New test. From-SVN: r225583 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 63ba71450cc..63d592ddc56 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2015-07-08 Jakub Jelinek + + * c-omp.c (c_omp_declare_simd_clauses_to_numbers): If all clauses + are to be removed, return NULL rather than original clauses list. + 2015-07-07 Andrew MacLeod * array-notation-common.c: Adjust includes. diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 607d16d6e28..cdd2ee83d76 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -1040,6 +1040,8 @@ c_omp_declare_simd_clauses_to_numbers (tree parms, tree clauses) for (i = 0; i < len; i++) OMP_CLAUSE_CHAIN (clvec[i]) = (i < len - 1) ? clvec[i + 1] : NULL_TREE; } + else + clauses = NULL_TREE; clvec.release (); return clauses; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e469156c8ff..74b746a5398 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-07-08 Jakub Jelinek + + * decl.c (grokfndecl): Handle flag_openmp_simd like flag_openmp. + * pt.c (apply_late_template_attributes): Likewise. + 2015-07-08 Marek Polacek PR c++/66748 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b70a2cc1b0f..db8b1aa17ca 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7910,7 +7910,7 @@ grokfndecl (tree ctype, if (TYPE_NOTHROW_P (type) || nothrow_libfn_p (decl)) TREE_NOTHROW (decl) = 1; - if (flag_openmp || flag_cilkplus) + if (flag_openmp || flag_openmp_simd || flag_cilkplus) { /* Adjust "omp declare simd" attributes. */ tree ods = lookup_attribute ("omp declare simd", *attrlist); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2f336ed41da..d3e9d3175b5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9071,7 +9071,7 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, { *p = TREE_CHAIN (t); TREE_CHAIN (t) = NULL_TREE; - if ((flag_openmp || flag_cilkplus) + if ((flag_openmp || flag_openmp_simd || flag_cilkplus) && is_attribute_p ("omp declare simd", get_attribute_name (t)) && TREE_VALUE (t)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3fa2511c40f..d883a7c8406 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-07-08 Jakub Jelinek + + * g++.dg/vect/vect.exp: Run also simd* tests. + * gcc.dg/vect/tree-vect.h (abort, exit): For C++ use extern "C". + (check_vect): Fix up get_cpuid call for C++. + * g++.dg/vect/simd-clone-1.cc: New test. + 2015-07-08 H.J. Lu * gcc.target/i386/pr37870.c (dg-options): Add -mlong-double-80. diff --git a/gcc/testsuite/g++.dg/vect/simd-clone-1.cc b/gcc/testsuite/g++.dg/vect/simd-clone-1.cc new file mode 100644 index 00000000000..f0be59aa600 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/simd-clone-1.cc @@ -0,0 +1,55 @@ +// { 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" + +struct S +{ + int s; + #pragma omp declare simd notinbranch linear(x) + int f (int x); +}; + +#pragma omp declare simd notinbranch linear(x) +int +S::f (int x) +{ + return x; +} + +template +struct T +{ + int t; + #pragma omp declare simd notinbranch linear(x) + int f (int x); +}; + +#pragma omp declare simd notinbranch linear(x) +template +int +T::f (int x) +{ + return x; +} + +void +do_main () +{ + int i, r = 0; + S s; + T<0> t; + #pragma omp simd reduction(+:r) + for (i = 0; i < 64; i++) + r += s.f (i) + t.f (i); + if (r != 64 * 63) + abort (); +} + +int +main () +{ + check_vect (); + do_main (); +} diff --git a/gcc/testsuite/g++.dg/vect/vect.exp b/gcc/testsuite/g++.dg/vect/vect.exp index aba1866a3ac..0492cc392bd 100644 --- a/gcc/testsuite/g++.dg/vect/vect.exp +++ b/gcc/testsuite/g++.dg/vect/vect.exp @@ -58,7 +58,7 @@ lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details" dg-init # Main loop. -g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.{c,cc,S} ]] \ +g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/{pr,simd}*.{c,cc,S} ]] \ "" $DEFAULT_VECTCFLAGS g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-pr*.{c,cc,S} ]] \ "" $VECT_SLP_CFLAGS diff --git a/gcc/testsuite/gcc.dg/vect/tree-vect.h b/gcc/testsuite/gcc.dg/vect/tree-vect.h index 2f21c2b1673..0853e3f76be 100644 --- a/gcc/testsuite/gcc.dg/vect/tree-vect.h +++ b/gcc/testsuite/gcc.dg/vect/tree-vect.h @@ -5,8 +5,14 @@ # include "cpuid.h" #endif +#ifdef __cplusplus +extern "C" { +#endif extern void abort (void); extern void exit (int); +#ifdef __cplusplus +} +#endif static void sig_ill_handler (int sig) @@ -26,7 +32,7 @@ check_vect (void) asm volatile (".long 0x10000484"); #elif defined(__i386__) || defined(__x86_64__) { - int a, b, c, d, want_level, want_c, want_d; + unsigned int a, b, c, d, want_level, want_c, want_d; /* Determine what instruction set we've been compiled for, and detect that we're running with it. This allows us to at least do a compile