[Bug c/88153] New: sqrt() is not vectorized
bugzilla@poradnik-webmastera.com
gcc-bugzilla@gcc.gnu.org
Thu Nov 22 16:55:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88153
Bug ID: 88153
Summary: sqrt() is not vectorized
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bugzilla@poradnik-webmastera.com
Target Milestone: ---
Sequence of calls to sqrt() is not vectorized.
I found Bug 21466 that claims that it was fixed in GCC 4.3, but looks that
change was reverted - at least 4.4.7 it also is not vectorized. I suspect that
after that change errors were not reported correctly - non-vectorized code uses
sqrtsd, and for negative numbers it also calls sqrt for its side effects.
I wrote following code snippet as a possible solution for SSE instructions. I
did not check all details how errors should be reported for sequence of sqrt
calls, so it may need some changes.
#include <emmintrin.h>
#include <math.h>
#define SIZE 8
double d1[SIZE];
double d2[SIZE];
void test()
{
int m = 0;
for (int n = 0; n < SIZE; n += 2)
{
__m128d v = _mm_load_pd(&d1[n]);
__m128d vs = _mm_sqrt_pd(v);
__m128d vn = _mm_cmplt_pd(v, _mm_setzero_pd());
m |= _mm_movemask_pd(vn);
_mm_store_pd(&d2[n], vs);
}
if (m)
sqrt(-1.0);
}
More information about the Gcc-bugs
mailing list