aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2016-04-15 08:37:22 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-15 08:37:22 -0700
commit2c7f24093a394ccbe54a7db60ba79af14682e7fa (patch)
treef598cd74ae4f051d383ea573cbd5d97267c50908 /src/opts
parent82497f9300432375cb9fd0e0ceca011ea7dce847 (diff)
Revert of skcpu: sse4.1 floor, f16c f16<->f32 (patchset #11 id:200001 of https://codereview.chromium.org/1891513002/ )
Reason for revert: this depends on a CL I want to revert Original issue's description: > skcpu: sse4.1 floor, f16c f16<->f32 > > - floor with roundps is about 4.5x faster when available > - f16 srcover_n is similar to but a little faster than the version in https://codereview.chromium.org/1884683002. This new one fuses the dst load/stores into the f16<->f32 conversions: > > +0x180 movups (%r15), %xmm1 > +0x184 vcvtph2ps (%rbx), %xmm2 > +0x189 movaps %xmm1, %xmm3 > +0x18c shufps $255, %xmm3, %xmm3 > +0x190 movaps %xmm0, %xmm4 > +0x193 subps %xmm3, %xmm4 > +0x196 mulps %xmm2, %xmm4 > +0x199 addps %xmm1, %xmm4 > +0x19c vcvtps2ph $0, %xmm4, (%rbx) > +0x1a2 addq $16, %r15 > +0x1a6 addq $8, %rbx > +0x1aa decl %r14d > +0x1ad jne +0x180 > > If we decide to land this it'd be a good idea to convert most or all users of SkFloatToHalf_01 and SkHalfToFloat_01 over to the pointer-based versions. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1891513002 > CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot > > Committed: https://skia.googlesource.com/skia/+/cbe3c1af987d622ea67ef560d855b41bb14a0ce9 > > Committed: https://skia.googlesource.com/skia/+/3faf74b8364491ca806f523fbb1d8a97be592663 TBR=fmalita@chromium.org,herb@google.com,reed@google.com,mtklein@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1897433002
Diffstat (limited to 'src/opts')
-rw-r--r--src/opts/SkNx_sse.h32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h
index 1fc235d99b..80c7f0e9ae 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -8,13 +8,21 @@
#ifndef SkNx_sse_DEFINED
#define SkNx_sse_DEFINED
-#include "SkCpu.h"
-
// This file may assume <= SSE2, but must check SK_CPU_SSE_LEVEL for anything more recent.
// If you do, make sure this is in a static inline function... anywhere else risks violating ODR.
#define SKNX_IS_FAST
+// SSE 4.1 has _mm_floor_ps to floor 4 floats. We emulate it:
+// - roundtrip through integers via truncation
+// - subtract 1 if that's too big (possible for negative values).
+// This restricts the domain of our inputs to a maximum somehwere around 2^31. Seems plenty big.
+static inline __m128 sse2_mm_floor_ps(__m128 v) {
+ __m128 roundtrip = _mm_cvtepi32_ps(_mm_cvttps_epi32(v));
+ __m128 too_big = _mm_cmpgt_ps(roundtrip, v);
+ return _mm_sub_ps(roundtrip, _mm_and_ps(too_big, _mm_set1_ps(1.0f)));
+}
+
template <>
class SkNx<2, float> {
public:
@@ -89,25 +97,7 @@ public:
static SkNx Max(const SkNx& l, const SkNx& r) { return _mm_max_ps(l.fVec, r.fVec); }
SkNx abs() const { return _mm_andnot_ps(_mm_set1_ps(-0.0f), fVec); }
- SkNx floor() const {
- if (SkCpu::Supports(SkCpu::SSE41)) {
- __m128 r;
- #if defined(__GNUC__) || defined(__clang__)
- asm("roundps $0x1, %[fVec], %[r]" : [r]"=x"(r) : [fVec]"x"(fVec));
- #else
- r = _mm_floor_ps(fVec);
- #endif
- return r;
- }
- // Emulate _mm_floor_ps() with SSE2:
- // - roundtrip through integers via truncation
- // - subtract 1 if that's too big (possible for negative values).
- // This restricts the domain of our inputs to a maximum somehwere around 2^31.
- // Seems plenty big.
- __m128 roundtrip = _mm_cvtepi32_ps(_mm_cvttps_epi32(fVec));
- __m128 too_big = _mm_cmpgt_ps(roundtrip, fVec);
- return _mm_sub_ps(roundtrip, _mm_and_ps(too_big, _mm_set1_ps(1.0f)));
- }
+ SkNx floor() const { return sse2_mm_floor_ps(fVec); }
SkNx sqrt() const { return _mm_sqrt_ps (fVec); }
SkNx rsqrt() const { return _mm_rsqrt_ps(fVec); }