是__m128i变量为零? [英] Is an __m128i variable zero?

查看:98
本文介绍了是__m128i变量为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何测试如果 __ m128i 变量对任何非零值SSE-2和早期的处理器?

How do I test if a __m128i variable has any nonzero value on SSE-2-and-earlier processors?

推荐答案

在SSE2,你可以这样做:

In SSE2 you can do:

__m128i zero = _mm_setzero_si128();
if(_mm_movemask_epi8(_mm_cmpeq_epi32(x,zero)) == 0xFFFF)
{
    //the code...
}

这将考验四个整形的VS为零,则返回一个面具每个字节,如此你的位偏移每个相应的 INT 将在0,4,8安培; 12,但上面的测试将赶上如果任何位被设置,那么如果preserve掩模可以用细粒份工作直接如果需要的话。

this will test four int's vs zero then return a mask for each byte, so your bit-offsets of each corresponding int would be at 0, 4, 8 & 12, but the above test will catch if any bit is set, then if you preserve the mask you can work with the finer grained parts directly if need be.

这篇关于是__m128i变量为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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