diff options
author | Mike Klein <mtklein@chromium.org> | 2018-03-26 13:04:14 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-26 18:48:23 +0000 |
commit | 68ff92f78addb3c862cc28bcee2b97ff4679c290 (patch) | |
tree | f214fbde644e1e7a778a207f6bc070c44ac24e0f /src | |
parent | 376a96aa07b5d88fdb77693642586192cd17101b (diff) |
specialize arm64 allTrue()/anyTrue()
aarch64 added vector-wise add/mul/min/max instructions.
We can use min and max to implement allTrue() and anyTrue(),
respectively.
(This CL is mostly so I don't forget these intrinsics exist.)
In assembly, these actually compile to two instructions,
the folding operation into a vector register, then a move
from the vector register to a general purpose register.
Change-Id: Ia6a999ac250740de765e871094e911979a8711c7
Reviewed-on: https://skia-review.googlesource.com/116482
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/opts/SkNx_neon.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/opts/SkNx_neon.h b/src/opts/SkNx_neon.h index f8170ef962..52247c8f66 100644 --- a/src/opts/SkNx_neon.h +++ b/src/opts/SkNx_neon.h @@ -112,12 +112,20 @@ public: } AI bool allTrue() const { + #if defined(__aarch64__) + return 0 != vminv_u32(vreinterpret_u32_f32(fVec)); + #else auto v = vreinterpret_u32_f32(fVec); return vget_lane_u32(v,0) && vget_lane_u32(v,1); + #endif } AI bool anyTrue() const { + #if defined(__aarch64__) + return 0 != vmaxv_u32(vreinterpret_u32_f32(fVec)); + #else auto v = vreinterpret_u32_f32(fVec); return vget_lane_u32(v,0) || vget_lane_u32(v,1); + #endif } AI SkNx thenElse(const SkNx& t, const SkNx& e) const { @@ -229,14 +237,22 @@ public: } AI bool allTrue() const { + #if defined(__aarch64__) + return 0 != vminvq_u32(vreinterpretq_u32_f32(fVec)); + #else auto v = vreinterpretq_u32_f32(fVec); return vgetq_lane_u32(v,0) && vgetq_lane_u32(v,1) && vgetq_lane_u32(v,2) && vgetq_lane_u32(v,3); + #endif } AI bool anyTrue() const { + #if defined(__aarch64__) + return 0 != vmaxvq_u32(vreinterpretq_u32_f32(fVec)); + #else auto v = vreinterpretq_u32_f32(fVec); return vgetq_lane_u32(v,0) || vgetq_lane_u32(v,1) || vgetq_lane_u32(v,2) || vgetq_lane_u32(v,3); + #endif } AI SkNx thenElse(const SkNx& t, const SkNx& e) const { |