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: |