This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81706] std::sin vectorization bug
- From: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 04 Aug 2017 11:05:59 +0000
- Subject: [Bug libstdc++/81706] std::sin vectorization bug
- Auto-submitted: auto-generated
- References: <bug-81706-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81706
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 4 Aug 2017, jakub at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81706
>
> --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> The C/C++ FE change would be something like:
> --- gcc/tree.c.jj 2017-07-29 09:48:40.000000000 +0200
> +++ gcc/tree.c 2017-08-04 12:06:35.636072718 +0200
> @@ -5022,8 +5022,8 @@ attribute_value_equal (const_tree attr1,
> TREE_VALUE (attr2)) == 1);
> }
>
> - if ((flag_openmp || flag_openmp_simd)
> - && TREE_VALUE (attr1) && TREE_VALUE (attr2)
> + if (TREE_VALUE (attr1)
> + && TREE_VALUE (attr2)
> && TREE_CODE (TREE_VALUE (attr1)) == OMP_CLAUSE
> && TREE_CODE (TREE_VALUE (attr2)) == OMP_CLAUSE)
> return omp_declare_simd_clauses_equal (TREE_VALUE (attr1),
> --- gcc/cp/decl.c.jj 2017-08-01 19:23:10.000000000 +0200
> +++ gcc/cp/decl.c 2017-08-04 12:44:44.773780568 +0200
> @@ -2456,6 +2456,35 @@ next_arg:;
> break;
> }
> }
> +
> + tree s = lookup_attribute ("omp declare simd",
> + DECL_ATTRIBUTES (newdecl));
> + if (s)
> + {
> + tree b = builtin_decl_explicit (DECL_FUNCTION_CODE (newdecl));
> + if (b)
> + {
> + tree s2 = lookup_attribute ("omp declare simd",
> + DECL_ATTRIBUTES (b));
> + while (s)
> + {
> + tree s3;
> + for (s3 = s2; s3;
> + s3 = lookup_attribute ("omp declare simd",
> + TREE_CHAIN (s3)))
> + if (attribute_value_equal (s, s3))
> + break;
> + if (!s3)
> + {
> + s3 = copy_node (s);
> + TREE_CHAIN (s3) = DECL_ATTRIBUTES (b);
> + DECL_ATTRIBUTES (b) = s3;
> + }
> + s = lookup_attribute ("omp declare simd",
> + TREE_CHAIN (s));
> + }
> + }
> + }
> }
> if (new_defines_function)
> /* If defining a function declared with other language
> --- gcc/c/c-decl.c.jj 2017-07-31 11:31:15.000000000 +0200
> +++ gcc/c/c-decl.c 2017-08-04 12:39:48.113226134 +0200
> @@ -2566,6 +2566,36 @@ merge_decls (tree newdecl, tree olddecl,
> set_builtin_decl_declared_p (fncode, true);
> break;
> }
> +
> + tree s = lookup_attribute ("omp declare simd",
> + DECL_ATTRIBUTES (newdecl));
> + if (s)
> + {
> + tree b
> + = builtin_decl_explicit (DECL_FUNCTION_CODE (newdecl));
> + if (b)
> + {
> + tree s2 = lookup_attribute ("omp declare simd",
> + DECL_ATTRIBUTES (b));
> + while (s)
> + {
> + tree s3;
> + for (s3 = s2; s3;
> + s3 = lookup_attribute ("omp declare simd",
> + TREE_CHAIN (s3)))
> + if (attribute_value_equal (s, s3))
> + break;
> + if (!s3)
> + {
> + tree s3 = copy_node (s);
> + TREE_CHAIN (s3) = DECL_ATTRIBUTES (b);
> + DECL_ATTRIBUTES (b) = s3;
> + }
> + s = lookup_attribute ("omp declare simd",
> + TREE_CHAIN (s));
> + }
> + }
> + }
> }
> }
> else
>
> and has the advantage that any other uses of __builtin_* would work that way.
True, but it removes the ability to avoid the vectorized variant with
using the __builtin_ variant ;) I think we never move attributes on
the C library header prototypes to our builtins, do we?
> As for the libstdc++-v3 patch, why is it incomplete? I've just changed the
> cases where glibc has
> routines with simd attribute (which is only for float/double routines, not for
> long double, and
> only those changed in the patch).
Oh, I was just looking for consistent handling -- where we have using ::X
use ::X instead of a builtin.