This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Improve -Ofast vectorization of std::sin etc. (PR libstdc++/81706)


Hi!

glibc for -ffast-math annotates a couple of math functions with simd
attribute, so that one can use vectorized versions with 4/8/16 vectorization
factor.

If one uses ::cos or ::cosf or std::cos(double), this works just fine, but not
when using std::cos(float).  This is because the libstdc++ headers call
__builtin_cosf, but the builtin function doesn't have the simd attribute,
only ::cosf does.

Attached are 2 patches to improve this.

The first one is a C/C++ FE change, which arranges that if we add simd
attribute to say ::cosf, then calls to __builtin_cosf will act as if
__builtin_cosf also has the attribute.  While other attributes aren't
handled this way, perhaps a small precedent to such change is that if
somebody uses typeof (cosf) cosf __asm ("foobar"); then calls to
__builtin_cosf if they expand into a library call will call foobar, not
cosf.

The other patch is instead a libstdc++ change, not using __builtin_cosf
etc., but ::cosf.

Both patches have been (separately) bootstrapped/regtested on x86_64-linux
and i686-linux.

	Jakub

Attachment: U674
Description: Text document

Attachment: U675
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]