aboutsummaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-10-25 10:05:58 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-10-25 10:05:58 +0200
commitbc1a75dda26988781847f00cfc5283eb13418106 (patch)
tree49aebe92a0ce8de7fe12083ca8885548de051cc4 /gcc/attribs.c
parent57904e87b934e9dd8f94e9a0c4b3e10f3a4863ec (diff)
downloadgcc-bc1a75dda26988781847f00cfc5283eb13418106.zip
gcc-bc1a75dda26988781847f00cfc5283eb13418106.tar.gz
gcc-bc1a75dda26988781847f00cfc5283eb13418106.tar.bz2
re PR libstdc++/81706 (std::sin vectorization bug)
PR libstdc++/81706 * attribs.c (attribute_value_equal): Use omp_declare_simd_clauses_equal for comparison of OMP_CLAUSEs regardless of flag_openmp{,_simd}. (duplicate_one_attribute, copy_attributes_to_builtin): New functions. * attribs.h (duplicate_one_attribute, copy_attributes_to_builtin): New declarations. * c-decl.c (merge_decls): Copy "omp declare simd" attributes from newdecl to corresponding __builtin_ if any. * decl.c (duplicate_decls): Copy "omp declare simd" attributes from newdecl to corresponding __builtin_ if any. * gcc.target/i386/pr81706.c: New test. * g++.dg/ext/pr81706.C: New test. From-SVN: r254069
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index ed76a8d..809f4c3 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -1125,9 +1125,9 @@ attribute_value_equal (const_tree attr1, const_tree attr2)
TREE_VALUE (attr2)) == 1);
}
- if ((flag_openmp || flag_openmp_simd)
- && TREE_VALUE (attr1) && TREE_VALUE (attr2)
+ if (TREE_VALUE (attr1)
&& TREE_CODE (TREE_VALUE (attr1)) == OMP_CLAUSE
+ && TREE_VALUE (attr2)
&& TREE_CODE (TREE_VALUE (attr2)) == OMP_CLAUSE)
return omp_declare_simd_clauses_equal (TREE_VALUE (attr1),
TREE_VALUE (attr2));
@@ -1322,6 +1322,44 @@ merge_decl_attributes (tree olddecl, tree newdecl)
DECL_ATTRIBUTES (newdecl));
}
+/* Duplicate all attributes with name NAME in ATTR list to *ATTRS if
+ they are missing there. */
+
+void
+duplicate_one_attribute (tree *attrs, tree attr, const char *name)
+{
+ attr = lookup_attribute (name, attr);
+ if (!attr)
+ return;
+ tree a = lookup_attribute (name, *attrs);
+ while (attr)
+ {
+ tree a2;
+ for (a2 = a; a2; a2 = lookup_attribute (name, TREE_CHAIN (a2)))
+ if (attribute_value_equal (attr, a2))
+ break;
+ if (!a2)
+ {
+ a2 = copy_node (attr);
+ TREE_CHAIN (a2) = *attrs;
+ *attrs = a2;
+ }
+ attr = lookup_attribute (name, TREE_CHAIN (attr));
+ }
+}
+
+/* Duplicate all attributes from user DECL to the corresponding
+ builtin that should be propagated. */
+
+void
+copy_attributes_to_builtin (tree decl)
+{
+ tree b = builtin_decl_explicit (DECL_FUNCTION_CODE (decl));
+ if (b)
+ duplicate_one_attribute (&DECL_ATTRIBUTES (b),
+ DECL_ATTRIBUTES (decl), "omp declare simd");
+}
+
#if TARGET_DLLIMPORT_DECL_ATTRIBUTES
/* Specialization of merge_decl_attributes for various Windows targets.