手臂霓虹灯比较操作产生负一 [英] arm neon compare operations generate negative one

查看:263
本文介绍了手臂霓虹灯比较操作产生负一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想下面的汇编code:

I am trying the following assembly code:

vclt.f32 q9,q0,#0
vst1.i32 q9,[r2:128]

但是,如果条件为真,在Q9相应的元素设置为负一,而不是积极的。

But if the condition is true, the corresponding element in q9 is set to negative one instead of positive one.

我能做些什么,得到了肯定的?

What can I do to get a positive one ?

推荐答案

有不在NEON很多有条件的东西,但什么也真的只有按位可行的,而不是布尔逻辑 - 例如见 VBSL

There's not a lot of conditional stuff in NEON, but what there is is really only workable with bitwise, rather than Boolean, logic - see e.g. vbsl.

如果你有基本的可怕回忆,真的很讨厌按位真值,那么琐碎的方式向蒙版转换为布尔是只取每个元素的最高位:

If you have horrible memories of BASIC and really hate bitwise truth values, then the trivial way to convert the mask to a Boolean is to just take the top bit of each element:

vshr.u32 q9, q9, #31

虽然否定,而可以说不太清楚,一目了然阅读,可能是微观更好的性能,明智的在某些情况下:

Although negation, whilst arguably less clear to read at a glance, could be microscopically better performance-wise in some cases:

vneg.s32 q9, q9

(从通过微架构的时间的浏览,这两个操作都pretty很多是相同的,但 VNEG 的一些理论优于 vshr 是,它消耗其输入以后的Cortex-A8,并且能够发出下来两个ASIMD管道的Cortex-A57 / A72)

(from a browse through microarchitectural timings, both operations are pretty much identical, but some theoretical advantages of vneg over vshr are that it consumes its inputs later on Cortex-A8, and can issue down both ASIMD pipes of Cortex-A57/A72)

无论哪种方式,如在顶部说,这只有真正有意义存储结果存储在存储器非矢量化code来看待。

Either way, as said at the top, this only really makes sense for storing the result back to memory to be looked at by non-vectorised code.

这篇关于手臂霓虹灯比较操作产生负一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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