aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-04-11 13:18:09 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-12 14:29:00 +0000
commite3fda9310a8996edbbb1d14acc8f5da07f2d2740 (patch)
tree828825030b2d3d5cbe9c4e40792a2c2f6b9a0df9 /src/opts
parent74e5937c188fccf57ba88208783ba39fb1aa6881 (diff)
Implement Sk4f min/max
Bug: skia: Change-Id: Icf235dea81e9f125c1c8590ec87cb3591393036c Reviewed-on: https://skia-review.googlesource.com/120281 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/opts')
-rw-r--r--src/opts/SkNx_neon.h18
-rw-r--r--src/opts/SkNx_sse.h12
2 files changed, 30 insertions, 0 deletions
diff --git a/src/opts/SkNx_neon.h b/src/opts/SkNx_neon.h
index 232903ab67..9020036076 100644
--- a/src/opts/SkNx_neon.h
+++ b/src/opts/SkNx_neon.h
@@ -244,6 +244,24 @@ public:
return pun.fs[k&3];
}
+ AI float min() const {
+ #if defined(__aarch64__)
+ return vminvq_f32(fVec);
+ #else
+ SkNx min = Min(*this, vrev64q_f32(fVec));
+ return std::min(min[0], min[2]);
+ #endif
+ }
+
+ AI float max() const {
+ #if defined(__aarch64__)
+ return vmaxvq_f32(fVec);
+ #else
+ SkNx max = Max(*this, vrev64q_f32(fVec));
+ return std::max(max[0], max[2]);
+ #endif
+ }
+
AI bool allTrue() const {
#if defined(__aarch64__)
return 0 != vminvq_u32(vreinterpretq_u32_f32(fVec));
diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h
index bd5c58e261..00edc3a51f 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -176,6 +176,18 @@ public:
return pun.fs[k&3];
}
+ AI float min() const {
+ SkNx min = Min(*this, _mm_shuffle_ps(fVec, fVec, _MM_SHUFFLE(2,3,0,1)));
+ min = Min(min, _mm_shuffle_ps(min.fVec, min.fVec, _MM_SHUFFLE(0,1,2,3)));
+ return min[0];
+ }
+
+ AI float max() const {
+ SkNx max = Max(*this, _mm_shuffle_ps(fVec, fVec, _MM_SHUFFLE(2,3,0,1)));
+ max = Max(max, _mm_shuffle_ps(max.fVec, max.fVec, _MM_SHUFFLE(0,1,2,3)));
+ return max[0];
+ }
+
AI bool allTrue() const { return 0xffff == _mm_movemask_epi8(_mm_castps_si128(fVec)); }
AI bool anyTrue() const { return 0x0000 != _mm_movemask_epi8(_mm_castps_si128(fVec)); }