SSE4 128bit TEST指令
来源:互联网 发布:js类库如jquery 编辑:程序博客网 时间:2024/06/06 11:49
Test Intrinsics
These Intel® Streaming SIMD Extensions (Intel® SSE4) intrinsics perform packed integer 128-bit comparisons. The prototypes for these instrinsics are in the smmintrin.h file.
Intrinsic Name
Operation
Corresponding
Intel® SSE4 Instruction
_mm_testz_si128
Check for all zeros in specified bits of a 128-bit valuePTEST
_mm_testc_si128
Check for all ones in specified bits of a 128-bit valuePTEST
_mm_testnzc_si128
Check for at least one zero and at least one one in the specified bits of a 128-bit valuePTEST
int _mm_testz_si128 (__m128i s1, __m128i s2)
Returns 1 if the bitwise AND operation on s1 and s2 results in all zeros, else returns 0. That is,
_mm_testz_si128 := ( (s1 & s2) == 0 ? 1 : 0 )
This intrinsic checks if the ZF flag equals 1 as a result of the instruction PTEST s1, s2. For example, it allows you to check if all set bits in s2 (mask) are zeros in s1.
Corresponding instruction: PTEST
int _mm_testc_si128 (__m128i s1, __m128i s2)
Returns 1 if the bitwise AND operation on s2 and logical NOT s1 results in all zeros, else returns 0. That is,
_mm_testc_si128 := ( (~s1 & s2) == 0 ? 1 : 0 )
This intrinsic checks if the CF flag equals 1 as a result of the instruction PTEST s1, s2. For example it allows you to check if all set bits in s2 (mask) are also set in s1.
Corresponding instruction: PTEST
int _mm_testnzc_si128 (__m128i s1, __m128i s2)
Returns 1 if the following conditions are true: bitwise operation of s1 AND s2 does not equal all zeros and bitwise operation of NOT s1 AND s2 does not equal all zeros, otherwise returns 0. That is,
_mm_testnzc_si128 := ( ( (s1 & s2) != 0 && (~s1 & s2) != 0 ) ? 1 : 0 )
This intrinsic checks if both the CF and ZF flags are not 1 as a result of the instruction PTEST s1, s2. For example, it allows you to check that the result has both zeros and ones in s1 on positions specified as set bits in s2 (mask).
Corresponding instruction: PTEST
http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/index.htm#intref_cls/common/intref_sse41_test.htm
Example1:
http://msdn.microsoft.com/en-us/library/bb513983(v=vs.90).aspx
#include <stdio.h>#include <smmintrin.h>int main (){ __m128i a, b; a.m128i_u64[0] = 0xAAAA55551111FFFF; b.m128i_u64[0] = 0xAAAA55551111FFFF; a.m128i_u64[1] = 0xFEDCBA9876543210; b.m128i_u64[1] = 0xFEDCBA9876543210; int res1 = _mm_testc_si128(a, b); a.m128i_u64[0] = 0xAAAA55551011FFFF; int res2 = _mm_testc_si128(a, b); printf_s("First result should be 1: %d\nSecond result should be 0: %d\n", res1, res2); return 0;}
Example2:
static const __m128i zero = {0};inline bool compare128(__m128i a, __m128i b) { __m128i c = _mm_xor_si128(a, b); return _mm_testc_si128(zero, c);}
- SSE4 128bit TEST指令
- Intel汇编指令集SSE4
- SSE4.1指令集系列之一
- 使用SSE4指令集优化双线性插值图像缩放
- MinGW+Eclipse下C/C++使用SSE4指令集
- test指令
- SSE4.1 : IINSERTPS – 把一个32位整型插入到一个128位参数中,并把某些位置零。内部指令:_mm_insert_ps
- nasm : test bit
- SSE4.1指令集系列之一----多字节绝对差值求和指令、水平最小值,整数格式扩展指令
- [VC6] 检查MMX和SSE系列指令集的支持级别(最高SSE4.2)
- Intel大坑之一:丢失的SSE2 128bit/64bit 位移指令,马航MH370??
- 测试指令TEST
- Test&Cmp汇编指令
- Linux-Test(测试指令)
- 汇编 test指令和cmp指令
- 关于指令test ecx,ecx
- test 指令的测试功能
- test指令的测试功能
- LINUX内核段错误调试详细指南精品培训PPT讲义
- 排序算法
- stm32_19264液晶LCD驱动程序
- 对象内存布局 (3)
- 找到一本好书
- SSE4 128bit TEST指令
- IPV4的私有地址
- poj2431 Expedition 优先队列
- 成长,没你想象的那么迫切!
- Broadcast Receiver(三)广播接收器的优先级
- 认识系统服务
- 对象内存布局 (4)
- C++ 单例模式
- 对象内存布局 (5)