SSE Intrinsics各函数介绍

原文:http://blog.csdn.net/fengbingchun/article/details/19293081

SIMD相关头文件包括:

  1. //#include <ivec.h>//MMX  
  2. //#include <fvec.h>//SSE(also include ivec.h)  
  3. //#include <dvec.h>//SSE2(also include fvec.h)  
  4.   
  5.   
  6. #include <mmintrin.h> //MMX  
  7. #include <xmmintrin.h> //SSE(include mmintrin.h)  
  8. #include <emmintrin.h> //SSE2(include xmmintrin.h)  
  9. #include <pmmintrin.h> //SSE3(include emmintrin.h)  
  10. #include <tmmintrin.h>//SSSE3(include pmmintrin.h)  
  11. #include <smmintrin.h>//SSE4.1(include tmmintrin.h)  
  12. #include <nmmintrin.h>//SSE4.2(include smmintrin.h)  
  13. #include <wmmintrin.h>//AES(include nmmintrin.h)  
  14. #include <immintrin.h>//AVX(include wmmintrin.h)  
  15. #include <intrin.h>//(include immintrin.h)  


mmintrin.h为MMX头文件,其中__m64的定义为:
  1. typedef union __declspec(intrin_type) _CRT_ALIGN(8) __m64  
  2. {  
  3.     unsigned __int64    m64_u64;  
  4.     float               m64_f32[2];  
  5.     __int8              m64_i8[8];  
  6.     __int16             m64_i16[4];  
  7.     __int32             m64_i32[2];      
  8.     __int64             m64_i64;  
  9.     unsigned __int8     m64_u8[8];  
  10.     unsigned __int16    m64_u16[4];  
  11.     unsigned __int32    m64_u32[2];  
  12. } __m64;  


xmmintrin.h为SSE头文件,此头文件里包含MMX头文件,其中__m128的定义为:
  1. typedef union __declspec(intrin_type) _CRT_ALIGN(16) __m128 {  
  2.      float               m128_f32[4];  
  3.      unsigned __int64    m128_u64[2];  
  4.      __int8              m128_i8[16];  
  5.      __int16             m128_i16[8];  
  6.      __int32             m128_i32[4];  
  7.      __int64             m128_i64[2];  
  8.      unsigned __int8     m128_u8[16];  
  9.      unsigned __int16    m128_u16[8];  
  10.      unsigned __int32    m128_u32[4];  
  11.  } __m128;  

