remove skvx::{rsqrt,rcp}

These don't return reliable portable results, so I don't want to promote
them as good ideas to use.  You can get at least 5 different results
from these across the four main architectures we support, and they've
been the root cause of bugs uncovered only in production on undertested
platforms.

Luckily, unused outside of tests.

Change-Id: I532731fe4cddf127253341e5ace8d9c5c9ebb0f1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/326108
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2020-10-13 09:52:24 -05:00 committed by Skia Commit-Bot
parent b3c42efd25
commit a221f1c36d
2 changed files with 0 additions and 57 deletions

View File

@ -558,9 +558,6 @@ SIN Vec<N,int> lrint(const Vec<N,float>& x) {
lrint(x.hi));
}
// TODO: new-style platform specializations for rcp() / rsqrt()?
SIN Vec<N,float> rcp(const Vec<N,float>& x) { return 1/x; }
SIN Vec<N,float> rsqrt(const Vec<N,float>& x) { return rcp(sqrt(x)); }
SIN Vec<N,float> fract(const Vec<N,float>& x) { return x - floor(x); }
// The default logic for to_half/from_half is borrowed from skcms,
@ -673,37 +670,6 @@ SIN Vec<N,uint8_t> approx_scale(const Vec<N,uint8_t>& x, const Vec<N,uint8_t>& y
}
#endif
#if !defined(SKNX_NO_SIMD)
// Platform-specific specializations and overloads can now drop in here.
#if defined(__AVX__)
SI Vec<8,float> rsqrt(const Vec<8,float>& x) {
return bit_pun<Vec<8,float>>(_mm256_rsqrt_ps(bit_pun<__m256>(x)));
}
SI Vec<8,float> rcp(const Vec<8,float>& x) {
return bit_pun<Vec<8,float>>(_mm256_rcp_ps(bit_pun<__m256>(x)));
}
#endif
#if defined(__SSE__)
SI Vec<4,float> rsqrt(const Vec<4,float>& x) {
return bit_pun<Vec<4,float>>(_mm_rsqrt_ps(bit_pun<__m128>(x)));
}
SI Vec<4,float> rcp(const Vec<4,float>& x) {
return bit_pun<Vec<4,float>>(_mm_rcp_ps(bit_pun<__m128>(x)));
}
SI Vec<2,float> rsqrt(const Vec<2,float>& x) {
return shuffle<0,1>(rsqrt(shuffle<0,1,0,1>(x)));
}
SI Vec<2,float> rcp(const Vec<2,float>& x) {
return shuffle<0,1>( rcp(shuffle<0,1,0,1>(x)));
}
#endif
#endif // !defined(SKNX_NO_SIMD)
} // namespace skvx
#undef SINTU

View File

@ -29,24 +29,6 @@ using long2 = skvx::Vec<2,int64_t>;
using long4 = skvx::Vec<4,int64_t>;
using long8 = skvx::Vec<8,int64_t>;
// These are unused, and just here so I can look at the disassembly.
float2 Sqrt(float2 x) { return sqrt(x); }
float4 Sqrt(float4 x) { return sqrt(x); }
float8 Sqrt(float8 x) { return sqrt(x); }
float4 RSqrt(float4 x) { return rsqrt(x); }
float4 Rcp(float4 x) { return rcp(x); }
float4 Ceil(float4 x) { return ceil(x); }
float4 Floor(float4 x) { return floor(x); }
float4 Trunc(float4 x) { return trunc(x); }
float4 Round(float4 x) { return round(x); }
float4 Abs(float4 x) { return abs(x); }
float4 Min(float4 x, float4 y) { return min(x,y); }
float4 Max(float4 x, float4 y) { return max(x,y); }
float4 IfThenElse(int4 c, float4 t, float4 e) { return if_then_else(c,t,e); }
DEF_TEST(SkVx, r) {
static_assert(sizeof(float2) == 8, "");
static_assert(sizeof(float4) == 16, "");
@ -106,12 +88,7 @@ DEF_TEST(SkVx, r) {
// TODO(mtklein): these tests could be made less loose.
REPORTER_ASSERT(r, all( sqrt(float4{2,3,4,5}) < float4{2,2,3,3}));
REPORTER_ASSERT(r, all( rcp(float4{2,3,4,5}) < float4{1.0f,0.5f,0.5f,0.3f}));
REPORTER_ASSERT(r, all(rsqrt(float4{2,3,4,5}) < float4{1.0f,1.0f,1.0f,0.5f}));
REPORTER_ASSERT(r, all( sqrt(float2{2,3}) < float2{2,2}));
REPORTER_ASSERT(r, all( rcp(float2{2,3}) < float2{1.0f,0.5f}));
REPORTER_ASSERT(r, all(rsqrt(float2{2,3}) < float2{1.0f,1.0f}));
REPORTER_ASSERT(r, all(skvx::cast<int>(float4{-1.5f,0.5f,1.0f,1.5f}) == int4{-1,0,1,1}));