This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54408] sqrt for vector types
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Sep 2012 15:04:53 +0000
- Subject: [Bug c/54408] sqrt for vector types
- Auto-submitted: auto-generated
- References: <bug-54408-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54408
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> 2012-09-06 15:04:53 UTC ---
Thanks for the explanations.
One goal would be, in C++, to be able to write a single function template:
template<class T> T f(T x){return x+sqrt(x);}
which would work for float, double, long double, float vectors and double
vectors. (how exactly sqrt is spelled, possibly __builtin_math_sqrt, isn't that
important)
Currently, std::sqrt is overloaded on arithmetic types. If we had
__builtin_vec_sqrt, I guess we could add an extra overload to std::sqrt for
vector types (sfinae-constrained in some way). Not quite as convenient as a
completely generic __builtin_sqrt, but good enough I think (assuming the
libstdc++ maintainers are ok with it). Otherwise, a more generic
__builtin_math_sqrt which works on both scalars and vectors would be better.