xmmintrin.h文件中各函数的介绍:


  1. /*----------Floating Point Intrinsics Using Streaming SIMD Extensions------------*/  
  2. //Arithmetic Operations(Floating Point ):add、sub、mul、div、sqrt、rcp、min、max  
  3. //---------------------说明:_ps结尾的指令表示对4个单精度浮点数同时进行运算,  
  4. //_ss结尾的指令表示仅对4个单精度浮点数最低位的浮点数进行运算---------------------  
  5. //返回一个__m128的寄存器,仅将寄存器_A和寄存器_B最低对应位置的32bit单精度浮点数相加,  
  6. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  7. //则返回寄存器为r=(_A0+_B0, _A1, _A2, _A3)  
  8. extern __m128 _mm_add_ss(__m128 _A, __m128 _B);  
  9. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数相加,  
  10. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  11. //则返回寄存器r0=_A0+_B0, r1=_A1+_B1, r2=_A2+_B2, r3=_A3+_B3  
  12. extern __m128 _mm_add_ps(__m128 _A, __m128 _B);  
  13. //返回一个__m128的寄存器,仅将寄存器_A和寄存器_B最低对应位置的32bit单精度浮点数相减,  
  14. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  15. //则返回寄存器为r=(_A0-_B0, _A1, _A2, _A3)  
  16. extern __m128 _mm_sub_ss(__m128 _A, __m128 _B);  
  17. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数相减,  
  18. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  19. //则返回寄存器r0=_A0-_B0, r1=_A1-_B1, r2=_A2-_B2, r3=_A3-_B3  
  20. extern __m128 _mm_sub_ps(__m128 _A, __m128 _B);  
  21. //返回一个__m128的寄存器,仅将寄存器_A和寄存器_B最低对应位置的32bit单精度浮点数相乘,  
  22. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  23. //则返回寄存器为r=(_A0*_B0, _A1, _A2, _A3)  
  24. extern __m128 _mm_mul_ss(__m128 _A, __m128 _B);  
  25. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数相乘,  
  26. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  27. //则返回寄存器r0=_A0*_B0, r1=_A1*_B1, r2=_A2*_B2, r3=_A3*_B3  
  28. extern __m128 _mm_mul_ps(__m128 _A, __m128 _B);  
  29. //返回一个__m128的寄存器,仅将寄存器_A和寄存器_B最低对应位置的32bit单精度浮点数相除,  
  30. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  31. //则返回寄存器为r=(_A0/_B0, _A1, _A2, _A3)  
  32. extern __m128 _mm_div_ss(__m128 _A, __m128 _B);  
  33. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数相除,  
  34. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  35. //则返回寄存器r0=_A0/_B0, r1=_A1/_B1, r2=_A2/_B2, r3=_A3/_B3  
  36. extern __m128 _mm_div_ps(__m128 _A, __m128 _B);  
  37. //返回一个__m128的寄存器,仅将寄存器_A最低对应位置的32bit单精度浮点数开平方,  
  38. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3)  
  39. //则返回寄存器为r=(sqrt(_A0), _A1, _A2, _A3)  
  40. extern __m128 _mm_sqrt_ss(__m128 _A);  
  41. //返回一个__m128的寄存器,将寄存器_A中4个32bit单精度浮点数开平方,  
  42. //例如_A=(_A0,_A1,_A2,_A3),则返回寄存器为  
  43. //r=(sqrt(_A0), sqrt(_A1), sqrt(_A2), sqrt(_A3))  
  44. extern __m128 _mm_sqrt_ps(__m128 _A);  
  45. //返回一个__m128的寄存器,仅将寄存器_A最低对应位置的32bit单精度浮点数取倒数,  
  46. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3)  
  47. //则返回寄存器为r=(recip(_A0), _A1, _A2, _A3)  
  48. extern __m128 _mm_rcp_ss(__m128 _A);  
  49. //返回一个__m128的寄存器,将寄存器_A中4个32bit单精度浮点数取倒数,  
  50. //例如_A=(_A0,_A1,_A2,_A3),则返回寄存器为  
  51. //r=(recip(_A0), recip(_A1), recip(_A2), recip(_A3))  
  52. extern __m128 _mm_rcp_ps(__m128 _A);  
  53. //返回一个__m128的寄存器,仅将寄存器_A最低对应位置的32bit单精度浮点数取平方根的倒数,  
  54. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3)  
  55. //则返回寄存器为r=(recip(sqrt(_A0)), _A1, _A2, _A3)  
  56. extern __m128 _mm_rsqrt_ss(__m128 _A);  
  57. //返回一个__m128的寄存器,将寄存器_A中4个32bit单精度浮点数取平方根的倒数,  
  58. //例如_A=(_A0,_A1,_A2,_A3),则返回寄存器为  
  59. //r=(recip(sqrt(_A0)), recip(sqrt(_A1)), recip(sqrt(_A2)), recip(sqrt(_A3)))  
  60. extern __m128 _mm_rsqrt_ps(__m128 _A);  
  61. //返回一个__m128的寄存器,仅将寄存器_A和寄存器_B最低对应位置的32bit单精度浮点数取最小值,  
  62. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  63. //则返回寄存器为r=(min(_A0,_B0), _A1, _A2, _A3)  
  64. extern __m128 _mm_min_ss(__m128 _A, __m128 _B);  
  65. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数取最小值,  
  66. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  67. //则返回寄存器r0=min(_A0,_B0), r1=min(_A1,_B1), r2=min(_A2,_B2), r3=min(_A3,_B3)  
  68. extern __m128 _mm_min_ps(__m128 _A, __m128 _B);  
  69. //返回一个__m128的寄存器,仅将寄存器_A和寄存器_B最低对应位置的32bit单精度浮点数取最大值,  
  70. //其余位置取寄存器_A中的数据,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  71. //则返回寄存器为r=(max(_A0,_B0), _A1, _A2, _A3)  
  72. extern __m128 _mm_max_ss(__m128 _A, __m128 _B);  
  73. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数取最大值,  
  74. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  75. //则返回寄存器r0=max(_A0,_B0), r1=max(_A1,_B1), r2=max(_A2,_B2), r3=max(_A3,_B3)  
  76. extern __m128 _mm_max_ps(__m128 _A, __m128 _B);  
  77.   
  78. //Logical Operations(SSE):and、andnot、or、xor  
  79. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数分别进行按位与运算,  
  80. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  81. //则返回寄存器r0=_A0 & _B0, r1=_A1 & _B1, r2=_A2 & _B2, r3=_A3 & _B3  
  82. extern __m128 _mm_and_ps(__m128 _A, __m128 _B);  
  83. //返回一个__m128的寄存器,将寄存器_A对应位置的32bit单精度浮点数的非和寄存器_B对应位置的32bit  
  84. //单精度浮点数分别进行按位与运算,例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  85. //则返回寄存器r0=~_A0 & _B0, r1=~_A1 & _B1, r2=~_A2 & _B2, r3=~_A3 & _B3  
  86. extern __m128 _mm_andnot_ps(__m128 _A, __m128 _B);  
  87. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数分别进行按位或运算,  
  88. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  89. //则返回寄存器r0=_A0 | _B0, r1=_A1 | _B1, r2=_A2 | _B2, r3=_A3 | _B3  
  90. extern __m128 _mm_or_ps(__m128 _A, __m128 _B);  
  91. //返回一个__m128的寄存器,将寄存器_A和_B的对应位置的32bit单精度浮点数分别进行按位异或运算,  
  92. //例如_A=(_A0,_A1,_A2,_A3), _B=(_B0,_B1,_B2,_B3),  
  93. //则返回寄存器r0=_A0 ^ _B0, r1=_A1 ^ _B1, r2=_A2 ^ _B2, r3=_A3 ^ _B3  
  94. extern __m128 _mm_xor_ps(__m128 _A, __m128 _B);  
  95.   
  96. //Comparison Intrinsics(SSE):==、<、<=、>、>=、!=、不小于、不小于等于、不大于、不大于等于  
  97. //返回一个__m128的寄存器,Compares for equality,  
  98. //r0=(_A0 == _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  99. extern __m128 _mm_cmpeq_ss(__m128 _A, __m128 _B);  
  100. //返回一个__m128的寄存器,Compares for equality,  
  101. //r0=(_A0 == _B0) ? 0xffffffff : 0x0, r1=(_A1 == _B1) ? 0xffffffff : 0x0,   
  102. //r2=(_A2 == _B2) ? 0xffffffff : 0x0, r3=(_A3 == _B3) ? 0xffffffff : 0x0  
  103. extern __m128 _mm_cmpeq_ps(__m128 _A, __m128 _B);  
  104. //返回一个__m128的寄存器,Compares for less than,  
  105. //r0=(_A0 < _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  106. extern __m128 _mm_cmplt_ss(__m128 _A, __m128 _B);  
  107. //返回一个__m128的寄存器,Compares for less than,  
  108. //r0=(_A0 < _B0) ? 0xffffffff : 0x0, r1=(_A1 < _B1) ? 0xffffffff : 0x0,   
  109. //r2=(_A2 < _B2) ? 0xffffffff : 0x0, r3=(_A3 < _B3) ? 0xffffffff : 0x0  
  110. extern __m128 _mm_cmplt_ps(__m128 _A, __m128 _B);  
  111. //返回一个__m128的寄存器,Compares for less than or equal,  
  112. //r0=(_A0 <= _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  113. extern __m128 _mm_cmple_ss(__m128 _A, __m128 _B);  
  114. //返回一个__m128的寄存器,Compares for less than or equal,  
  115. //r0=(_A0 <= _B0) ? 0xffffffff : 0x0, r1=(_A1 <= _B1) ? 0xffffffff : 0x0,   
  116. //r2=(_A2 <= _B2) ? 0xffffffff : 0x0, r3=(_A3 <= _B3) ? 0xffffffff : 0x0  
  117. extern __m128 _mm_cmple_ps(__m128 _A, __m128 _B);  
  118. //返回一个__m128的寄存器,Compares for greater than,  
  119. //r0=(_A0 > _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  120. extern __m128 _mm_cmpgt_ss(__m128 _A, __m128 _B);  
  121. //返回一个__m128的寄存器,Compares for greater than,  
  122. //r0=(_A0 > _B0) ? 0xffffffff : 0x0, r1=(_A1 > _B1) ? 0xffffffff : 0x0,   
  123. //r2=(_A2 > _B2) ? 0xffffffff : 0x0, r3=(_A3 > _B3) ? 0xffffffff : 0x0  
  124. extern __m128 _mm_cmpgt_ps(__m128 _A, __m128 _B);  
  125. //返回一个__m128的寄存器,Compares for greater than or equal,  
  126. //r0=(_A0 >= _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  127. extern __m128 _mm_cmpge_ss(__m128 _A, __m128 _B);  
  128. //返回一个__m128的寄存器,Compares for greater than or equal,  
  129. //r0=(_A0 >= _B0) ? 0xffffffff : 0x0, r1=(_A1 >= _B1) ? 0xffffffff : 0x0,   
  130. //r2=(_A2 >= _B2) ? 0xffffffff : 0x0, r3=(_A3 >= _B3) ? 0xffffffff : 0x0  
  131. extern __m128 _mm_cmpge_ps(__m128 _A, __m128 _B);  
  132. //返回一个__m128的寄存器,Compares for inequality,  
  133. //r0=(_A0 != _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  134. extern __m128 _mm_cmpneq_ss(__m128 _A, __m128 _B);  
  135. //返回一个__m128的寄存器,Compares for inequality,  
  136. //r0=(_A0 != _B0) ? 0xffffffff : 0x0, r1=(_A1 != _B1) ? 0xffffffff : 0x0,   
  137. //r2=(_A2 != _B2) ? 0xffffffff : 0x0, r3=(_A3 != _B3) ? 0xffffffff : 0x0  
  138. extern __m128 _mm_cmpneq_ps(__m128 _A, __m128 _B);  
  139. //返回一个__m128的寄存器,Compares for not less than,  
  140. //r0= !(_A0 < _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  141. extern __m128 _mm_cmpnlt_ss(__m128 _A, __m128 _B);  
  142. //返回一个__m128的寄存器,Compares for not less than,  
  143. //r0=!(_A0 < _B0) ? 0xffffffff : 0x0, r1=!(_A1 < _B1) ? 0xffffffff : 0x0,   
  144. //r2=!(_A2 < _B2) ? 0xffffffff : 0x0, r3=!(_A3 < _B3) ? 0xffffffff : 0x0  
  145. extern __m128 _mm_cmpnlt_ps(__m128 _A, __m128 _B);  
  146. //返回一个__m128的寄存器,Compares for not less than or equal  
  147. //r0= !(_A0 <= _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  148. extern __m128 _mm_cmpnle_ss(__m128 _A, __m128 _B);  
  149. //返回一个__m128的寄存器,Compares for not less than or equal  
  150. //r0=!(_A0 <= _B0) ? 0xffffffff : 0x0, r1=!(_A1 <= _B1) ? 0xffffffff : 0x0,   
  151. //r2=!(_A2 <= _B2) ? 0xffffffff : 0x0, r3=!(_A3 <= _B3) ? 0xffffffff : 0x0  
  152. extern __m128 _mm_cmpnle_ps(__m128 _A, __m128 _B);  
  153. //返回一个__m128的寄存器,Compares for not greater than,  
  154. //r0=!(_A0 > _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  155. extern __m128 _mm_cmpngt_ss(__m128 _A, __m128 _B);  
  156. //返回一个__m128的寄存器,Compares for not greater than,  
  157. //r0=!(_A0 > _B0) ? 0xffffffff : 0x0, r1=!(_A1 > _B1) ? 0xffffffff : 0x0,   
  158. //r2=!(_A2 > _B2) ? 0xffffffff : 0x0, r3=!(_A3 > _B3) ? 0xffffffff : 0x0  
  159. extern __m128 _mm_cmpngt_ps(__m128 _A, __m128 _B);  
  160. //返回一个__m128的寄存器,Compares for not greater than or equal,  
  161. //r0=!(_A0 >= _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  162. extern __m128 _mm_cmpnge_ss(__m128 _A, __m128 _B);  
  163. //返回一个__m128的寄存器,Compares for not greater than or equal,  
  164. //r0=!(_A0 >= _B0) ? 0xffffffff : 0x0, r1=!(_A1 >= _B1) ? 0xffffffff : 0x0,   
  165. //r2=!(_A2 >= _B2) ? 0xffffffff : 0x0, r3=!(_A3 >= _B3) ? 0xffffffff : 0x0  
  166. extern __m128 _mm_cmpnge_ps(__m128 _A, __m128 _B);  
  167. //返回一个__m128的寄存器,Compares for ordered,  
  168. //r0=(_A0 ord? _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3  
  169. extern __m128 _mm_cmpord_ss(__m128 _A, __m128 _B);  
  170. //返回一个__m128的寄存器,Compares for ordered,  
  171. //r0=(_A0 ord? _B0) ? 0xffffffff : 0x0, r1=(_A1 ord? _B1) ? 0xffffffff : 0x0,   
  172. //r2=(_A2 ord? _B2) ? 0xffffffff : 0x0, r3=(_A3 ord? _B3) ? 0xffffffff : 0x0  
  173. extern __m128 _mm_cmpord_ps(__m128 _A, __m128 _B);  
  174. //返回一个__m128的寄存器,Compares for unordered,  
  175. //r0=(_A0 unord? _B0) ? 0xffffffff : 0x0, r1=_A1, r2=_A2, r3=_A3      
  176. extern __m128 _mm_cmpunord_ss(__m128 _A, __m128 _B);  
  177. //返回一个__m128的寄存器,Compares for unordered,  
  178. //r0=(_A0 unord? _B0) ? 0xffffffff : 0x0, r1=(_A1 unord? _B1) ? 0xffffffff : 0x0,   
  179. //r2=(_A2 unord? _B2) ? 0xffffffff : 0x0, r3=(_A3 unord? _B3) ? 0xffffffff : 0x0  
  180. extern __m128 _mm_cmpunord_ps(__m128 _A, __m128 _B);  
  181. //返回一个0或1的整数,Compares the lower single-precision, floating-point value of  
  182. //a and b for a equal to b,If a and b are equal, 1 is returned. Otherwise,  
  183. //0 is returned. If a or b is a NaN, 1 is returned  
  184. //r=(_A0 == _B0) ? 0x1 : 0x0  
  185. extern int _mm_comieq_ss(__m128 _A, __m128 _B);  
  186. //返回一个0或1的整数,If a is less than b, 1 is returned. Otherwise,   
  187. //0 is returned. If a or b is a NaN, 1 is returned,  
  188. //r=(_A0 < _B0) ? 0x1 : 0x0  
  189. extern int _mm_comilt_ss(__m128 _A, __m128 _B);  
  190. //返回一个0或1的整数,If a is less than or equal to b, 1 is returned.   
  191. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  192. //r=(_A0 <= _B0) ? 0x1 : 0x0  
  193. extern int _mm_comile_ss(__m128 _A, __m128 _B);  
  194. //返回一个0或1的整数,If a is greater than b, 1 is returned.  
  195. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  196. //r=(_A0 > _B0) ? 0x1 : 0x0  
  197. extern int _mm_comigt_ss(__m128 _A, __m128 _B);  
  198. //返回一个0或1的整数,If a is greater than or equal to b, 1 is returned.   
  199. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  200. //r=(_A0 >= _B0) ? 0x1 : 0x0  
  201. extern int _mm_comige_ss(__m128 _A, __m128 _B);  
  202. //返回一个0或1的整数,If a and b are not equal, 1 is returned.   
  203. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  204. //r=(_A0 != _B0) ? 0x1 : 0x0  
  205. extern int _mm_comineq_ss(__m128 _A, __m128 _B);  
  206. //返回一个0或1的整数,If a and b are equal, 1 is returned.   
  207. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  208. //r=(_A0 == _B0) ? 0x1 : 0x0      
  209. extern int _mm_ucomieq_ss(__m128 _A, __m128 _B);  
  210. //返回一个0或1的整数,If a is less than b , 1 is returned.   
  211. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  212. //r=(_A0 < _B0) ? 0x1 : 0x0  
  213. extern int _mm_ucomilt_ss(__m128 _A, __m128 _B);  
  214. //返回一个0或1的整数,If a is less than or equal to b, 1 is returned.   
  215. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  216. //r=(_A0 <= _B0) ? 0x1 : 0x0  
  217. extern int _mm_ucomile_ss(__m128 _A, __m128 _B);  
  218. //返回一个0或1的整数,If a is greater than b, 1 is returned.   
  219. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  220. //r=(_A0 > _B0) ? 0x1 : 0x0  
  221. extern int _mm_ucomigt_ss(__m128 _A, __m128 _B);  
  222. //返回一个0或1的整数,If a is greater than or equal to b, 1 is returned.  
  223. //Otherwise, 0 is returned,r=(_A0 >= _B0) ? 0x1 : 0x0  
  224. extern int _mm_ucomige_ss(__m128 _A, __m128 _B);  
  225. //返回一个0或1的整数,If a and b are not equal, 1 is returned.   
  226. //Otherwise, 0 is returned. If a or b is a NaN, 1 is returned,  
  227. //r=(_A0 != _B0) ? 0x1 : 0x0  
  228. extern int _mm_ucomineq_ss(__m128 _A, __m128 _B);  
  229.   
  230. //Conversion Operations(SSE)  
  231. //返回一个32bit的整数,Converts the lower single-precision, floating-point value  
  232. //of a to a 32-bit integer according to the current rounding mode, r=(int)_A0  
  233. extern int _mm_cvt_ss2si(__m128 _A);//=_mm_cvtss_si32  
  234. //返回一个__m64寄存器,Converts the two lower single-precision, floating-point   
  235. //values of a to two 32-bit integers according to the current rounding mode,   
  236. //returning the integers in packed form, r0=(int)_A0, r1=(int)_A1  
  237. extern __m64 _mm_cvt_ps2pi(__m128 _A);//=_mm_cvtps_pi32  
  238. //返回一个32bit的整数,Converts the lower single-precision, floating-point value  
  239. //of a to a 32-bit integer with truncation, r=(int)_A0  
  240. extern int _mm_cvtt_ss2si(__m128 _A);//=_mm_cvttss_si32  
  241. //返回一个__m64寄存器,Converts the two lower single-precision, floating-point   
  242. //values of a to two 32-bit integer with truncation, returning the integers   
  243. //in packed form, r0=(int)_A0, r1=(int)_A1  
  244. extern __m64 _mm_cvtt_ps2pi(__m128 _A);//=_mm_cvttps_pi32  
  245. //返回一个__m128的寄存器,Converts the 32-bit integer value b to an single-precision,  
  246. //floating-point value; the upper three single-precision, floating-point values are  
  247. //passed through from a, r0=(float)_B, r1=_A1, r2=_A2, r3=_A3  
  248. extern __m128 _mm_cvt_si2ss(__m128 _A, int _B);//=_mm_cvtsi32_ss   
  249. //返回一个__m128的寄存器,Converts the two 32-bit integer values in packed form in b  
  250. //to two single-precision, floating-point values; the upper two single-precision,   
  251. //floating-point values are passed through from a  
  252. //r0=(float)_B0, r1=(float)_B1, r2=_A2, r3=_A3  
  253. extern __m128 _mm_cvt_pi2ps(__m128 _A, __m64 _B);//=_mm_cvtpi32_ps  
  254. //返回一个__m128的寄存器,Converts the four 16-bit signed integer values in a to   
  255. //four single-precision, floating-point values  
  256. //r0=(float)_A0, r1=(float)_A1, r2=(float)_A2, r3=(float)_A3  
  257. __inline __m128 _mm_cvtpi16_ps(__m64 _A);  
  258. //返回一个__m128的寄存器,Converts the four 16-bit unsigned integer values in a  
  259. //to four single-precision, floating-point values  
  260. //r0=(float)_A0, r1=(float)_A1, r2=(float)_A2, r3=(float)_A3  
  261. __inline __m128 _mm_cvtpu16_ps(__m64 _A);  
  262. //返回一个__m64的寄存器,Converts the four single-precision, floating-point values  
  263. //in a to four signed 16-bit integer values  
  264. //r0=(short)_A0, r1=(short)_A1, r2=(short)_A2, r3=(short)_A3  
  265. __inline __m64 _mm_cvtps_pi16(__m128 _A);  
  266. //返回一个__m128的寄存器,Converts the lower four 8-bit signed integer values in a   
  267. //to four single-precision, floating-point values  
  268. //r0=(float)_A0, r1=(float)_A1, r2=(float)_A2, r3=(float)_A3  
  269. __inline __m128 _mm_cvtpi8_ps(__m64 _A);  
  270. //返回一个__m128的寄存器,Converts the lower four 8-bit unsigned integer values in a  
  271. //to four single-precision, floating-point values  
  272. //r0=(float)_A0, r1=(float)_A1, r2=(float)_A2, r3=(float)_A3  
  273. __inline __m128 _mm_cvtpu8_ps(__m64 _A);  
  274. //返回一个__m64的寄存器,Converts the four single-precision, floating-point values   
  275. //in a to the lower four signed 8-bit integer values of the result  
  276. //r0=(char)_A0, r1=(char)_A1, r2=(char)_A2, r3=(char)_A3  
  277. __inline __m64 _mm_cvtps_pi8(__m128 _A);  
  278. //返回一个__m128的寄存器,Converts the two 32-bit signed integer values in a and the  
  279. //two 32-bit signed integer values in b to four single-precision, floating-point values  
  280. //r0=(float)_A0, r1=(float)_A1, r2=(float)_B0, r3=(float)_B1  
  281. __inline __m128 _mm_cvtpi32x2_ps(__m64 _A, __m64 _B);  
  282. //返回一个32bit浮点数,Extracts the lower order floating point value from the parameter  
  283. //r=_A0  
  284. extern float _mm_cvtss_f32(__m128 _A);  
  285.   
  286. //Miscellaneous Instructions That Use Streaming SIMD Extensions:  
  287. //返回一个__m128的寄存器,Selects four specific single-precision, floating-point   
  288. //values from a and b, based on the mask i  
  289. extern __m128 _mm_shuffle_ps(__m128 _A, __m128 _B, unsigned int _Imm8);  
  290. //返回一个__m128的寄存器,Selects and interleaves the upper two single-precision,  
  291. //floating-point values from a and b  
  292. //r0=_A2, r1=_B2, r2=_A3, r3=_B3  
  293. extern __m128 _mm_unpackhi_ps(__m128 _A, __m128 _B);  
  294. //返回一个__m128的寄存器,Selects and interleaves the lower two single-precision,  
  295. //floating-point values from a and b  
  296. //r0=_A0, r1=_B0, r2=_A1, r3=_B1  
  297. extern __m128 _mm_unpacklo_ps(__m128 _A, __m128 _B);  
  298. //返回一个__m128的寄存器,Sets the upper two single-precision, floating-point   
  299. //values with 64 bits of data loaded from the address p; the lower two values  
  300. //are passed through from a  
  301. //r0=_A0, r1=_A1, r2=*_P0, r3=*_P1  
  302. extern __m128 _mm_loadh_pi(__m128 _A, __m64 const* _P);  
  303. //返回一个__m128的寄存器,Moves the upper two single-precision, floating-point  
  304. //values of b to the lower two single-precision, floating-point values of the result  
  305. //r3=_A3, r2=_A2, r1=_B3, r0=_B2  
  306. extern __m128 _mm_movehl_ps(__m128 _A, __m128 _B);  
  307. //返回一个__m128的寄存器,Moves the lower two single-precision, floating-point   
  308. //values of b to the upper two single-precision, floating-point values of the result  
  309. //r3=_B1, r2=_B0, r1=_A1, r0=_A0  
  310. extern __m128 _mm_movelh_ps(__m128 _A, __m128 _B);  
  311. //返回为空,Stores the upper two single-precision, floating-point values of a   
  312. //to the address p, *_P0=_A2, *_P1=_A3  
  313. extern void _mm_storeh_pi(__m64 *_P, __m128 _A);  
  314. //返回一个__m128的寄存器,Sets the lower two single-precision, floating-point  
  315. //values with 64 bits of data loaded from the address p; the upper two values  
  316. //are passed through from a  
  317. //r0=*_P0, r1=*_P1, r2=_A2, r3=_A3    
  318. extern __m128 _mm_loadl_pi(__m128 _A, __m64 const* _P);  
  319. //返回为空,Stores the lower two single-precision, floating-point values of a  
  320. //to the address p, *_P0=_A0, *_P1=_A1  
  321. extern void _mm_storel_pi(__m64 *_P, __m128 _A);  
  322. //返回一个整数,Creates a 4-bit mask from the most significant bits of the  
  323. //four single-precision, floating-point values    
  324. //r=sign(_A3)<<3 | sign(_A2)<<2 | sign(_A1)<<1 | sign(_A0)  
  325. extern int _mm_movemask_ps(__m128 _A);  
  326. //返回一个无符号整数,Returns the contents of the control register  
  327. extern unsigned int _mm_getcsr(void);  
  328. //返回为空,Sets the control register to the value specified  
  329. extern void _mm_setcsr(unsigned int);  
  330.   
  331. //Memory and Initialization Using Streaming SIMD Extensions  
  332. //Load Operations(SSE)  
  333. //返回一个__m128的寄存器,Loads an single-precision, floating-point value into  
  334. //the low word and clears the upper three words  
  335. //r0=*_P, r1=0.0, r2=0.0, r3=0.0  
  336. extern __m128 _mm_load_ss(float const* _P);  
  337. //返回一个__m128的寄存器,Loads a single single-precision, floating-point value,  
  338. //copying it into all four words  
  339. //r0=*_P0, r1=*_P1, r2=*_P2, r3=*_P3  
  340. extern __m128 _mm_load_ps1(float const* _P);//=_mm_load1_ps  
  341. //返回一个__m128的寄存器,Loads four single-precision, floating-point values  
  342. //The address must be 16-byte aligned  
  343. //r0=_P[0], r1=_P[1], r2=_P[2], r3=_P[3]  
  344. extern __m128 _mm_load_ps(float const* _P);  
  345. //返回一个__m128的寄存器,Loads four single-precision, floating-point values   
  346. //in reverse order, The address must be 16-byte aligned  
  347. //r0=_P[3], r1=_P[2], r2=_P[1], r3=_P[0]  
  348. extern __m128 _mm_loadr_ps(float const* _P);  
  349. //返回一个__m128的寄存器,Loads four single-precision, floating-point values  
  350. //The address does not need to be 16-byte aligned  
  351. //r0=_P[0], r1=_P[1], r2=_P[2], r3=_P[3]  
  352. extern __m128 _mm_loadu_ps(float const* _P);  
  353.   
  354. //Set Operations(SSE)  
  355. //返回一个__m128的寄存器,Sets the low word of an single-precision,   
  356. //floating-point value to w and clears the upper three words  
  357. //r0=_W, r1=r2=r3=0.0  
  358. extern __m128 _mm_set_ss(float _W);  
  359. //返回一个__m128的寄存器,Sets the four single-precision, floating-point values to w  
  360. //r0=r1=r2=r3=_W  
  361. extern __m128 _mm_set_ps1(float _W);//=_mm_set1_ps  
  362. //返回一个__m128的寄存器,Sets the four single-precision, floating-point values to   
  363. //the four inputs, r0=_D, r1=_C, r2=_B, r3=_A  
  364. extern __m128 _mm_set_ps(float _A, float _B, float _C, float _D);  
  365. //返回一个__m128的寄存器,Sets the four single-precision, floating-point values to  
  366. //the four inputs in reverse order, r0=_A, r1=_B, r2=_C, r3=_D  
  367. extern __m128 _mm_setr_ps(float _A, float _B, float _C, float _D);  
  368. //返回一个__m128的寄存器,Clears the four single-precision, floating-point values  
  369. //r0=r1=r2=r3=0.0  
  370. extern __m128 _mm_setzero_ps(void);  
  371.   
  372. //Store Operations(SSE)  
  373. //返回为空,Stores the lower single-precision, floating-point value,*_V=_A0  
  374. extern void _mm_store_ss(float *_V, __m128 _A);  
  375. //返回为空,Stores the lower single-precision, floating-point value across four words  
  376. //_V[0]=_A0, _V[1]=_A0, _V[2]=_A0, _V[3]=_A0  
  377. extern void _mm_store_ps1(float *_V, __m128 _A);//=_mm_store1_ps  
  378. //返回为空,Stores four single-precision, floating-point values  
  379. //The address must be 16-byte aligned  
  380. //_V[0]=_A0, _V[1]=_A1, _V[2]=_A2, _V[3]=_A3  
  381. extern void _mm_store_ps(float *_V, __m128 _A);  
  382. //返回为空,Stores four single-precision, floating-point values in reverse order  
  383. //The address must be 16-byte aligned,  
  384. //_V[0]=_A3, _V[1]=_A2, _V[2]=_A1, _V[3]=_A0  
  385. extern void _mm_storer_ps(float *_V, __m128 _A);  
  386. //返回为空,Stores four single-precision, floating-point values,  
  387. //The address does not need to be 16-byte aligned  
  388. //_V[0]=_A0, _V[1]=_A1, _V[2]=_A2, _V[3]=_A3  
  389. extern void _mm_storeu_ps(float *_V, __m128 _A);  
  390. //返回一个__m128的寄存器,Sets the low word to the single-precision, floating-point  
  391. //value of b,The upper 3 single-precision, floating-point values are passed through   
  392. //from a, r0=_B0, r1=_A1, r2=_A2, r3=_A3          
  393. extern __m128 _mm_move_ss(__m128 _A, __m128 _B);  
  394.   
  395. //Integer Intrinsics Using Streaming SIMD Extensions  
  396. //返回一个16bit整数,Extracts one of the four words of a,  
  397. //The selector n must be an immediate,  
  398. //r=(_Imm == 0) ? _A0 : ((_Imm==1) ? _A1 : ((_Imm==2) ? _A2 : _A3))  
  399. extern int _m_pextrw(__m64 _A, int _Imm);//=_mm_extract_pi16  
  400. //返回一个__m64的寄存器,Inserts word d into one of four words of a,  
  401. //The selector n must be an immediate  
  402. //r0=(_Imm==0)? _D : _A0, r1=(_Imm==1)? _D : _A1,  
  403. //r2=(_Imm==2)? _D : _A2, r3=(_Imm==3)? _D : _A3  
  404. extern __m64 _m_pinsrw(__m64 _A, int _D, int _Imm);//=_mm_insert_pi16  
  405. //返回一个__m64的寄存器,Computes the element-wise maximum of the words in a and b,  
  406. //r0=max(_A0, _B0), r1=max(_A1, _B1), r2=max(_A2, _B2), r3=max(_A3, _B3)  
  407. extern __m64 _m_pmaxsw(__m64 _A, __m64 _B);//=_mm_max_pi16  
  408. //返回一个__m64的寄存器,Computes the element-wise maximum of the unsigned bytes in  
  409. //a and b, r0=max(_A0, _B0), r1=max(_A1, _B1), ... r7=max(_A7, _B7)  
  410. extern __m64 _m_pmaxub(__m64 _A, __m64 _B);//=_mm_max_pu8  
  411. //返回一个__m64的寄存器,Computes the element-wise minimum of the words in a and b  
  412. //r0=min(_A0, _B0), r1=min(_A1, _B1), r2=min(_A2, _B2), r3=min(_A3, _B3)  
  413. extern __m64 _m_pminsw(__m64 _A, __m64 _B);//=_mm_min_pi16  
  414. //返回一个__m64的寄存器,Computes the element-wise minimum of the unsigned bytes  
  415. //in a and b, r0=min(_A0, _B0), r1=min(_A1, _B1), ... r7=min(_A7, _B7)  
  416. extern __m64 _m_pminub(__m64 _A, __m64 _B);//=_mm_min_pu8  
  417. //返回一个整数,Creates an 8-bit mask from the most significant bits of the  
  418. //bytes in a, r=sign(_A7)<<7 | sign(_A6)<<6 | ... | sign(_A0)  
  419. extern int _m_pmovmskb(__m64 _A);//=_mm_movemask_pi8  
  420. //返回一个__m64的寄存器,Multiplies the unsigned words in a and b, returning the  
  421. //upper 16 bits of the 32-bit intermediate results,  
  422. //r0=hiword(_A0, _B0), r1=hiword(_A1, _B1), r2=hiword(_A2, _B2), r3=hiword(_A3, _B3)  
  423. extern __m64 _m_pmulhuw(__m64 _A, __m64 _B);//=_mm_mulhi_pu16  
  424. //返回为空,Conditionally stores byte elements of d to address p,The high bit of   
  425. //each byte in the selector _B determines whether the corresponding byte in _A   
  426. //will be stored, if (sign(_B0)) _P[0]=_A0, if (sign(_B1)) _P[1]=_A1, ...  
  427. //if (sign(_B7)) _P[7]=_A7  
  428. extern void _m_maskmovq(__m64 _A, __m64 _B, char * _P);//=_mm_maskmove_si64  
  429. //返回一个__m64的寄存器,Computes the (rounded) averages of the unsigned bytes   
  430. //in a and b, t=(unsigned short)_A0 + (unsigned short)_B0, r0=(t>>1) | (t & 0x01),  
  431. //..., t=(unsigned short)_A7 + (unsigned short)_B7, r7=(t>>1) | (t & 0x01)      
  432. extern __m64 _m_pavgb(__m64 _A, __m64 _B);//=_mm_avg_pu8  
  433. //返回一个__m64的寄存器,Computes the (rounded) averages of the unsigned words  
  434. //in a and b, t=(unsigned short)_A0 + (unsigned short)_B0, r0=(t>>1) | (t & 0x01),  
  435. //..., t=(unsigned short)_A4 + (unsigned short)_B4, r7=(t>>1) | (t & 0x01)  
  436. extern __m64 _m_pavgw(__m64 _A, __m64 _B);//=_mm_avg_pu16  
  437. //返回一个__m64的寄存器,Computes the sum of the absolute differences of the unsigned  
  438. //bytes in a and b, returning the value in the lower word  
  439. //The upper three words are cleared  
  440. //r0=abs(_A0-_B0) + ... + abs(_A7-_B7), r1=r2=r3=0  
  441. extern __m64 _m_psadbw(__m64, __m64);//=_mm_sad_pu8  
  442. //返回一个__m64的寄存器,Returns a combination of the four words of a.  
  443. //The selector _Imm must be an immediate  
  444. //r0=word(_Imm & 0x03) of _A, r1=word((_Imm>>2) & 0x03) of _A,   
  445. //r2=word((_Imm>>4) & 0x03) of _A, r1=word((_Imm>>6) & 0x03) of _A,   
  446. extern __m64 _m_pshufw(__m64 _A, int _Imm);//=_mm_shuffle_pi16  
  447.   
  448. //Streaming SIMD Extensions that Support the Cache  
  449. //返回为空,Loads one cache line of data from address p to a location closer  
  450. //to the processor, The value _Sel specifies the type of prefetch operation  
  451. extern void _mm_prefetch(char const*_A, int _Sel);  
  452. //返回为空,Stores the data in a to the address p without polluting the caches  
  453. //This intrinsic requires you to empty the multimedia state for the MMX register  
  454. extern void _mm_stream_pi(__m64 * _P, __m64 _A);  
  455. //返回为空,Stores the data in a to the address p without polluting the caches,  
  456. //The address must be 16-byte aligned  
  457. extern void _mm_stream_ps(float *, __m128 _A);  
  458. //返回为空,Guarantees that every preceding store is globally visible   
  459. //before any subsequent store  
  460. extern void _mm_sfence(void);  
  461.   
  462. /* Alternate intrinsic names definition */  
  463. #define _mm_cvtss_si32    _mm_cvt_ss2si  
  464. #define _mm_cvtps_pi32    _mm_cvt_ps2pi  
  465. #define _mm_cvttss_si32   _mm_cvtt_ss2si  
  466. #define _mm_cvttps_pi32   _mm_cvtt_ps2pi  
  467. #define _mm_cvtsi32_ss    _mm_cvt_si2ss  
  468. #define _mm_cvtpi32_ps    _mm_cvt_pi2ps  
  469. #define _mm_extract_pi16  _m_pextrw  
  470. #define _mm_insert_pi16   _m_pinsrw  
  471. #define _mm_max_pi16      _m_pmaxsw  
  472. #define _mm_max_pu8       _m_pmaxub  
  473. #define _mm_min_pi16      _m_pminsw  
  474. #define _mm_min_pu8       _m_pminub  
  475. #define _mm_movemask_pi8  _m_pmovmskb  
  476. #define _mm_mulhi_pu16    _m_pmulhuw  
  477. #define _mm_shuffle_pi16  _m_pshufw  
  478. #define _mm_maskmove_si64 _m_maskmovq  
  479. #define _mm_avg_pu8       _m_pavgb  
  480. #define _mm_avg_pu16      _m_pavgw  
  481. #define _mm_sad_pu8       _m_psadbw  
  482. #define _mm_set1_ps       _mm_set_ps1  
  483. #define _mm_load1_ps      _mm_load_ps1  
  484. #define _mm_store1_ps     _mm_store_ps1 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值