英特尔 SSE:为什么 `_mm_extract_ps` 返回 `int` 而不是 `float`? [英] Intel SSE: Why does `_mm_extract_ps` return `int` instead of `float`?

查看:17
本文介绍了英特尔 SSE:为什么 `_mm_extract_ps` 返回 `int` 而不是 `float`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 _mm_extract_ps 返回的是 int 而不是 float?

Why does _mm_extract_ps return an int instead of a float?

从 C 中的 XMM 寄存器读取单个 float 的正确方法是什么?

What's the proper way to read a single float from an XMM register in C?

或者更确切地说,一种不同的提问方式是:_mm_set_ps 指令的反面是什么?

Or rather, a different way to ask it is: What's the opposite of the _mm_set_ps instruction?

推荐答案

来自 MSDN 文档,我相信您可以将结果转换为浮点数.

From the MSDN docs, I believe you can cast the result to a float.

注意他们的例子,0xc0a40000 值等价于 -5.125 (a.m128_f32[1]).

Note from their example, the 0xc0a40000 value is equivalent to -5.125 (a.m128_f32[1]).

更新:我强烈推荐@doug65536 和@PeterCordes(下面)的答案来代替我的答案,这显然会在许多编译器上生成性能不佳的代码.

Update: I strongly recommend the answers from @doug65536 and @PeterCordes (below) in lieu of mine, which apparently generates poorly performing code on many compilers.

这篇关于英特尔 SSE:为什么 `_mm_extract_ps` 返回 `int` 而不是 `float`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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