mmintrin.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. /* Copyright (C) 2002-2019 Free Software Foundation, Inc.
  2. This file is part of GCC.
  3. GCC is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. GCC is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. /* Implemented from the specification included in the Intel C++ Compiler
  19. User Guide and Reference, version 9.0. */
  20. #ifndef _MMINTRIN_H_INCLUDED
  21. #define _MMINTRIN_H_INCLUDED
  22. #if defined __x86_64__ && !defined __SSE__ || !defined __MMX__
  23. #pragma GCC push_options
  24. #ifdef __x86_64__
  25. #pragma GCC target("sse,mmx")
  26. #else
  27. #pragma GCC target("mmx")
  28. #endif
  29. #define __DISABLE_MMX__
  30. #endif /* __MMX__ */
  31. /* The Intel API is flexible enough that we must allow aliasing with other
  32. vector types, and their scalar components. */
  33. typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));
  34. /* Unaligned version of the same type */
  35. typedef int __m64_u __attribute__ ((__vector_size__ (8), __may_alias__, __aligned__ (1)));
  36. /* Internal data types for implementing the intrinsics. */
  37. typedef int __v2si __attribute__ ((__vector_size__ (8)));
  38. typedef short __v4hi __attribute__ ((__vector_size__ (8)));
  39. typedef char __v8qi __attribute__ ((__vector_size__ (8)));
  40. typedef long long __v1di __attribute__ ((__vector_size__ (8)));
  41. typedef float __v2sf __attribute__ ((__vector_size__ (8)));
  42. /* Empty the multimedia state. */
  43. extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  44. _mm_empty (void)
  45. {
  46. __builtin_ia32_emms ();
  47. }
  48. extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  49. _m_empty (void)
  50. {
  51. _mm_empty ();
  52. }
  53. /* Convert I to a __m64 object. The integer is zero-extended to 64-bits. */
  54. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  55. _mm_cvtsi32_si64 (int __i)
  56. {
  57. return (__m64) __builtin_ia32_vec_init_v2si (__i, 0);
  58. }
  59. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  60. _m_from_int (int __i)
  61. {
  62. return _mm_cvtsi32_si64 (__i);
  63. }
  64. #ifdef __x86_64__
  65. /* Convert I to a __m64 object. */
  66. /* Intel intrinsic. */
  67. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  68. _m_from_int64 (long long __i)
  69. {
  70. return (__m64) __i;
  71. }
  72. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  73. _mm_cvtsi64_m64 (long long __i)
  74. {
  75. return (__m64) __i;
  76. }
  77. /* Microsoft intrinsic. */
  78. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  79. _mm_cvtsi64x_si64 (long long __i)
  80. {
  81. return (__m64) __i;
  82. }
  83. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  84. _mm_set_pi64x (long long __i)
  85. {
  86. return (__m64) __i;
  87. }
  88. #endif
  89. /* Convert the lower 32 bits of the __m64 object into an integer. */
  90. extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  91. _mm_cvtsi64_si32 (__m64 __i)
  92. {
  93. return __builtin_ia32_vec_ext_v2si ((__v2si)__i, 0);
  94. }
  95. extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  96. _m_to_int (__m64 __i)
  97. {
  98. return _mm_cvtsi64_si32 (__i);
  99. }
  100. #ifdef __x86_64__
  101. /* Convert the __m64 object to a 64bit integer. */
  102. /* Intel intrinsic. */
  103. extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  104. _m_to_int64 (__m64 __i)
  105. {
  106. return (long long)__i;
  107. }
  108. extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  109. _mm_cvtm64_si64 (__m64 __i)
  110. {
  111. return (long long)__i;
  112. }
  113. /* Microsoft intrinsic. */
  114. extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  115. _mm_cvtsi64_si64x (__m64 __i)
  116. {
  117. return (long long)__i;
  118. }
  119. #endif
  120. /* Pack the four 16-bit values from M1 into the lower four 8-bit values of
  121. the result, and the four 16-bit values from M2 into the upper four 8-bit
  122. values of the result, all with signed saturation. */
  123. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  124. _mm_packs_pi16 (__m64 __m1, __m64 __m2)
  125. {
  126. return (__m64) __builtin_ia32_packsswb ((__v4hi)__m1, (__v4hi)__m2);
  127. }
  128. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  129. _m_packsswb (__m64 __m1, __m64 __m2)
  130. {
  131. return _mm_packs_pi16 (__m1, __m2);
  132. }
  133. /* Pack the two 32-bit values from M1 in to the lower two 16-bit values of
  134. the result, and the two 32-bit values from M2 into the upper two 16-bit
  135. values of the result, all with signed saturation. */
  136. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  137. _mm_packs_pi32 (__m64 __m1, __m64 __m2)
  138. {
  139. return (__m64) __builtin_ia32_packssdw ((__v2si)__m1, (__v2si)__m2);
  140. }
  141. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  142. _m_packssdw (__m64 __m1, __m64 __m2)
  143. {
  144. return _mm_packs_pi32 (__m1, __m2);
  145. }
  146. /* Pack the four 16-bit values from M1 into the lower four 8-bit values of
  147. the result, and the four 16-bit values from M2 into the upper four 8-bit
  148. values of the result, all with unsigned saturation. */
  149. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  150. _mm_packs_pu16 (__m64 __m1, __m64 __m2)
  151. {
  152. return (__m64) __builtin_ia32_packuswb ((__v4hi)__m1, (__v4hi)__m2);
  153. }
  154. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  155. _m_packuswb (__m64 __m1, __m64 __m2)
  156. {
  157. return _mm_packs_pu16 (__m1, __m2);
  158. }
  159. /* Interleave the four 8-bit values from the high half of M1 with the four
  160. 8-bit values from the high half of M2. */
  161. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  162. _mm_unpackhi_pi8 (__m64 __m1, __m64 __m2)
  163. {
  164. return (__m64) __builtin_ia32_punpckhbw ((__v8qi)__m1, (__v8qi)__m2);
  165. }
  166. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  167. _m_punpckhbw (__m64 __m1, __m64 __m2)
  168. {
  169. return _mm_unpackhi_pi8 (__m1, __m2);
  170. }
  171. /* Interleave the two 16-bit values from the high half of M1 with the two
  172. 16-bit values from the high half of M2. */
  173. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  174. _mm_unpackhi_pi16 (__m64 __m1, __m64 __m2)
  175. {
  176. return (__m64) __builtin_ia32_punpckhwd ((__v4hi)__m1, (__v4hi)__m2);
  177. }
  178. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  179. _m_punpckhwd (__m64 __m1, __m64 __m2)
  180. {
  181. return _mm_unpackhi_pi16 (__m1, __m2);
  182. }
  183. /* Interleave the 32-bit value from the high half of M1 with the 32-bit
  184. value from the high half of M2. */
  185. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  186. _mm_unpackhi_pi32 (__m64 __m1, __m64 __m2)
  187. {
  188. return (__m64) __builtin_ia32_punpckhdq ((__v2si)__m1, (__v2si)__m2);
  189. }
  190. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  191. _m_punpckhdq (__m64 __m1, __m64 __m2)
  192. {
  193. return _mm_unpackhi_pi32 (__m1, __m2);
  194. }
  195. /* Interleave the four 8-bit values from the low half of M1 with the four
  196. 8-bit values from the low half of M2. */
  197. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  198. _mm_unpacklo_pi8 (__m64 __m1, __m64 __m2)
  199. {
  200. return (__m64) __builtin_ia32_punpcklbw ((__v8qi)__m1, (__v8qi)__m2);
  201. }
  202. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  203. _m_punpcklbw (__m64 __m1, __m64 __m2)
  204. {
  205. return _mm_unpacklo_pi8 (__m1, __m2);
  206. }
  207. /* Interleave the two 16-bit values from the low half of M1 with the two
  208. 16-bit values from the low half of M2. */
  209. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  210. _mm_unpacklo_pi16 (__m64 __m1, __m64 __m2)
  211. {
  212. return (__m64) __builtin_ia32_punpcklwd ((__v4hi)__m1, (__v4hi)__m2);
  213. }
  214. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  215. _m_punpcklwd (__m64 __m1, __m64 __m2)
  216. {
  217. return _mm_unpacklo_pi16 (__m1, __m2);
  218. }
  219. /* Interleave the 32-bit value from the low half of M1 with the 32-bit
  220. value from the low half of M2. */
  221. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  222. _mm_unpacklo_pi32 (__m64 __m1, __m64 __m2)
  223. {
  224. return (__m64) __builtin_ia32_punpckldq ((__v2si)__m1, (__v2si)__m2);
  225. }
  226. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  227. _m_punpckldq (__m64 __m1, __m64 __m2)
  228. {
  229. return _mm_unpacklo_pi32 (__m1, __m2);
  230. }
  231. /* Add the 8-bit values in M1 to the 8-bit values in M2. */
  232. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  233. _mm_add_pi8 (__m64 __m1, __m64 __m2)
  234. {
  235. return (__m64) __builtin_ia32_paddb ((__v8qi)__m1, (__v8qi)__m2);
  236. }
  237. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  238. _m_paddb (__m64 __m1, __m64 __m2)
  239. {
  240. return _mm_add_pi8 (__m1, __m2);
  241. }
  242. /* Add the 16-bit values in M1 to the 16-bit values in M2. */
  243. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  244. _mm_add_pi16 (__m64 __m1, __m64 __m2)
  245. {
  246. return (__m64) __builtin_ia32_paddw ((__v4hi)__m1, (__v4hi)__m2);
  247. }
  248. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  249. _m_paddw (__m64 __m1, __m64 __m2)
  250. {
  251. return _mm_add_pi16 (__m1, __m2);
  252. }
  253. /* Add the 32-bit values in M1 to the 32-bit values in M2. */
  254. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  255. _mm_add_pi32 (__m64 __m1, __m64 __m2)
  256. {
  257. return (__m64) __builtin_ia32_paddd ((__v2si)__m1, (__v2si)__m2);
  258. }
  259. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  260. _m_paddd (__m64 __m1, __m64 __m2)
  261. {
  262. return _mm_add_pi32 (__m1, __m2);
  263. }
  264. /* Add the 64-bit values in M1 to the 64-bit values in M2. */
  265. #ifndef __SSE2__
  266. #pragma GCC push_options
  267. #pragma GCC target("sse2,mmx")
  268. #define __DISABLE_SSE2__
  269. #endif /* __SSE2__ */
  270. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  271. _mm_add_si64 (__m64 __m1, __m64 __m2)
  272. {
  273. return (__m64) __builtin_ia32_paddq ((__v1di)__m1, (__v1di)__m2);
  274. }
  275. #ifdef __DISABLE_SSE2__
  276. #undef __DISABLE_SSE2__
  277. #pragma GCC pop_options
  278. #endif /* __DISABLE_SSE2__ */
  279. /* Add the 8-bit values in M1 to the 8-bit values in M2 using signed
  280. saturated arithmetic. */
  281. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  282. _mm_adds_pi8 (__m64 __m1, __m64 __m2)
  283. {
  284. return (__m64) __builtin_ia32_paddsb ((__v8qi)__m1, (__v8qi)__m2);
  285. }
  286. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  287. _m_paddsb (__m64 __m1, __m64 __m2)
  288. {
  289. return _mm_adds_pi8 (__m1, __m2);
  290. }
  291. /* Add the 16-bit values in M1 to the 16-bit values in M2 using signed
  292. saturated arithmetic. */
  293. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  294. _mm_adds_pi16 (__m64 __m1, __m64 __m2)
  295. {
  296. return (__m64) __builtin_ia32_paddsw ((__v4hi)__m1, (__v4hi)__m2);
  297. }
  298. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  299. _m_paddsw (__m64 __m1, __m64 __m2)
  300. {
  301. return _mm_adds_pi16 (__m1, __m2);
  302. }
  303. /* Add the 8-bit values in M1 to the 8-bit values in M2 using unsigned
  304. saturated arithmetic. */
  305. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  306. _mm_adds_pu8 (__m64 __m1, __m64 __m2)
  307. {
  308. return (__m64) __builtin_ia32_paddusb ((__v8qi)__m1, (__v8qi)__m2);
  309. }
  310. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  311. _m_paddusb (__m64 __m1, __m64 __m2)
  312. {
  313. return _mm_adds_pu8 (__m1, __m2);
  314. }
  315. /* Add the 16-bit values in M1 to the 16-bit values in M2 using unsigned
  316. saturated arithmetic. */
  317. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  318. _mm_adds_pu16 (__m64 __m1, __m64 __m2)
  319. {
  320. return (__m64) __builtin_ia32_paddusw ((__v4hi)__m1, (__v4hi)__m2);
  321. }
  322. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  323. _m_paddusw (__m64 __m1, __m64 __m2)
  324. {
  325. return _mm_adds_pu16 (__m1, __m2);
  326. }
  327. /* Subtract the 8-bit values in M2 from the 8-bit values in M1. */
  328. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  329. _mm_sub_pi8 (__m64 __m1, __m64 __m2)
  330. {
  331. return (__m64) __builtin_ia32_psubb ((__v8qi)__m1, (__v8qi)__m2);
  332. }
  333. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  334. _m_psubb (__m64 __m1, __m64 __m2)
  335. {
  336. return _mm_sub_pi8 (__m1, __m2);
  337. }
  338. /* Subtract the 16-bit values in M2 from the 16-bit values in M1. */
  339. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  340. _mm_sub_pi16 (__m64 __m1, __m64 __m2)
  341. {
  342. return (__m64) __builtin_ia32_psubw ((__v4hi)__m1, (__v4hi)__m2);
  343. }
  344. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  345. _m_psubw (__m64 __m1, __m64 __m2)
  346. {
  347. return _mm_sub_pi16 (__m1, __m2);
  348. }
  349. /* Subtract the 32-bit values in M2 from the 32-bit values in M1. */
  350. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  351. _mm_sub_pi32 (__m64 __m1, __m64 __m2)
  352. {
  353. return (__m64) __builtin_ia32_psubd ((__v2si)__m1, (__v2si)__m2);
  354. }
  355. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  356. _m_psubd (__m64 __m1, __m64 __m2)
  357. {
  358. return _mm_sub_pi32 (__m1, __m2);
  359. }
  360. /* Add the 64-bit values in M1 to the 64-bit values in M2. */
  361. #ifndef __SSE2__
  362. #pragma GCC push_options
  363. #pragma GCC target("sse2,mmx")
  364. #define __DISABLE_SSE2__
  365. #endif /* __SSE2__ */
  366. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  367. _mm_sub_si64 (__m64 __m1, __m64 __m2)
  368. {
  369. return (__m64) __builtin_ia32_psubq ((__v1di)__m1, (__v1di)__m2);
  370. }
  371. #ifdef __DISABLE_SSE2__
  372. #undef __DISABLE_SSE2__
  373. #pragma GCC pop_options
  374. #endif /* __DISABLE_SSE2__ */
  375. /* Subtract the 8-bit values in M2 from the 8-bit values in M1 using signed
  376. saturating arithmetic. */
  377. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  378. _mm_subs_pi8 (__m64 __m1, __m64 __m2)
  379. {
  380. return (__m64) __builtin_ia32_psubsb ((__v8qi)__m1, (__v8qi)__m2);
  381. }
  382. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  383. _m_psubsb (__m64 __m1, __m64 __m2)
  384. {
  385. return _mm_subs_pi8 (__m1, __m2);
  386. }
  387. /* Subtract the 16-bit values in M2 from the 16-bit values in M1 using
  388. signed saturating arithmetic. */
  389. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  390. _mm_subs_pi16 (__m64 __m1, __m64 __m2)
  391. {
  392. return (__m64) __builtin_ia32_psubsw ((__v4hi)__m1, (__v4hi)__m2);
  393. }
  394. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  395. _m_psubsw (__m64 __m1, __m64 __m2)
  396. {
  397. return _mm_subs_pi16 (__m1, __m2);
  398. }
  399. /* Subtract the 8-bit values in M2 from the 8-bit values in M1 using
  400. unsigned saturating arithmetic. */
  401. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  402. _mm_subs_pu8 (__m64 __m1, __m64 __m2)
  403. {
  404. return (__m64) __builtin_ia32_psubusb ((__v8qi)__m1, (__v8qi)__m2);
  405. }
  406. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  407. _m_psubusb (__m64 __m1, __m64 __m2)
  408. {
  409. return _mm_subs_pu8 (__m1, __m2);
  410. }
  411. /* Subtract the 16-bit values in M2 from the 16-bit values in M1 using
  412. unsigned saturating arithmetic. */
  413. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  414. _mm_subs_pu16 (__m64 __m1, __m64 __m2)
  415. {
  416. return (__m64) __builtin_ia32_psubusw ((__v4hi)__m1, (__v4hi)__m2);
  417. }
  418. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  419. _m_psubusw (__m64 __m1, __m64 __m2)
  420. {
  421. return _mm_subs_pu16 (__m1, __m2);
  422. }
  423. /* Multiply four 16-bit values in M1 by four 16-bit values in M2 producing
  424. four 32-bit intermediate results, which are then summed by pairs to
  425. produce two 32-bit results. */
  426. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  427. _mm_madd_pi16 (__m64 __m1, __m64 __m2)
  428. {
  429. return (__m64) __builtin_ia32_pmaddwd ((__v4hi)__m1, (__v4hi)__m2);
  430. }
  431. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  432. _m_pmaddwd (__m64 __m1, __m64 __m2)
  433. {
  434. return _mm_madd_pi16 (__m1, __m2);
  435. }
  436. /* Multiply four signed 16-bit values in M1 by four signed 16-bit values in
  437. M2 and produce the high 16 bits of the 32-bit results. */
  438. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  439. _mm_mulhi_pi16 (__m64 __m1, __m64 __m2)
  440. {
  441. return (__m64) __builtin_ia32_pmulhw ((__v4hi)__m1, (__v4hi)__m2);
  442. }
  443. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  444. _m_pmulhw (__m64 __m1, __m64 __m2)
  445. {
  446. return _mm_mulhi_pi16 (__m1, __m2);
  447. }
  448. /* Multiply four 16-bit values in M1 by four 16-bit values in M2 and produce
  449. the low 16 bits of the results. */
  450. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  451. _mm_mullo_pi16 (__m64 __m1, __m64 __m2)
  452. {
  453. return (__m64) __builtin_ia32_pmullw ((__v4hi)__m1, (__v4hi)__m2);
  454. }
  455. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  456. _m_pmullw (__m64 __m1, __m64 __m2)
  457. {
  458. return _mm_mullo_pi16 (__m1, __m2);
  459. }
  460. /* Shift four 16-bit values in M left by COUNT. */
  461. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  462. _mm_sll_pi16 (__m64 __m, __m64 __count)
  463. {
  464. return (__m64) __builtin_ia32_psllw ((__v4hi)__m, (__v4hi)__count);
  465. }
  466. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  467. _m_psllw (__m64 __m, __m64 __count)
  468. {
  469. return _mm_sll_pi16 (__m, __count);
  470. }
  471. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  472. _mm_slli_pi16 (__m64 __m, int __count)
  473. {
  474. return (__m64) __builtin_ia32_psllwi ((__v4hi)__m, __count);
  475. }
  476. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  477. _m_psllwi (__m64 __m, int __count)
  478. {
  479. return _mm_slli_pi16 (__m, __count);
  480. }
  481. /* Shift two 32-bit values in M left by COUNT. */
  482. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  483. _mm_sll_pi32 (__m64 __m, __m64 __count)
  484. {
  485. return (__m64) __builtin_ia32_pslld ((__v2si)__m, (__v2si)__count);
  486. }
  487. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  488. _m_pslld (__m64 __m, __m64 __count)
  489. {
  490. return _mm_sll_pi32 (__m, __count);
  491. }
  492. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  493. _mm_slli_pi32 (__m64 __m, int __count)
  494. {
  495. return (__m64) __builtin_ia32_pslldi ((__v2si)__m, __count);
  496. }
  497. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  498. _m_pslldi (__m64 __m, int __count)
  499. {
  500. return _mm_slli_pi32 (__m, __count);
  501. }
  502. /* Shift the 64-bit value in M left by COUNT. */
  503. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  504. _mm_sll_si64 (__m64 __m, __m64 __count)
  505. {
  506. return (__m64) __builtin_ia32_psllq ((__v1di)__m, (__v1di)__count);
  507. }
  508. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  509. _m_psllq (__m64 __m, __m64 __count)
  510. {
  511. return _mm_sll_si64 (__m, __count);
  512. }
  513. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  514. _mm_slli_si64 (__m64 __m, int __count)
  515. {
  516. return (__m64) __builtin_ia32_psllqi ((__v1di)__m, __count);
  517. }
  518. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  519. _m_psllqi (__m64 __m, int __count)
  520. {
  521. return _mm_slli_si64 (__m, __count);
  522. }
  523. /* Shift four 16-bit values in M right by COUNT; shift in the sign bit. */
  524. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  525. _mm_sra_pi16 (__m64 __m, __m64 __count)
  526. {
  527. return (__m64) __builtin_ia32_psraw ((__v4hi)__m, (__v4hi)__count);
  528. }
  529. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  530. _m_psraw (__m64 __m, __m64 __count)
  531. {
  532. return _mm_sra_pi16 (__m, __count);
  533. }
  534. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  535. _mm_srai_pi16 (__m64 __m, int __count)
  536. {
  537. return (__m64) __builtin_ia32_psrawi ((__v4hi)__m, __count);
  538. }
  539. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  540. _m_psrawi (__m64 __m, int __count)
  541. {
  542. return _mm_srai_pi16 (__m, __count);
  543. }
  544. /* Shift two 32-bit values in M right by COUNT; shift in the sign bit. */
  545. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  546. _mm_sra_pi32 (__m64 __m, __m64 __count)
  547. {
  548. return (__m64) __builtin_ia32_psrad ((__v2si)__m, (__v2si)__count);
  549. }
  550. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  551. _m_psrad (__m64 __m, __m64 __count)
  552. {
  553. return _mm_sra_pi32 (__m, __count);
  554. }
  555. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  556. _mm_srai_pi32 (__m64 __m, int __count)
  557. {
  558. return (__m64) __builtin_ia32_psradi ((__v2si)__m, __count);
  559. }
  560. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  561. _m_psradi (__m64 __m, int __count)
  562. {
  563. return _mm_srai_pi32 (__m, __count);
  564. }
  565. /* Shift four 16-bit values in M right by COUNT; shift in zeros. */
  566. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  567. _mm_srl_pi16 (__m64 __m, __m64 __count)
  568. {
  569. return (__m64) __builtin_ia32_psrlw ((__v4hi)__m, (__v4hi)__count);
  570. }
  571. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  572. _m_psrlw (__m64 __m, __m64 __count)
  573. {
  574. return _mm_srl_pi16 (__m, __count);
  575. }
  576. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  577. _mm_srli_pi16 (__m64 __m, int __count)
  578. {
  579. return (__m64) __builtin_ia32_psrlwi ((__v4hi)__m, __count);
  580. }
  581. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  582. _m_psrlwi (__m64 __m, int __count)
  583. {
  584. return _mm_srli_pi16 (__m, __count);
  585. }
  586. /* Shift two 32-bit values in M right by COUNT; shift in zeros. */
  587. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  588. _mm_srl_pi32 (__m64 __m, __m64 __count)
  589. {
  590. return (__m64) __builtin_ia32_psrld ((__v2si)__m, (__v2si)__count);
  591. }
  592. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  593. _m_psrld (__m64 __m, __m64 __count)
  594. {
  595. return _mm_srl_pi32 (__m, __count);
  596. }
  597. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  598. _mm_srli_pi32 (__m64 __m, int __count)
  599. {
  600. return (__m64) __builtin_ia32_psrldi ((__v2si)__m, __count);
  601. }
  602. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  603. _m_psrldi (__m64 __m, int __count)
  604. {
  605. return _mm_srli_pi32 (__m, __count);
  606. }
  607. /* Shift the 64-bit value in M left by COUNT; shift in zeros. */
  608. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  609. _mm_srl_si64 (__m64 __m, __m64 __count)
  610. {
  611. return (__m64) __builtin_ia32_psrlq ((__v1di)__m, (__v1di)__count);
  612. }
  613. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  614. _m_psrlq (__m64 __m, __m64 __count)
  615. {
  616. return _mm_srl_si64 (__m, __count);
  617. }
  618. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  619. _mm_srli_si64 (__m64 __m, int __count)
  620. {
  621. return (__m64) __builtin_ia32_psrlqi ((__v1di)__m, __count);
  622. }
  623. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  624. _m_psrlqi (__m64 __m, int __count)
  625. {
  626. return _mm_srli_si64 (__m, __count);
  627. }
  628. /* Bit-wise AND the 64-bit values in M1 and M2. */
  629. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  630. _mm_and_si64 (__m64 __m1, __m64 __m2)
  631. {
  632. return __builtin_ia32_pand (__m1, __m2);
  633. }
  634. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  635. _m_pand (__m64 __m1, __m64 __m2)
  636. {
  637. return _mm_and_si64 (__m1, __m2);
  638. }
  639. /* Bit-wise complement the 64-bit value in M1 and bit-wise AND it with the
  640. 64-bit value in M2. */
  641. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  642. _mm_andnot_si64 (__m64 __m1, __m64 __m2)
  643. {
  644. return __builtin_ia32_pandn (__m1, __m2);
  645. }
  646. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  647. _m_pandn (__m64 __m1, __m64 __m2)
  648. {
  649. return _mm_andnot_si64 (__m1, __m2);
  650. }
  651. /* Bit-wise inclusive OR the 64-bit values in M1 and M2. */
  652. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  653. _mm_or_si64 (__m64 __m1, __m64 __m2)
  654. {
  655. return __builtin_ia32_por (__m1, __m2);
  656. }
  657. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  658. _m_por (__m64 __m1, __m64 __m2)
  659. {
  660. return _mm_or_si64 (__m1, __m2);
  661. }
  662. /* Bit-wise exclusive OR the 64-bit values in M1 and M2. */
  663. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  664. _mm_xor_si64 (__m64 __m1, __m64 __m2)
  665. {
  666. return __builtin_ia32_pxor (__m1, __m2);
  667. }
  668. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  669. _m_pxor (__m64 __m1, __m64 __m2)
  670. {
  671. return _mm_xor_si64 (__m1, __m2);
  672. }
  673. /* Compare eight 8-bit values. The result of the comparison is 0xFF if the
  674. test is true and zero if false. */
  675. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  676. _mm_cmpeq_pi8 (__m64 __m1, __m64 __m2)
  677. {
  678. return (__m64) __builtin_ia32_pcmpeqb ((__v8qi)__m1, (__v8qi)__m2);
  679. }
  680. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  681. _m_pcmpeqb (__m64 __m1, __m64 __m2)
  682. {
  683. return _mm_cmpeq_pi8 (__m1, __m2);
  684. }
  685. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  686. _mm_cmpgt_pi8 (__m64 __m1, __m64 __m2)
  687. {
  688. return (__m64) __builtin_ia32_pcmpgtb ((__v8qi)__m1, (__v8qi)__m2);
  689. }
  690. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  691. _m_pcmpgtb (__m64 __m1, __m64 __m2)
  692. {
  693. return _mm_cmpgt_pi8 (__m1, __m2);
  694. }
  695. /* Compare four 16-bit values. The result of the comparison is 0xFFFF if
  696. the test is true and zero if false. */
  697. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  698. _mm_cmpeq_pi16 (__m64 __m1, __m64 __m2)
  699. {
  700. return (__m64) __builtin_ia32_pcmpeqw ((__v4hi)__m1, (__v4hi)__m2);
  701. }
  702. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  703. _m_pcmpeqw (__m64 __m1, __m64 __m2)
  704. {
  705. return _mm_cmpeq_pi16 (__m1, __m2);
  706. }
  707. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  708. _mm_cmpgt_pi16 (__m64 __m1, __m64 __m2)
  709. {
  710. return (__m64) __builtin_ia32_pcmpgtw ((__v4hi)__m1, (__v4hi)__m2);
  711. }
  712. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  713. _m_pcmpgtw (__m64 __m1, __m64 __m2)
  714. {
  715. return _mm_cmpgt_pi16 (__m1, __m2);
  716. }
  717. /* Compare two 32-bit values. The result of the comparison is 0xFFFFFFFF if
  718. the test is true and zero if false. */
  719. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  720. _mm_cmpeq_pi32 (__m64 __m1, __m64 __m2)
  721. {
  722. return (__m64) __builtin_ia32_pcmpeqd ((__v2si)__m1, (__v2si)__m2);
  723. }
  724. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  725. _m_pcmpeqd (__m64 __m1, __m64 __m2)
  726. {
  727. return _mm_cmpeq_pi32 (__m1, __m2);
  728. }
  729. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  730. _mm_cmpgt_pi32 (__m64 __m1, __m64 __m2)
  731. {
  732. return (__m64) __builtin_ia32_pcmpgtd ((__v2si)__m1, (__v2si)__m2);
  733. }
  734. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  735. _m_pcmpgtd (__m64 __m1, __m64 __m2)
  736. {
  737. return _mm_cmpgt_pi32 (__m1, __m2);
  738. }
  739. /* Creates a 64-bit zero. */
  740. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  741. _mm_setzero_si64 (void)
  742. {
  743. return (__m64)0LL;
  744. }
  745. /* Creates a vector of two 32-bit values; I0 is least significant. */
  746. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  747. _mm_set_pi32 (int __i1, int __i0)
  748. {
  749. return (__m64) __builtin_ia32_vec_init_v2si (__i0, __i1);
  750. }
  751. /* Creates a vector of four 16-bit values; W0 is least significant. */
  752. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  753. _mm_set_pi16 (short __w3, short __w2, short __w1, short __w0)
  754. {
  755. return (__m64) __builtin_ia32_vec_init_v4hi (__w0, __w1, __w2, __w3);
  756. }
  757. /* Creates a vector of eight 8-bit values; B0 is least significant. */
  758. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  759. _mm_set_pi8 (char __b7, char __b6, char __b5, char __b4,
  760. char __b3, char __b2, char __b1, char __b0)
  761. {
  762. return (__m64) __builtin_ia32_vec_init_v8qi (__b0, __b1, __b2, __b3,
  763. __b4, __b5, __b6, __b7);
  764. }
  765. /* Similar, but with the arguments in reverse order. */
  766. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  767. _mm_setr_pi32 (int __i0, int __i1)
  768. {
  769. return _mm_set_pi32 (__i1, __i0);
  770. }
  771. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  772. _mm_setr_pi16 (short __w0, short __w1, short __w2, short __w3)
  773. {
  774. return _mm_set_pi16 (__w3, __w2, __w1, __w0);
  775. }
  776. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  777. _mm_setr_pi8 (char __b0, char __b1, char __b2, char __b3,
  778. char __b4, char __b5, char __b6, char __b7)
  779. {
  780. return _mm_set_pi8 (__b7, __b6, __b5, __b4, __b3, __b2, __b1, __b0);
  781. }
  782. /* Creates a vector of two 32-bit values, both elements containing I. */
  783. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  784. _mm_set1_pi32 (int __i)
  785. {
  786. return _mm_set_pi32 (__i, __i);
  787. }
  788. /* Creates a vector of four 16-bit values, all elements containing W. */
  789. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  790. _mm_set1_pi16 (short __w)
  791. {
  792. return _mm_set_pi16 (__w, __w, __w, __w);
  793. }
  794. /* Creates a vector of eight 8-bit values, all elements containing B. */
  795. extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
  796. _mm_set1_pi8 (char __b)
  797. {
  798. return _mm_set_pi8 (__b, __b, __b, __b, __b, __b, __b, __b);
  799. }
  800. #ifdef __DISABLE_MMX__
  801. #undef __DISABLE_MMX__
  802. #pragma GCC pop_options
  803. #endif /* __DISABLE_MMX__ */
  804. #endif /* _MMINTRIN_H_INCLUDED */