ARM NEON:比较 128 位值 [英] ARM NEON: comparing 128 bit values

查看:32
本文介绍了ARM NEON:比较 128 位值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣找到在 Cortex-A9 内核(允许 VFP 指令)上比较存储到 NEON 寄存器(例如 Q0 和 Q3)中的值的最快方法(最低周期数).

I'm interested in finding the fastest way (lowest cycle count) of comparing the values stored into NEON registers (say Q0 and Q3) on a Cortex-A9 core (VFP instructions allowed).

到目前为止,我有以下几点:

So far I have the following:

(1) 使用 VFP 浮点比较:

(1) Using the VFP floating point comparison:

vcmp.f64        d0, d6
vmrs            APSR_nzcv, fpscr
vcmpeq.f64      d1, d7
vmrseq          APSR_nzcv, fpscr

如果 64 位浮点数"等价于 NaN,则此版本将不起作用.

If the 64bit "floats" are equivalent to NaN, this version will not work.

(2) 使用 NEON 缩小和 VFP 比较(这次只使用一次,并且是 NaN 安全的方式):

(2) Using the NEON narrowing and the VFP comparison (this time only once and in a NaN-safe manner):

vceq.i32        q15, q0, q3
vmovn.i32       d31, q15
vshl.s16        d31, d31, #8
vcmp.f64        d31, d29
vmrs            APSR_nzcv, fpscr

D29 寄存器预先加载了正确的 16 位模式:

The D29 register is previously preloaded with the right 16bit pattern:

vmov.i16        d29, #65280     ; 0xff00

我的问题是:还有比这更好的吗?我是否正在监督一些明显的方法来做到这一点?

My question is: is there any better than this? Am I overseeing some obvious way to do it?

推荐答案

我相信你可以减少一个指令.通过使用左移并插入 (VLSI),您可以将 Q15 的 4 个 32 位值组合成 D31 中的 4 个 16 位值.然后您可以与 0 进行比较并获得浮点标志.

I believe you can reduce it by one instruction. By using the shift left and insert (VLSI), you can combine the 4 32-bit values of Q15 into 4 16-bit values in D31. You can then compare with 0 and get the floating point flags.

vceq.i32  q15, q0, q3
vlsi.32   d31, d30, #16
vcmp.f64  d31, #0
vmrs      APSR_nzcv, fpscr

这篇关于ARM NEON:比较 128 位值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