[Bug target/85077] New: V[248][SD]F abs not optimized to
kretz at kde dot org
gcc-bugzilla@gcc.gnu.org
Mon Mar 26 09:56:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85077
Bug ID: 85077
Summary: V[248][SD]F abs not optimized to
Product: gcc
Version: 8.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kretz at kde dot org
Target Milestone: ---
The following test case (also at https://godbolt.org/g/XEPk7M) shows that `x <
0 ? -x : x` is not optimized to an efficient abs implementation. This is not
only the case for SSE, but also for AVX and AVX512 vectors.
The my_abs functions show what I'd expect the result to be.
#include <x86intrin.h>
template <class T, int N> using V [[gnu::vector_size(N)]] = T;
auto abs(V<float, 16> x) { return x < 0 ? -x : x; }
auto my_abs(V<float, 16> x) {
return _mm_and_ps((__m128)(~V<unsigned, 16>() >> 1), x);
}
auto abs(V<double, 16> x) { return x < 0 ? -x : x; }
auto my_abs(V<double, 16> x) {
return _mm_and_pd((__m128d)(~V<unsigned long long, 16>() >> 1), x);
}
More information about the Gcc-bugs
mailing list