assembly - uint32x2x2_t 和 int32x4_t 之间的 arm-neon 转换
问题描述
我正在尝试为使用sse2neon_mm_mul_epu32
的某些代码实现一个等效的霓虹灯下降,因为它是代码使用的唯一调用,而sse2neon没有等效的代码。_mm_mul_epu32
FORCE_INLINE __m128i _mm_mul_epu32(__m128i a, __m128i b)
{
// shuffle: 0, 1, 2, 3 -> 0, 2, 1, 3 */
__m128i const a_shuf = (int32x4_t)(vzip_u32(vget_low_u32(vreinterpretq_u32_m128i(a)), vget_high_u32(vreinterpretq_u32_m128i(a))));
__m128i const b_shuf = (int32x4_t)(vzip_u32(vget_low_u32(vreinterpretq_u32_m128i(b)), vget_high_u32(vreinterpretq_u32_m128i(b))));
// Multiply low word (32 bit) against low word (24 bit) and high word (32 bit) against high word (32 bit).
// Pack both results (64 bit) into 128 bit register and return result.
return vreinterpretq_m128i_u64(vmull_u32(vget_low_u32(vreinterpretq_u32_m128i(a_shuf)), vget_low_u32(vreinterpretq_u32_m128i(b_shuf))));
}
我有一些似乎基本上是等价的 - 但是我不确定将vzip_u32
(which is uint32x2x2_t
) 的结果转换为其他函数期望的正确方法是什么int32x4_t
。
对于大多数其他霓虹灯转换,有转换功能,例如vreinterpretq_u32_s32
,但我找不到这个。
我可以强制强制转换编译,如果我这样做结果是正确的(通过我的测试向量),但是我不喜欢这样,并且想知道是否有更正确的方法来处理事情。
在这些类型之间转换的正确方法是什么,有吗?或者有没有更好的方法来进行洗牌,这样我就可以完全避免转换?
带有一些强制转换的 Godbolt 示例: https ://godbolt.org/z/gRDpRs https://godbolt.org/z/H-3fOt
解决方案
推荐阅读
- typescript - 并非所有属性都匹配时不显示打字稿类型检查错误
- spring-boot - 不带过滤器的 Spring Boot API 和带过滤器的 Spring Boot API 有什么区别?
- c - 如何确保在 RTOS 中 Task1 完成然后 Task2 启动(我们不知道调度算法)?
- sql - 如何在不更改数据的情况下将行转换为列?
- api - 使用属性路由调用 Web API 时找不到 404
- docker - JFrog Container Registry 和 JFrog Artifactory 有什么区别?
- javascript - 获取带有文本的关联标签
- mysql - 尝试转换 Microsoft SQL 函数后出现 MySQL 错误
- python - 如果单词在字典中,我如何计算每行中的单词出现次数
- angular - 针对不同环境的 Angular `ng build` 命令的快捷方式或语法