public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/54408] New: sqrt for vector types
@ 2012-08-29 14:06 glisse at gcc dot gnu.org
2012-09-03 10:17 ` [Bug c/54408] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-08-29 14:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54408
Bug #: 54408
Summary: sqrt for vector types
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: glisse@gcc.gnu.org
Hello,
it would be nice to add sqrt to the gcc vector extensions. There are already
target specific builtins, but a generic one would fit better (and get lowered
to elementwise sqrt when the target doesn't support vector sqrt). I don't know
if __builtin_sqrt should be extended, or maybe a different __builtin_vec_sqrt.
Component "other" because fixing this might involve front, middle and
back-ends.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/54408] sqrt for vector types
2012-08-29 14:06 [Bug other/54408] New: sqrt for vector types glisse at gcc dot gnu.org
@ 2012-09-03 10:17 ` rguenth at gcc dot gnu.org
2012-09-03 15:47 ` joseph at codesourcery dot com
2012-09-06 15:05 ` glisse at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-03 10:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54408
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-09-03
CC| |jsm28 at gcc dot gnu.org
Component|other |c
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-09-03 10:17:11 UTC ---
Hmm, I suppose the extension would be to the C type-generic math piece. Of
course that would require library support for most routines (and an ABI for
them) or GCC, if no such routine is specified, expanding to a call for each
vector component. Just special-casing sqrt may be convenient but odd.
Joseph, any input?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/54408] sqrt for vector types
2012-08-29 14:06 [Bug other/54408] New: sqrt for vector types glisse at gcc dot gnu.org
2012-09-03 10:17 ` [Bug c/54408] " rguenth at gcc dot gnu.org
@ 2012-09-03 15:47 ` joseph at codesourcery dot com
2012-09-06 15:05 ` glisse at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2012-09-03 15:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54408
--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-09-03 15:47:38 UTC ---
Built-in mathematical functions are generally type-generic where they
correspond to type-generic math.h macros (e.g. isgreater, isnan), not
otherwise. (__builtin_signbit should be changed to type-generic: bug
36757.)
I think __builtin_sqrt should be expected to correspond directly to the
sqrt (double) library function rather than being type-generic - thus, I
think vector versions of library functions (where those functions are not
type-generic) should be separate from the normal built-in versions of
those functions (e.g. define __builtin_vec_sqrt - which could itself be
type-generic over different vector types).
Remember to define, both at the language level and at the ABI level,
things such as how such a built-in function handles errors / exceptional
values (and whether or not this depends at the language level on the
various -f options that affect this for ordinary C language arithmetic and
library calls).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/54408] sqrt for vector types
2012-08-29 14:06 [Bug other/54408] New: sqrt for vector types glisse at gcc dot gnu.org
2012-09-03 10:17 ` [Bug c/54408] " rguenth at gcc dot gnu.org
2012-09-03 15:47 ` joseph at codesourcery dot com
@ 2012-09-06 15:05 ` glisse at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-09-06 15:05 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-06 15:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-29 14:06 [Bug other/54408] New: sqrt for vector types glisse at gcc dot gnu.org
2012-09-03 10:17 ` [Bug c/54408] " rguenth at gcc dot gnu.org
2012-09-03 15:47 ` joseph at codesourcery dot com
2012-09-06 15:05 ` glisse at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).