尝试在 SSE 编程中使用和掩码添加 __m128 [英] Trying to add an __m128 using an and mask in SSE programming
本文介绍了尝试在 SSE 编程中使用和掩码添加 __m128的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用比较操作的结果添加到 SSE 变量.我刚刚意识到,当使用 _mm_cmplt_ps
操作时,如果结果为真,它会返回一个 NAN,因为无法表示 0xffffffff,这对我没有用:
I am trying to use the result of a compare operation to add to an SSE variable. I have just realised that when using the _mm_cmplt_ps
operation if the result is true it returns a NAN because 0xffffffff can't be represented which is of no use to me:
__m128 va;
__m128 vb;
__m128 result =_mm_set1_ps(0.0f);
vb = _mm_cmplt_ps(va,vb);
result = _mm_add_ps(result,vb); // problem is that I would like to convert vb to 1.0's and 0.0's
推荐答案
您可以将比较掩码应用于 1.0 值的向量,例如
You can just apply the comparison mask to a vector of 1.0 values, e.g.
__m128 va, vb;
__m128 vcmp = _mm_cmplt_ps(va, vb);
__m128 vresult = _mm_and_ps(_mm_set1_ps(1.0f), vcmp);
这篇关于尝试在 SSE 编程中使用和掩码添加 __m128的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文