Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: src/opts/SkNx_sse.h

Issue 1891993002: Revert of skcpu: sse4.1 floor, f16c f16<->f32 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkXfermodeF16.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkNx_sse.h
diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h
index e824d29debd27b31769492a657d8b718930e4c83..80c7f0e9ae79f1a0e0743d77eb50a0fdbfb9a499 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -8,12 +8,20 @@
#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> {
@@ -89,25 +97,7 @@
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(_MSC_VER)
- r = _mm_floor_ps(fVec);
- #else
- asm("roundps $0x1, %[fVec], %[r]" : [r]"=x"(r) : [fVec]"x"(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); }
« no previous file with comments | « src/core/SkXfermodeF16.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698