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

Unified Diff: src/opts/SkNx_sse.h

Issue 1059743002: Use switch operator[](int) to kth<int>() so we can use vget_lane. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/opts/SkNx_neon.h ('k') | tests/SkNxTest.cpp » ('j') | 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 87754ad155ad10ed83743ab68a3717331740729f..cae2d458f66b968621ee78d7abd2bbc01b23a2fc 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -87,10 +87,10 @@ public:
SkNf invert() const { return SkNf(1) / *this; }
SkNf approxInvert() const { return _mm_rcp_ps(fVec); }
- float operator[] (int k) const {
+ template <int k> float kth() const {
SkASSERT(0 <= k && k < 2);
union { __m128 v; float fs[4]; } pun = {fVec};
- return pun.fs[k];
+ return pun.fs[k&1];
}
private:
@@ -131,10 +131,10 @@ public:
SkNf invert() const { return SkNf(1) / *this; }
SkNf approxInvert() const { return _mm_cvtps_pd(_mm_rcp_ps(_mm_cvtpd_ps(fVec))); }
- double operator[] (int k) const {
+ template <int k> double kth() const {
SkASSERT(0 <= k && k < 2);
union { __m128d v; double ds[2]; } pun = {fVec};
- return pun.ds[k];
+ return pun.ds[k&1];
}
private:
@@ -176,10 +176,10 @@ public:
SkNf invert() const { return SkNf(1) / *this; }
SkNf approxInvert() const { return _mm_rcp_ps(fVec); }
- float operator[] (int k) const {
+ template <int k> float kth() const {
SkASSERT(0 <= k && k < 4);
union { __m128 v; float fs[4]; } pun = {fVec};
- return pun.fs[k];
+ return pun.fs[k&3];
}
private:
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698