xmmintrin.h 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012
  1. /*===---- xmmintrin.h - SSE intrinsics -------------------------------------===
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. *
  21. *===-----------------------------------------------------------------------===
  22. */
  23. #ifndef __XMMINTRIN_H
  24. #define __XMMINTRIN_H
  25. #include <mmintrin.h>
  26. typedef int __v4si __attribute__((__vector_size__(16)));
  27. typedef float __v4sf __attribute__((__vector_size__(16)));
  28. typedef float __m128 __attribute__((__vector_size__(16)));
  29. /* Unsigned types */
  30. typedef unsigned int __v4su __attribute__((__vector_size__(16)));
  31. /* This header should only be included in a hosted environment as it depends on
  32. * a standard library to provide allocation routines. */
  33. #if __STDC_HOSTED__
  34. #include <mm_malloc.h>
  35. #endif
  36. /* Define the default attributes for the functions in this file. */
  37. #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse"), __min_vector_width__(128)))
  38. #define __DEFAULT_FN_ATTRS_MMX __attribute__((__always_inline__, __nodebug__, __target__("mmx,sse"), __min_vector_width__(64)))
  39. /// Adds the 32-bit float values in the low-order bits of the operands.
  40. ///
  41. /// \headerfile <x86intrin.h>
  42. ///
  43. /// This intrinsic corresponds to the <c> VADDSS / ADDSS </c> instructions.
  44. ///
  45. /// \param __a
  46. /// A 128-bit vector of [4 x float] containing one of the source operands.
  47. /// The lower 32 bits of this operand are used in the calculation.
  48. /// \param __b
  49. /// A 128-bit vector of [4 x float] containing one of the source operands.
  50. /// The lower 32 bits of this operand are used in the calculation.
  51. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the sum
  52. /// of the lower 32 bits of both operands. The upper 96 bits are copied from
  53. /// the upper 96 bits of the first source operand.
  54. static __inline__ __m128 __DEFAULT_FN_ATTRS
  55. _mm_add_ss(__m128 __a, __m128 __b)
  56. {
  57. __a[0] += __b[0];
  58. return __a;
  59. }
  60. /// Adds two 128-bit vectors of [4 x float], and returns the results of
  61. /// the addition.
  62. ///
  63. /// \headerfile <x86intrin.h>
  64. ///
  65. /// This intrinsic corresponds to the <c> VADDPS / ADDPS </c> instructions.
  66. ///
  67. /// \param __a
  68. /// A 128-bit vector of [4 x float] containing one of the source operands.
  69. /// \param __b
  70. /// A 128-bit vector of [4 x float] containing one of the source operands.
  71. /// \returns A 128-bit vector of [4 x float] containing the sums of both
  72. /// operands.
  73. static __inline__ __m128 __DEFAULT_FN_ATTRS
  74. _mm_add_ps(__m128 __a, __m128 __b)
  75. {
  76. return (__m128)((__v4sf)__a + (__v4sf)__b);
  77. }
  78. /// Subtracts the 32-bit float value in the low-order bits of the second
  79. /// operand from the corresponding value in the first operand.
  80. ///
  81. /// \headerfile <x86intrin.h>
  82. ///
  83. /// This intrinsic corresponds to the <c> VSUBSS / SUBSS </c> instructions.
  84. ///
  85. /// \param __a
  86. /// A 128-bit vector of [4 x float] containing the minuend. The lower 32 bits
  87. /// of this operand are used in the calculation.
  88. /// \param __b
  89. /// A 128-bit vector of [4 x float] containing the subtrahend. The lower 32
  90. /// bits of this operand are used in the calculation.
  91. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
  92. /// difference of the lower 32 bits of both operands. The upper 96 bits are
  93. /// copied from the upper 96 bits of the first source operand.
  94. static __inline__ __m128 __DEFAULT_FN_ATTRS
  95. _mm_sub_ss(__m128 __a, __m128 __b)
  96. {
  97. __a[0] -= __b[0];
  98. return __a;
  99. }
  100. /// Subtracts each of the values of the second operand from the first
  101. /// operand, both of which are 128-bit vectors of [4 x float] and returns
  102. /// the results of the subtraction.
  103. ///
  104. /// \headerfile <x86intrin.h>
  105. ///
  106. /// This intrinsic corresponds to the <c> VSUBPS / SUBPS </c> instructions.
  107. ///
  108. /// \param __a
  109. /// A 128-bit vector of [4 x float] containing the minuend.
  110. /// \param __b
  111. /// A 128-bit vector of [4 x float] containing the subtrahend.
  112. /// \returns A 128-bit vector of [4 x float] containing the differences between
  113. /// both operands.
  114. static __inline__ __m128 __DEFAULT_FN_ATTRS
  115. _mm_sub_ps(__m128 __a, __m128 __b)
  116. {
  117. return (__m128)((__v4sf)__a - (__v4sf)__b);
  118. }
  119. /// Multiplies two 32-bit float values in the low-order bits of the
  120. /// operands.
  121. ///
  122. /// \headerfile <x86intrin.h>
  123. ///
  124. /// This intrinsic corresponds to the <c> VMULSS / MULSS </c> instructions.
  125. ///
  126. /// \param __a
  127. /// A 128-bit vector of [4 x float] containing one of the source operands.
  128. /// The lower 32 bits of this operand are used in the calculation.
  129. /// \param __b
  130. /// A 128-bit vector of [4 x float] containing one of the source operands.
  131. /// The lower 32 bits of this operand are used in the calculation.
  132. /// \returns A 128-bit vector of [4 x float] containing the product of the lower
  133. /// 32 bits of both operands. The upper 96 bits are copied from the upper 96
  134. /// bits of the first source operand.
  135. static __inline__ __m128 __DEFAULT_FN_ATTRS
  136. _mm_mul_ss(__m128 __a, __m128 __b)
  137. {
  138. __a[0] *= __b[0];
  139. return __a;
  140. }
  141. /// Multiplies two 128-bit vectors of [4 x float] and returns the
  142. /// results of the multiplication.
  143. ///
  144. /// \headerfile <x86intrin.h>
  145. ///
  146. /// This intrinsic corresponds to the <c> VMULPS / MULPS </c> instructions.
  147. ///
  148. /// \param __a
  149. /// A 128-bit vector of [4 x float] containing one of the source operands.
  150. /// \param __b
  151. /// A 128-bit vector of [4 x float] containing one of the source operands.
  152. /// \returns A 128-bit vector of [4 x float] containing the products of both
  153. /// operands.
  154. static __inline__ __m128 __DEFAULT_FN_ATTRS
  155. _mm_mul_ps(__m128 __a, __m128 __b)
  156. {
  157. return (__m128)((__v4sf)__a * (__v4sf)__b);
  158. }
  159. /// Divides the value in the low-order 32 bits of the first operand by
  160. /// the corresponding value in the second operand.
  161. ///
  162. /// \headerfile <x86intrin.h>
  163. ///
  164. /// This intrinsic corresponds to the <c> VDIVSS / DIVSS </c> instructions.
  165. ///
  166. /// \param __a
  167. /// A 128-bit vector of [4 x float] containing the dividend. The lower 32
  168. /// bits of this operand are used in the calculation.
  169. /// \param __b
  170. /// A 128-bit vector of [4 x float] containing the divisor. The lower 32 bits
  171. /// of this operand are used in the calculation.
  172. /// \returns A 128-bit vector of [4 x float] containing the quotients of the
  173. /// lower 32 bits of both operands. The upper 96 bits are copied from the
  174. /// upper 96 bits of the first source operand.
  175. static __inline__ __m128 __DEFAULT_FN_ATTRS
  176. _mm_div_ss(__m128 __a, __m128 __b)
  177. {
  178. __a[0] /= __b[0];
  179. return __a;
  180. }
  181. /// Divides two 128-bit vectors of [4 x float].
  182. ///
  183. /// \headerfile <x86intrin.h>
  184. ///
  185. /// This intrinsic corresponds to the <c> VDIVPS / DIVPS </c> instructions.
  186. ///
  187. /// \param __a
  188. /// A 128-bit vector of [4 x float] containing the dividend.
  189. /// \param __b
  190. /// A 128-bit vector of [4 x float] containing the divisor.
  191. /// \returns A 128-bit vector of [4 x float] containing the quotients of both
  192. /// operands.
  193. static __inline__ __m128 __DEFAULT_FN_ATTRS
  194. _mm_div_ps(__m128 __a, __m128 __b)
  195. {
  196. return (__m128)((__v4sf)__a / (__v4sf)__b);
  197. }
  198. /// Calculates the square root of the value stored in the low-order bits
  199. /// of a 128-bit vector of [4 x float].
  200. ///
  201. /// \headerfile <x86intrin.h>
  202. ///
  203. /// This intrinsic corresponds to the <c> VSQRTSS / SQRTSS </c> instructions.
  204. ///
  205. /// \param __a
  206. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  207. /// used in the calculation.
  208. /// \returns A 128-bit vector of [4 x float] containing the square root of the
  209. /// value in the low-order bits of the operand.
  210. static __inline__ __m128 __DEFAULT_FN_ATTRS
  211. _mm_sqrt_ss(__m128 __a)
  212. {
  213. return (__m128)__builtin_ia32_sqrtss((__v4sf)__a);
  214. }
  215. /// Calculates the square roots of the values stored in a 128-bit vector
  216. /// of [4 x float].
  217. ///
  218. /// \headerfile <x86intrin.h>
  219. ///
  220. /// This intrinsic corresponds to the <c> VSQRTPS / SQRTPS </c> instructions.
  221. ///
  222. /// \param __a
  223. /// A 128-bit vector of [4 x float].
  224. /// \returns A 128-bit vector of [4 x float] containing the square roots of the
  225. /// values in the operand.
  226. static __inline__ __m128 __DEFAULT_FN_ATTRS
  227. _mm_sqrt_ps(__m128 __a)
  228. {
  229. return __builtin_ia32_sqrtps((__v4sf)__a);
  230. }
  231. /// Calculates the approximate reciprocal of the value stored in the
  232. /// low-order bits of a 128-bit vector of [4 x float].
  233. ///
  234. /// \headerfile <x86intrin.h>
  235. ///
  236. /// This intrinsic corresponds to the <c> VRCPSS / RCPSS </c> instructions.
  237. ///
  238. /// \param __a
  239. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  240. /// used in the calculation.
  241. /// \returns A 128-bit vector of [4 x float] containing the approximate
  242. /// reciprocal of the value in the low-order bits of the operand.
  243. static __inline__ __m128 __DEFAULT_FN_ATTRS
  244. _mm_rcp_ss(__m128 __a)
  245. {
  246. return (__m128)__builtin_ia32_rcpss((__v4sf)__a);
  247. }
  248. /// Calculates the approximate reciprocals of the values stored in a
  249. /// 128-bit vector of [4 x float].
  250. ///
  251. /// \headerfile <x86intrin.h>
  252. ///
  253. /// This intrinsic corresponds to the <c> VRCPPS / RCPPS </c> instructions.
  254. ///
  255. /// \param __a
  256. /// A 128-bit vector of [4 x float].
  257. /// \returns A 128-bit vector of [4 x float] containing the approximate
  258. /// reciprocals of the values in the operand.
  259. static __inline__ __m128 __DEFAULT_FN_ATTRS
  260. _mm_rcp_ps(__m128 __a)
  261. {
  262. return (__m128)__builtin_ia32_rcpps((__v4sf)__a);
  263. }
  264. /// Calculates the approximate reciprocal of the square root of the value
  265. /// stored in the low-order bits of a 128-bit vector of [4 x float].
  266. ///
  267. /// \headerfile <x86intrin.h>
  268. ///
  269. /// This intrinsic corresponds to the <c> VRSQRTSS / RSQRTSS </c> instructions.
  270. ///
  271. /// \param __a
  272. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  273. /// used in the calculation.
  274. /// \returns A 128-bit vector of [4 x float] containing the approximate
  275. /// reciprocal of the square root of the value in the low-order bits of the
  276. /// operand.
  277. static __inline__ __m128 __DEFAULT_FN_ATTRS
  278. _mm_rsqrt_ss(__m128 __a)
  279. {
  280. return __builtin_ia32_rsqrtss((__v4sf)__a);
  281. }
  282. /// Calculates the approximate reciprocals of the square roots of the
  283. /// values stored in a 128-bit vector of [4 x float].
  284. ///
  285. /// \headerfile <x86intrin.h>
  286. ///
  287. /// This intrinsic corresponds to the <c> VRSQRTPS / RSQRTPS </c> instructions.
  288. ///
  289. /// \param __a
  290. /// A 128-bit vector of [4 x float].
  291. /// \returns A 128-bit vector of [4 x float] containing the approximate
  292. /// reciprocals of the square roots of the values in the operand.
  293. static __inline__ __m128 __DEFAULT_FN_ATTRS
  294. _mm_rsqrt_ps(__m128 __a)
  295. {
  296. return __builtin_ia32_rsqrtps((__v4sf)__a);
  297. }
  298. /// Compares two 32-bit float values in the low-order bits of both
  299. /// operands and returns the lesser value in the low-order bits of the
  300. /// vector of [4 x float].
  301. ///
  302. /// \headerfile <x86intrin.h>
  303. ///
  304. /// This intrinsic corresponds to the <c> VMINSS / MINSS </c> instructions.
  305. ///
  306. /// \param __a
  307. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  308. /// 32 bits of this operand are used in the comparison.
  309. /// \param __b
  310. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  311. /// 32 bits of this operand are used in the comparison.
  312. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
  313. /// minimum value between both operands. The upper 96 bits are copied from
  314. /// the upper 96 bits of the first source operand.
  315. static __inline__ __m128 __DEFAULT_FN_ATTRS
  316. _mm_min_ss(__m128 __a, __m128 __b)
  317. {
  318. return __builtin_ia32_minss((__v4sf)__a, (__v4sf)__b);
  319. }
  320. /// Compares two 128-bit vectors of [4 x float] and returns the lesser
  321. /// of each pair of values.
  322. ///
  323. /// \headerfile <x86intrin.h>
  324. ///
  325. /// This intrinsic corresponds to the <c> VMINPS / MINPS </c> instructions.
  326. ///
  327. /// \param __a
  328. /// A 128-bit vector of [4 x float] containing one of the operands.
  329. /// \param __b
  330. /// A 128-bit vector of [4 x float] containing one of the operands.
  331. /// \returns A 128-bit vector of [4 x float] containing the minimum values
  332. /// between both operands.
  333. static __inline__ __m128 __DEFAULT_FN_ATTRS
  334. _mm_min_ps(__m128 __a, __m128 __b)
  335. {
  336. return __builtin_ia32_minps((__v4sf)__a, (__v4sf)__b);
  337. }
  338. /// Compares two 32-bit float values in the low-order bits of both
  339. /// operands and returns the greater value in the low-order bits of a 128-bit
  340. /// vector of [4 x float].
  341. ///
  342. /// \headerfile <x86intrin.h>
  343. ///
  344. /// This intrinsic corresponds to the <c> VMAXSS / MAXSS </c> instructions.
  345. ///
  346. /// \param __a
  347. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  348. /// 32 bits of this operand are used in the comparison.
  349. /// \param __b
  350. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  351. /// 32 bits of this operand are used in the comparison.
  352. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
  353. /// maximum value between both operands. The upper 96 bits are copied from
  354. /// the upper 96 bits of the first source operand.
  355. static __inline__ __m128 __DEFAULT_FN_ATTRS
  356. _mm_max_ss(__m128 __a, __m128 __b)
  357. {
  358. return __builtin_ia32_maxss((__v4sf)__a, (__v4sf)__b);
  359. }
  360. /// Compares two 128-bit vectors of [4 x float] and returns the greater
  361. /// of each pair of values.
  362. ///
  363. /// \headerfile <x86intrin.h>
  364. ///
  365. /// This intrinsic corresponds to the <c> VMAXPS / MAXPS </c> instructions.
  366. ///
  367. /// \param __a
  368. /// A 128-bit vector of [4 x float] containing one of the operands.
  369. /// \param __b
  370. /// A 128-bit vector of [4 x float] containing one of the operands.
  371. /// \returns A 128-bit vector of [4 x float] containing the maximum values
  372. /// between both operands.
  373. static __inline__ __m128 __DEFAULT_FN_ATTRS
  374. _mm_max_ps(__m128 __a, __m128 __b)
  375. {
  376. return __builtin_ia32_maxps((__v4sf)__a, (__v4sf)__b);
  377. }
  378. /// Performs a bitwise AND of two 128-bit vectors of [4 x float].
  379. ///
  380. /// \headerfile <x86intrin.h>
  381. ///
  382. /// This intrinsic corresponds to the <c> VANDPS / ANDPS </c> instructions.
  383. ///
  384. /// \param __a
  385. /// A 128-bit vector containing one of the source operands.
  386. /// \param __b
  387. /// A 128-bit vector containing one of the source operands.
  388. /// \returns A 128-bit vector of [4 x float] containing the bitwise AND of the
  389. /// values between both operands.
  390. static __inline__ __m128 __DEFAULT_FN_ATTRS
  391. _mm_and_ps(__m128 __a, __m128 __b)
  392. {
  393. return (__m128)((__v4su)__a & (__v4su)__b);
  394. }
  395. /// Performs a bitwise AND of two 128-bit vectors of [4 x float], using
  396. /// the one's complement of the values contained in the first source
  397. /// operand.
  398. ///
  399. /// \headerfile <x86intrin.h>
  400. ///
  401. /// This intrinsic corresponds to the <c> VANDNPS / ANDNPS </c> instructions.
  402. ///
  403. /// \param __a
  404. /// A 128-bit vector of [4 x float] containing the first source operand. The
  405. /// one's complement of this value is used in the bitwise AND.
  406. /// \param __b
  407. /// A 128-bit vector of [4 x float] containing the second source operand.
  408. /// \returns A 128-bit vector of [4 x float] containing the bitwise AND of the
  409. /// one's complement of the first operand and the values in the second
  410. /// operand.
  411. static __inline__ __m128 __DEFAULT_FN_ATTRS
  412. _mm_andnot_ps(__m128 __a, __m128 __b)
  413. {
  414. return (__m128)(~(__v4su)__a & (__v4su)__b);
  415. }
  416. /// Performs a bitwise OR of two 128-bit vectors of [4 x float].
  417. ///
  418. /// \headerfile <x86intrin.h>
  419. ///
  420. /// This intrinsic corresponds to the <c> VORPS / ORPS </c> instructions.
  421. ///
  422. /// \param __a
  423. /// A 128-bit vector of [4 x float] containing one of the source operands.
  424. /// \param __b
  425. /// A 128-bit vector of [4 x float] containing one of the source operands.
  426. /// \returns A 128-bit vector of [4 x float] containing the bitwise OR of the
  427. /// values between both operands.
  428. static __inline__ __m128 __DEFAULT_FN_ATTRS
  429. _mm_or_ps(__m128 __a, __m128 __b)
  430. {
  431. return (__m128)((__v4su)__a | (__v4su)__b);
  432. }
  433. /// Performs a bitwise exclusive OR of two 128-bit vectors of
  434. /// [4 x float].
  435. ///
  436. /// \headerfile <x86intrin.h>
  437. ///
  438. /// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instructions.
  439. ///
  440. /// \param __a
  441. /// A 128-bit vector of [4 x float] containing one of the source operands.
  442. /// \param __b
  443. /// A 128-bit vector of [4 x float] containing one of the source operands.
  444. /// \returns A 128-bit vector of [4 x float] containing the bitwise exclusive OR
  445. /// of the values between both operands.
  446. static __inline__ __m128 __DEFAULT_FN_ATTRS
  447. _mm_xor_ps(__m128 __a, __m128 __b)
  448. {
  449. return (__m128)((__v4su)__a ^ (__v4su)__b);
  450. }
  451. /// Compares two 32-bit float values in the low-order bits of both
  452. /// operands for equality and returns the result of the comparison in the
  453. /// low-order bits of a vector [4 x float].
  454. ///
  455. /// \headerfile <x86intrin.h>
  456. ///
  457. /// This intrinsic corresponds to the <c> VCMPEQSS / CMPEQSS </c> instructions.
  458. ///
  459. /// \param __a
  460. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  461. /// 32 bits of this operand are used in the comparison.
  462. /// \param __b
  463. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  464. /// 32 bits of this operand are used in the comparison.
  465. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  466. /// in the low-order bits.
  467. static __inline__ __m128 __DEFAULT_FN_ATTRS
  468. _mm_cmpeq_ss(__m128 __a, __m128 __b)
  469. {
  470. return (__m128)__builtin_ia32_cmpeqss((__v4sf)__a, (__v4sf)__b);
  471. }
  472. /// Compares each of the corresponding 32-bit float values of the
  473. /// 128-bit vectors of [4 x float] for equality.
  474. ///
  475. /// \headerfile <x86intrin.h>
  476. ///
  477. /// This intrinsic corresponds to the <c> VCMPEQPS / CMPEQPS </c> instructions.
  478. ///
  479. /// \param __a
  480. /// A 128-bit vector of [4 x float].
  481. /// \param __b
  482. /// A 128-bit vector of [4 x float].
  483. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  484. static __inline__ __m128 __DEFAULT_FN_ATTRS
  485. _mm_cmpeq_ps(__m128 __a, __m128 __b)
  486. {
  487. return (__m128)__builtin_ia32_cmpeqps((__v4sf)__a, (__v4sf)__b);
  488. }
  489. /// Compares two 32-bit float values in the low-order bits of both
  490. /// operands to determine if the value in the first operand is less than the
  491. /// corresponding value in the second operand and returns the result of the
  492. /// comparison in the low-order bits of a vector of [4 x float].
  493. ///
  494. /// \headerfile <x86intrin.h>
  495. ///
  496. /// This intrinsic corresponds to the <c> VCMPLTSS / CMPLTSS </c> instructions.
  497. ///
  498. /// \param __a
  499. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  500. /// 32 bits of this operand are used in the comparison.
  501. /// \param __b
  502. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  503. /// 32 bits of this operand are used in the comparison.
  504. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  505. /// in the low-order bits.
  506. static __inline__ __m128 __DEFAULT_FN_ATTRS
  507. _mm_cmplt_ss(__m128 __a, __m128 __b)
  508. {
  509. return (__m128)__builtin_ia32_cmpltss((__v4sf)__a, (__v4sf)__b);
  510. }
  511. /// Compares each of the corresponding 32-bit float values of the
  512. /// 128-bit vectors of [4 x float] to determine if the values in the first
  513. /// operand are less than those in the second operand.
  514. ///
  515. /// \headerfile <x86intrin.h>
  516. ///
  517. /// This intrinsic corresponds to the <c> VCMPLTPS / CMPLTPS </c> instructions.
  518. ///
  519. /// \param __a
  520. /// A 128-bit vector of [4 x float].
  521. /// \param __b
  522. /// A 128-bit vector of [4 x float].
  523. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  524. static __inline__ __m128 __DEFAULT_FN_ATTRS
  525. _mm_cmplt_ps(__m128 __a, __m128 __b)
  526. {
  527. return (__m128)__builtin_ia32_cmpltps((__v4sf)__a, (__v4sf)__b);
  528. }
  529. /// Compares two 32-bit float values in the low-order bits of both
  530. /// operands to determine if the value in the first operand is less than or
  531. /// equal to the corresponding value in the second operand and returns the
  532. /// result of the comparison in the low-order bits of a vector of
  533. /// [4 x float].
  534. ///
  535. /// \headerfile <x86intrin.h>
  536. ///
  537. /// This intrinsic corresponds to the <c> VCMPLESS / CMPLESS </c> instructions.
  538. ///
  539. /// \param __a
  540. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  541. /// 32 bits of this operand are used in the comparison.
  542. /// \param __b
  543. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  544. /// 32 bits of this operand are used in the comparison.
  545. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  546. /// in the low-order bits.
  547. static __inline__ __m128 __DEFAULT_FN_ATTRS
  548. _mm_cmple_ss(__m128 __a, __m128 __b)
  549. {
  550. return (__m128)__builtin_ia32_cmpless((__v4sf)__a, (__v4sf)__b);
  551. }
  552. /// Compares each of the corresponding 32-bit float values of the
  553. /// 128-bit vectors of [4 x float] to determine if the values in the first
  554. /// operand are less than or equal to those in the second operand.
  555. ///
  556. /// \headerfile <x86intrin.h>
  557. ///
  558. /// This intrinsic corresponds to the <c> VCMPLEPS / CMPLEPS </c> instructions.
  559. ///
  560. /// \param __a
  561. /// A 128-bit vector of [4 x float].
  562. /// \param __b
  563. /// A 128-bit vector of [4 x float].
  564. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  565. static __inline__ __m128 __DEFAULT_FN_ATTRS
  566. _mm_cmple_ps(__m128 __a, __m128 __b)
  567. {
  568. return (__m128)__builtin_ia32_cmpleps((__v4sf)__a, (__v4sf)__b);
  569. }
  570. /// Compares two 32-bit float values in the low-order bits of both
  571. /// operands to determine if the value in the first operand is greater than
  572. /// the corresponding value in the second operand and returns the result of
  573. /// the comparison in the low-order bits of a vector of [4 x float].
  574. ///
  575. /// \headerfile <x86intrin.h>
  576. ///
  577. /// This intrinsic corresponds to the <c> VCMPLTSS / CMPLTSS </c> instructions.
  578. ///
  579. /// \param __a
  580. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  581. /// 32 bits of this operand are used in the comparison.
  582. /// \param __b
  583. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  584. /// 32 bits of this operand are used in the comparison.
  585. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  586. /// in the low-order bits.
  587. static __inline__ __m128 __DEFAULT_FN_ATTRS
  588. _mm_cmpgt_ss(__m128 __a, __m128 __b)
  589. {
  590. return (__m128)__builtin_shufflevector((__v4sf)__a,
  591. (__v4sf)__builtin_ia32_cmpltss((__v4sf)__b, (__v4sf)__a),
  592. 4, 1, 2, 3);
  593. }
  594. /// Compares each of the corresponding 32-bit float values of the
  595. /// 128-bit vectors of [4 x float] to determine if the values in the first
  596. /// operand are greater than those in the second operand.
  597. ///
  598. /// \headerfile <x86intrin.h>
  599. ///
  600. /// This intrinsic corresponds to the <c> VCMPLTPS / CMPLTPS </c> instructions.
  601. ///
  602. /// \param __a
  603. /// A 128-bit vector of [4 x float].
  604. /// \param __b
  605. /// A 128-bit vector of [4 x float].
  606. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  607. static __inline__ __m128 __DEFAULT_FN_ATTRS
  608. _mm_cmpgt_ps(__m128 __a, __m128 __b)
  609. {
  610. return (__m128)__builtin_ia32_cmpltps((__v4sf)__b, (__v4sf)__a);
  611. }
  612. /// Compares two 32-bit float values in the low-order bits of both
  613. /// operands to determine if the value in the first operand is greater than
  614. /// or equal to the corresponding value in the second operand and returns
  615. /// the result of the comparison in the low-order bits of a vector of
  616. /// [4 x float].
  617. ///
  618. /// \headerfile <x86intrin.h>
  619. ///
  620. /// This intrinsic corresponds to the <c> VCMPLESS / CMPLESS </c> instructions.
  621. ///
  622. /// \param __a
  623. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  624. /// 32 bits of this operand are used in the comparison.
  625. /// \param __b
  626. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  627. /// 32 bits of this operand are used in the comparison.
  628. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  629. /// in the low-order bits.
  630. static __inline__ __m128 __DEFAULT_FN_ATTRS
  631. _mm_cmpge_ss(__m128 __a, __m128 __b)
  632. {
  633. return (__m128)__builtin_shufflevector((__v4sf)__a,
  634. (__v4sf)__builtin_ia32_cmpless((__v4sf)__b, (__v4sf)__a),
  635. 4, 1, 2, 3);
  636. }
  637. /// Compares each of the corresponding 32-bit float values of the
  638. /// 128-bit vectors of [4 x float] to determine if the values in the first
  639. /// operand are greater than or equal to those in the second operand.
  640. ///
  641. /// \headerfile <x86intrin.h>
  642. ///
  643. /// This intrinsic corresponds to the <c> VCMPLEPS / CMPLEPS </c> instructions.
  644. ///
  645. /// \param __a
  646. /// A 128-bit vector of [4 x float].
  647. /// \param __b
  648. /// A 128-bit vector of [4 x float].
  649. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  650. static __inline__ __m128 __DEFAULT_FN_ATTRS
  651. _mm_cmpge_ps(__m128 __a, __m128 __b)
  652. {
  653. return (__m128)__builtin_ia32_cmpleps((__v4sf)__b, (__v4sf)__a);
  654. }
  655. /// Compares two 32-bit float values in the low-order bits of both
  656. /// operands for inequality and returns the result of the comparison in the
  657. /// low-order bits of a vector of [4 x float].
  658. ///
  659. /// \headerfile <x86intrin.h>
  660. ///
  661. /// This intrinsic corresponds to the <c> VCMPNEQSS / CMPNEQSS </c>
  662. /// instructions.
  663. ///
  664. /// \param __a
  665. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  666. /// 32 bits of this operand are used in the comparison.
  667. /// \param __b
  668. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  669. /// 32 bits of this operand are used in the comparison.
  670. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  671. /// in the low-order bits.
  672. static __inline__ __m128 __DEFAULT_FN_ATTRS
  673. _mm_cmpneq_ss(__m128 __a, __m128 __b)
  674. {
  675. return (__m128)__builtin_ia32_cmpneqss((__v4sf)__a, (__v4sf)__b);
  676. }
  677. /// Compares each of the corresponding 32-bit float values of the
  678. /// 128-bit vectors of [4 x float] for inequality.
  679. ///
  680. /// \headerfile <x86intrin.h>
  681. ///
  682. /// This intrinsic corresponds to the <c> VCMPNEQPS / CMPNEQPS </c>
  683. /// instructions.
  684. ///
  685. /// \param __a
  686. /// A 128-bit vector of [4 x float].
  687. /// \param __b
  688. /// A 128-bit vector of [4 x float].
  689. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  690. static __inline__ __m128 __DEFAULT_FN_ATTRS
  691. _mm_cmpneq_ps(__m128 __a, __m128 __b)
  692. {
  693. return (__m128)__builtin_ia32_cmpneqps((__v4sf)__a, (__v4sf)__b);
  694. }
  695. /// Compares two 32-bit float values in the low-order bits of both
  696. /// operands to determine if the value in the first operand is not less than
  697. /// the corresponding value in the second operand and returns the result of
  698. /// the comparison in the low-order bits of a vector of [4 x float].
  699. ///
  700. /// \headerfile <x86intrin.h>
  701. ///
  702. /// This intrinsic corresponds to the <c> VCMPNLTSS / CMPNLTSS </c>
  703. /// instructions.
  704. ///
  705. /// \param __a
  706. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  707. /// 32 bits of this operand are used in the comparison.
  708. /// \param __b
  709. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  710. /// 32 bits of this operand are used in the comparison.
  711. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  712. /// in the low-order bits.
  713. static __inline__ __m128 __DEFAULT_FN_ATTRS
  714. _mm_cmpnlt_ss(__m128 __a, __m128 __b)
  715. {
  716. return (__m128)__builtin_ia32_cmpnltss((__v4sf)__a, (__v4sf)__b);
  717. }
  718. /// Compares each of the corresponding 32-bit float values of the
  719. /// 128-bit vectors of [4 x float] to determine if the values in the first
  720. /// operand are not less than those in the second operand.
  721. ///
  722. /// \headerfile <x86intrin.h>
  723. ///
  724. /// This intrinsic corresponds to the <c> VCMPNLTPS / CMPNLTPS </c>
  725. /// instructions.
  726. ///
  727. /// \param __a
  728. /// A 128-bit vector of [4 x float].
  729. /// \param __b
  730. /// A 128-bit vector of [4 x float].
  731. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  732. static __inline__ __m128 __DEFAULT_FN_ATTRS
  733. _mm_cmpnlt_ps(__m128 __a, __m128 __b)
  734. {
  735. return (__m128)__builtin_ia32_cmpnltps((__v4sf)__a, (__v4sf)__b);
  736. }
  737. /// Compares two 32-bit float values in the low-order bits of both
  738. /// operands to determine if the value in the first operand is not less than
  739. /// or equal to the corresponding value in the second operand and returns
  740. /// the result of the comparison in the low-order bits of a vector of
  741. /// [4 x float].
  742. ///
  743. /// \headerfile <x86intrin.h>
  744. ///
  745. /// This intrinsic corresponds to the <c> VCMPNLESS / CMPNLESS </c>
  746. /// instructions.
  747. ///
  748. /// \param __a
  749. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  750. /// 32 bits of this operand are used in the comparison.
  751. /// \param __b
  752. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  753. /// 32 bits of this operand are used in the comparison.
  754. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  755. /// in the low-order bits.
  756. static __inline__ __m128 __DEFAULT_FN_ATTRS
  757. _mm_cmpnle_ss(__m128 __a, __m128 __b)
  758. {
  759. return (__m128)__builtin_ia32_cmpnless((__v4sf)__a, (__v4sf)__b);
  760. }
  761. /// Compares each of the corresponding 32-bit float values of the
  762. /// 128-bit vectors of [4 x float] to determine if the values in the first
  763. /// operand are not less than or equal to those in the second operand.
  764. ///
  765. /// \headerfile <x86intrin.h>
  766. ///
  767. /// This intrinsic corresponds to the <c> VCMPNLEPS / CMPNLEPS </c>
  768. /// instructions.
  769. ///
  770. /// \param __a
  771. /// A 128-bit vector of [4 x float].
  772. /// \param __b
  773. /// A 128-bit vector of [4 x float].
  774. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  775. static __inline__ __m128 __DEFAULT_FN_ATTRS
  776. _mm_cmpnle_ps(__m128 __a, __m128 __b)
  777. {
  778. return (__m128)__builtin_ia32_cmpnleps((__v4sf)__a, (__v4sf)__b);
  779. }
  780. /// Compares two 32-bit float values in the low-order bits of both
  781. /// operands to determine if the value in the first operand is not greater
  782. /// than the corresponding value in the second operand and returns the
  783. /// result of the comparison in the low-order bits of a vector of
  784. /// [4 x float].
  785. ///
  786. /// \headerfile <x86intrin.h>
  787. ///
  788. /// This intrinsic corresponds to the <c> VCMPNLTSS / CMPNLTSS </c>
  789. /// instructions.
  790. ///
  791. /// \param __a
  792. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  793. /// 32 bits of this operand are used in the comparison.
  794. /// \param __b
  795. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  796. /// 32 bits of this operand are used in the comparison.
  797. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  798. /// in the low-order bits.
  799. static __inline__ __m128 __DEFAULT_FN_ATTRS
  800. _mm_cmpngt_ss(__m128 __a, __m128 __b)
  801. {
  802. return (__m128)__builtin_shufflevector((__v4sf)__a,
  803. (__v4sf)__builtin_ia32_cmpnltss((__v4sf)__b, (__v4sf)__a),
  804. 4, 1, 2, 3);
  805. }
  806. /// Compares each of the corresponding 32-bit float values of the
  807. /// 128-bit vectors of [4 x float] to determine if the values in the first
  808. /// operand are not greater than those in the second operand.
  809. ///
  810. /// \headerfile <x86intrin.h>
  811. ///
  812. /// This intrinsic corresponds to the <c> VCMPNLTPS / CMPNLTPS </c>
  813. /// instructions.
  814. ///
  815. /// \param __a
  816. /// A 128-bit vector of [4 x float].
  817. /// \param __b
  818. /// A 128-bit vector of [4 x float].
  819. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  820. static __inline__ __m128 __DEFAULT_FN_ATTRS
  821. _mm_cmpngt_ps(__m128 __a, __m128 __b)
  822. {
  823. return (__m128)__builtin_ia32_cmpnltps((__v4sf)__b, (__v4sf)__a);
  824. }
  825. /// Compares two 32-bit float values in the low-order bits of both
  826. /// operands to determine if the value in the first operand is not greater
  827. /// than or equal to the corresponding value in the second operand and
  828. /// returns the result of the comparison in the low-order bits of a vector
  829. /// of [4 x float].
  830. ///
  831. /// \headerfile <x86intrin.h>
  832. ///
  833. /// This intrinsic corresponds to the <c> VCMPNLESS / CMPNLESS </c>
  834. /// instructions.
  835. ///
  836. /// \param __a
  837. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  838. /// 32 bits of this operand are used in the comparison.
  839. /// \param __b
  840. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  841. /// 32 bits of this operand are used in the comparison.
  842. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  843. /// in the low-order bits.
  844. static __inline__ __m128 __DEFAULT_FN_ATTRS
  845. _mm_cmpnge_ss(__m128 __a, __m128 __b)
  846. {
  847. return (__m128)__builtin_shufflevector((__v4sf)__a,
  848. (__v4sf)__builtin_ia32_cmpnless((__v4sf)__b, (__v4sf)__a),
  849. 4, 1, 2, 3);
  850. }
  851. /// Compares each of the corresponding 32-bit float values of the
  852. /// 128-bit vectors of [4 x float] to determine if the values in the first
  853. /// operand are not greater than or equal to those in the second operand.
  854. ///
  855. /// \headerfile <x86intrin.h>
  856. ///
  857. /// This intrinsic corresponds to the <c> VCMPNLEPS / CMPNLEPS </c>
  858. /// instructions.
  859. ///
  860. /// \param __a
  861. /// A 128-bit vector of [4 x float].
  862. /// \param __b
  863. /// A 128-bit vector of [4 x float].
  864. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  865. static __inline__ __m128 __DEFAULT_FN_ATTRS
  866. _mm_cmpnge_ps(__m128 __a, __m128 __b)
  867. {
  868. return (__m128)__builtin_ia32_cmpnleps((__v4sf)__b, (__v4sf)__a);
  869. }
  870. /// Compares two 32-bit float values in the low-order bits of both
  871. /// operands to determine if the value in the first operand is ordered with
  872. /// respect to the corresponding value in the second operand and returns the
  873. /// result of the comparison in the low-order bits of a vector of
  874. /// [4 x float].
  875. ///
  876. /// \headerfile <x86intrin.h>
  877. ///
  878. /// This intrinsic corresponds to the <c> VCMPORDSS / CMPORDSS </c>
  879. /// instructions.
  880. ///
  881. /// \param __a
  882. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  883. /// 32 bits of this operand are used in the comparison.
  884. /// \param __b
  885. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  886. /// 32 bits of this operand are used in the comparison.
  887. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  888. /// in the low-order bits.
  889. static __inline__ __m128 __DEFAULT_FN_ATTRS
  890. _mm_cmpord_ss(__m128 __a, __m128 __b)
  891. {
  892. return (__m128)__builtin_ia32_cmpordss((__v4sf)__a, (__v4sf)__b);
  893. }
  894. /// Compares each of the corresponding 32-bit float values of the
  895. /// 128-bit vectors of [4 x float] to determine if the values in the first
  896. /// operand are ordered with respect to those in the second operand.
  897. ///
  898. /// \headerfile <x86intrin.h>
  899. ///
  900. /// This intrinsic corresponds to the <c> VCMPORDPS / CMPORDPS </c>
  901. /// instructions.
  902. ///
  903. /// \param __a
  904. /// A 128-bit vector of [4 x float].
  905. /// \param __b
  906. /// A 128-bit vector of [4 x float].
  907. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  908. static __inline__ __m128 __DEFAULT_FN_ATTRS
  909. _mm_cmpord_ps(__m128 __a, __m128 __b)
  910. {
  911. return (__m128)__builtin_ia32_cmpordps((__v4sf)__a, (__v4sf)__b);
  912. }
  913. /// Compares two 32-bit float values in the low-order bits of both
  914. /// operands to determine if the value in the first operand is unordered
  915. /// with respect to the corresponding value in the second operand and
  916. /// returns the result of the comparison in the low-order bits of a vector
  917. /// of [4 x float].
  918. ///
  919. /// \headerfile <x86intrin.h>
  920. ///
  921. /// This intrinsic corresponds to the <c> VCMPUNORDSS / CMPUNORDSS </c>
  922. /// instructions.
  923. ///
  924. /// \param __a
  925. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  926. /// 32 bits of this operand are used in the comparison.
  927. /// \param __b
  928. /// A 128-bit vector of [4 x float] containing one of the operands. The lower
  929. /// 32 bits of this operand are used in the comparison.
  930. /// \returns A 128-bit vector of [4 x float] containing the comparison results
  931. /// in the low-order bits.
  932. static __inline__ __m128 __DEFAULT_FN_ATTRS
  933. _mm_cmpunord_ss(__m128 __a, __m128 __b)
  934. {
  935. return (__m128)__builtin_ia32_cmpunordss((__v4sf)__a, (__v4sf)__b);
  936. }
  937. /// Compares each of the corresponding 32-bit float values of the
  938. /// 128-bit vectors of [4 x float] to determine if the values in the first
  939. /// operand are unordered with respect to those in the second operand.
  940. ///
  941. /// \headerfile <x86intrin.h>
  942. ///
  943. /// This intrinsic corresponds to the <c> VCMPUNORDPS / CMPUNORDPS </c>
  944. /// instructions.
  945. ///
  946. /// \param __a
  947. /// A 128-bit vector of [4 x float].
  948. /// \param __b
  949. /// A 128-bit vector of [4 x float].
  950. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  951. static __inline__ __m128 __DEFAULT_FN_ATTRS
  952. _mm_cmpunord_ps(__m128 __a, __m128 __b)
  953. {
  954. return (__m128)__builtin_ia32_cmpunordps((__v4sf)__a, (__v4sf)__b);
  955. }
  956. /// Compares two 32-bit float values in the low-order bits of both
  957. /// operands for equality and returns the result of the comparison.
  958. ///
  959. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  960. ///
  961. /// \headerfile <x86intrin.h>
  962. ///
  963. /// This intrinsic corresponds to the <c> VCOMISS / COMISS </c>
  964. /// instructions.
  965. ///
  966. /// \param __a
  967. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  968. /// used in the comparison.
  969. /// \param __b
  970. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  971. /// used in the comparison.
  972. /// \returns An integer containing the comparison results. If either of the
  973. /// two lower 32-bit values is NaN, 0 is returned.
  974. static __inline__ int __DEFAULT_FN_ATTRS
  975. _mm_comieq_ss(__m128 __a, __m128 __b)
  976. {
  977. return __builtin_ia32_comieq((__v4sf)__a, (__v4sf)__b);
  978. }
  979. /// Compares two 32-bit float values in the low-order bits of both
  980. /// operands to determine if the first operand is less than the second
  981. /// operand and returns the result of the comparison.
  982. ///
  983. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  984. ///
  985. /// \headerfile <x86intrin.h>
  986. ///
  987. /// This intrinsic corresponds to the <c> VCOMISS / COMISS </c>
  988. /// instructions.
  989. ///
  990. /// \param __a
  991. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  992. /// used in the comparison.
  993. /// \param __b
  994. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  995. /// used in the comparison.
  996. /// \returns An integer containing the comparison results. If either of the two
  997. /// lower 32-bit values is NaN, 0 is returned.
  998. static __inline__ int __DEFAULT_FN_ATTRS
  999. _mm_comilt_ss(__m128 __a, __m128 __b)
  1000. {
  1001. return __builtin_ia32_comilt((__v4sf)__a, (__v4sf)__b);
  1002. }
  1003. /// Compares two 32-bit float values in the low-order bits of both
  1004. /// operands to determine if the first operand is less than or equal to the
  1005. /// second operand and returns the result of the comparison.
  1006. ///
  1007. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1008. ///
  1009. /// \headerfile <x86intrin.h>
  1010. ///
  1011. /// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
  1012. ///
  1013. /// \param __a
  1014. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1015. /// used in the comparison.
  1016. /// \param __b
  1017. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1018. /// used in the comparison.
  1019. /// \returns An integer containing the comparison results. If either of the two
  1020. /// lower 32-bit values is NaN, 0 is returned.
  1021. static __inline__ int __DEFAULT_FN_ATTRS
  1022. _mm_comile_ss(__m128 __a, __m128 __b)
  1023. {
  1024. return __builtin_ia32_comile((__v4sf)__a, (__v4sf)__b);
  1025. }
  1026. /// Compares two 32-bit float values in the low-order bits of both
  1027. /// operands to determine if the first operand is greater than the second
  1028. /// operand and returns the result of the comparison.
  1029. ///
  1030. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1031. ///
  1032. /// \headerfile <x86intrin.h>
  1033. ///
  1034. /// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
  1035. ///
  1036. /// \param __a
  1037. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1038. /// used in the comparison.
  1039. /// \param __b
  1040. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1041. /// used in the comparison.
  1042. /// \returns An integer containing the comparison results. If either of the
  1043. /// two lower 32-bit values is NaN, 0 is returned.
  1044. static __inline__ int __DEFAULT_FN_ATTRS
  1045. _mm_comigt_ss(__m128 __a, __m128 __b)
  1046. {
  1047. return __builtin_ia32_comigt((__v4sf)__a, (__v4sf)__b);
  1048. }
  1049. /// Compares two 32-bit float values in the low-order bits of both
  1050. /// operands to determine if the first operand is greater than or equal to
  1051. /// the second operand and returns the result of the comparison.
  1052. ///
  1053. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1054. ///
  1055. /// \headerfile <x86intrin.h>
  1056. ///
  1057. /// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
  1058. ///
  1059. /// \param __a
  1060. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1061. /// used in the comparison.
  1062. /// \param __b
  1063. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1064. /// used in the comparison.
  1065. /// \returns An integer containing the comparison results. If either of the two
  1066. /// lower 32-bit values is NaN, 0 is returned.
  1067. static __inline__ int __DEFAULT_FN_ATTRS
  1068. _mm_comige_ss(__m128 __a, __m128 __b)
  1069. {
  1070. return __builtin_ia32_comige((__v4sf)__a, (__v4sf)__b);
  1071. }
  1072. /// Compares two 32-bit float values in the low-order bits of both
  1073. /// operands to determine if the first operand is not equal to the second
  1074. /// operand and returns the result of the comparison.
  1075. ///
  1076. /// If either of the two lower 32-bit values is NaN, 1 is returned.
  1077. ///
  1078. /// \headerfile <x86intrin.h>
  1079. ///
  1080. /// This intrinsic corresponds to the <c> VCOMISS / COMISS </c> instructions.
  1081. ///
  1082. /// \param __a
  1083. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1084. /// used in the comparison.
  1085. /// \param __b
  1086. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1087. /// used in the comparison.
  1088. /// \returns An integer containing the comparison results. If either of the
  1089. /// two lower 32-bit values is NaN, 1 is returned.
  1090. static __inline__ int __DEFAULT_FN_ATTRS
  1091. _mm_comineq_ss(__m128 __a, __m128 __b)
  1092. {
  1093. return __builtin_ia32_comineq((__v4sf)__a, (__v4sf)__b);
  1094. }
  1095. /// Performs an unordered comparison of two 32-bit float values using
  1096. /// the low-order bits of both operands to determine equality and returns
  1097. /// the result of the comparison.
  1098. ///
  1099. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1100. ///
  1101. /// \headerfile <x86intrin.h>
  1102. ///
  1103. /// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
  1104. ///
  1105. /// \param __a
  1106. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1107. /// used in the comparison.
  1108. /// \param __b
  1109. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1110. /// used in the comparison.
  1111. /// \returns An integer containing the comparison results. If either of the two
  1112. /// lower 32-bit values is NaN, 0 is returned.
  1113. static __inline__ int __DEFAULT_FN_ATTRS
  1114. _mm_ucomieq_ss(__m128 __a, __m128 __b)
  1115. {
  1116. return __builtin_ia32_ucomieq((__v4sf)__a, (__v4sf)__b);
  1117. }
  1118. /// Performs an unordered comparison of two 32-bit float values using
  1119. /// the low-order bits of both operands to determine if the first operand is
  1120. /// less than the second operand and returns the result of the comparison.
  1121. ///
  1122. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1123. ///
  1124. /// \headerfile <x86intrin.h>
  1125. ///
  1126. /// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
  1127. ///
  1128. /// \param __a
  1129. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1130. /// used in the comparison.
  1131. /// \param __b
  1132. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1133. /// used in the comparison.
  1134. /// \returns An integer containing the comparison results. If either of the two
  1135. /// lower 32-bit values is NaN, 0 is returned.
  1136. static __inline__ int __DEFAULT_FN_ATTRS
  1137. _mm_ucomilt_ss(__m128 __a, __m128 __b)
  1138. {
  1139. return __builtin_ia32_ucomilt((__v4sf)__a, (__v4sf)__b);
  1140. }
  1141. /// Performs an unordered comparison of two 32-bit float values using
  1142. /// the low-order bits of both operands to determine if the first operand is
  1143. /// less than or equal to the second operand and returns the result of the
  1144. /// comparison.
  1145. ///
  1146. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1147. ///
  1148. /// \headerfile <x86intrin.h>
  1149. ///
  1150. /// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
  1151. ///
  1152. /// \param __a
  1153. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1154. /// used in the comparison.
  1155. /// \param __b
  1156. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1157. /// used in the comparison.
  1158. /// \returns An integer containing the comparison results. If either of the two
  1159. /// lower 32-bit values is NaN, 0 is returned.
  1160. static __inline__ int __DEFAULT_FN_ATTRS
  1161. _mm_ucomile_ss(__m128 __a, __m128 __b)
  1162. {
  1163. return __builtin_ia32_ucomile((__v4sf)__a, (__v4sf)__b);
  1164. }
  1165. /// Performs an unordered comparison of two 32-bit float values using
  1166. /// the low-order bits of both operands to determine if the first operand is
  1167. /// greater than the second operand and returns the result of the
  1168. /// comparison.
  1169. ///
  1170. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1171. ///
  1172. /// \headerfile <x86intrin.h>
  1173. ///
  1174. /// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
  1175. ///
  1176. /// \param __a
  1177. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1178. /// used in the comparison.
  1179. /// \param __b
  1180. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1181. /// used in the comparison.
  1182. /// \returns An integer containing the comparison results. If either of the two
  1183. /// lower 32-bit values is NaN, 0 is returned.
  1184. static __inline__ int __DEFAULT_FN_ATTRS
  1185. _mm_ucomigt_ss(__m128 __a, __m128 __b)
  1186. {
  1187. return __builtin_ia32_ucomigt((__v4sf)__a, (__v4sf)__b);
  1188. }
  1189. /// Performs an unordered comparison of two 32-bit float values using
  1190. /// the low-order bits of both operands to determine if the first operand is
  1191. /// greater than or equal to the second operand and returns the result of
  1192. /// the comparison.
  1193. ///
  1194. /// If either of the two lower 32-bit values is NaN, 0 is returned.
  1195. ///
  1196. /// \headerfile <x86intrin.h>
  1197. ///
  1198. /// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
  1199. ///
  1200. /// \param __a
  1201. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1202. /// used in the comparison.
  1203. /// \param __b
  1204. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1205. /// used in the comparison.
  1206. /// \returns An integer containing the comparison results. If either of the two
  1207. /// lower 32-bit values is NaN, 0 is returned.
  1208. static __inline__ int __DEFAULT_FN_ATTRS
  1209. _mm_ucomige_ss(__m128 __a, __m128 __b)
  1210. {
  1211. return __builtin_ia32_ucomige((__v4sf)__a, (__v4sf)__b);
  1212. }
  1213. /// Performs an unordered comparison of two 32-bit float values using
  1214. /// the low-order bits of both operands to determine inequality and returns
  1215. /// the result of the comparison.
  1216. ///
  1217. /// If either of the two lower 32-bit values is NaN, 1 is returned.
  1218. ///
  1219. /// \headerfile <x86intrin.h>
  1220. ///
  1221. /// This intrinsic corresponds to the <c> VUCOMISS / UCOMISS </c> instructions.
  1222. ///
  1223. /// \param __a
  1224. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1225. /// used in the comparison.
  1226. /// \param __b
  1227. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1228. /// used in the comparison.
  1229. /// \returns An integer containing the comparison results. If either of the two
  1230. /// lower 32-bit values is NaN, 1 is returned.
  1231. static __inline__ int __DEFAULT_FN_ATTRS
  1232. _mm_ucomineq_ss(__m128 __a, __m128 __b)
  1233. {
  1234. return __builtin_ia32_ucomineq((__v4sf)__a, (__v4sf)__b);
  1235. }
  1236. /// Converts a float value contained in the lower 32 bits of a vector of
  1237. /// [4 x float] into a 32-bit integer.
  1238. ///
  1239. /// \headerfile <x86intrin.h>
  1240. ///
  1241. /// This intrinsic corresponds to the <c> VCVTSS2SI / CVTSS2SI </c>
  1242. /// instructions.
  1243. ///
  1244. /// \param __a
  1245. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1246. /// used in the conversion.
  1247. /// \returns A 32-bit integer containing the converted value.
  1248. static __inline__ int __DEFAULT_FN_ATTRS
  1249. _mm_cvtss_si32(__m128 __a)
  1250. {
  1251. return __builtin_ia32_cvtss2si((__v4sf)__a);
  1252. }
  1253. /// Converts a float value contained in the lower 32 bits of a vector of
  1254. /// [4 x float] into a 32-bit integer.
  1255. ///
  1256. /// \headerfile <x86intrin.h>
  1257. ///
  1258. /// This intrinsic corresponds to the <c> VCVTSS2SI / CVTSS2SI </c>
  1259. /// instructions.
  1260. ///
  1261. /// \param __a
  1262. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1263. /// used in the conversion.
  1264. /// \returns A 32-bit integer containing the converted value.
  1265. static __inline__ int __DEFAULT_FN_ATTRS
  1266. _mm_cvt_ss2si(__m128 __a)
  1267. {
  1268. return _mm_cvtss_si32(__a);
  1269. }
  1270. #ifdef __x86_64__
  1271. /// Converts a float value contained in the lower 32 bits of a vector of
  1272. /// [4 x float] into a 64-bit integer.
  1273. ///
  1274. /// \headerfile <x86intrin.h>
  1275. ///
  1276. /// This intrinsic corresponds to the <c> VCVTSS2SI / CVTSS2SI </c>
  1277. /// instructions.
  1278. ///
  1279. /// \param __a
  1280. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1281. /// used in the conversion.
  1282. /// \returns A 64-bit integer containing the converted value.
  1283. static __inline__ long long __DEFAULT_FN_ATTRS
  1284. _mm_cvtss_si64(__m128 __a)
  1285. {
  1286. return __builtin_ia32_cvtss2si64((__v4sf)__a);
  1287. }
  1288. #endif
  1289. /// Converts two low-order float values in a 128-bit vector of
  1290. /// [4 x float] into a 64-bit vector of [2 x i32].
  1291. ///
  1292. /// \headerfile <x86intrin.h>
  1293. ///
  1294. /// This intrinsic corresponds to the <c> CVTPS2PI </c> instruction.
  1295. ///
  1296. /// \param __a
  1297. /// A 128-bit vector of [4 x float].
  1298. /// \returns A 64-bit integer vector containing the converted values.
  1299. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  1300. _mm_cvtps_pi32(__m128 __a)
  1301. {
  1302. return (__m64)__builtin_ia32_cvtps2pi((__v4sf)__a);
  1303. }
  1304. /// Converts two low-order float values in a 128-bit vector of
  1305. /// [4 x float] into a 64-bit vector of [2 x i32].
  1306. ///
  1307. /// \headerfile <x86intrin.h>
  1308. ///
  1309. /// This intrinsic corresponds to the <c> CVTPS2PI </c> instruction.
  1310. ///
  1311. /// \param __a
  1312. /// A 128-bit vector of [4 x float].
  1313. /// \returns A 64-bit integer vector containing the converted values.
  1314. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  1315. _mm_cvt_ps2pi(__m128 __a)
  1316. {
  1317. return _mm_cvtps_pi32(__a);
  1318. }
  1319. /// Converts a float value contained in the lower 32 bits of a vector of
  1320. /// [4 x float] into a 32-bit integer, truncating the result when it is
  1321. /// inexact.
  1322. ///
  1323. /// \headerfile <x86intrin.h>
  1324. ///
  1325. /// This intrinsic corresponds to the <c> VCVTTSS2SI / CVTTSS2SI </c>
  1326. /// instructions.
  1327. ///
  1328. /// \param __a
  1329. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1330. /// used in the conversion.
  1331. /// \returns A 32-bit integer containing the converted value.
  1332. static __inline__ int __DEFAULT_FN_ATTRS
  1333. _mm_cvttss_si32(__m128 __a)
  1334. {
  1335. return __builtin_ia32_cvttss2si((__v4sf)__a);
  1336. }
  1337. /// Converts a float value contained in the lower 32 bits of a vector of
  1338. /// [4 x float] into a 32-bit integer, truncating the result when it is
  1339. /// inexact.
  1340. ///
  1341. /// \headerfile <x86intrin.h>
  1342. ///
  1343. /// This intrinsic corresponds to the <c> VCVTTSS2SI / CVTTSS2SI </c>
  1344. /// instructions.
  1345. ///
  1346. /// \param __a
  1347. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1348. /// used in the conversion.
  1349. /// \returns A 32-bit integer containing the converted value.
  1350. static __inline__ int __DEFAULT_FN_ATTRS
  1351. _mm_cvtt_ss2si(__m128 __a)
  1352. {
  1353. return _mm_cvttss_si32(__a);
  1354. }
  1355. #ifdef __x86_64__
  1356. /// Converts a float value contained in the lower 32 bits of a vector of
  1357. /// [4 x float] into a 64-bit integer, truncating the result when it is
  1358. /// inexact.
  1359. ///
  1360. /// \headerfile <x86intrin.h>
  1361. ///
  1362. /// This intrinsic corresponds to the <c> VCVTTSS2SI / CVTTSS2SI </c>
  1363. /// instructions.
  1364. ///
  1365. /// \param __a
  1366. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1367. /// used in the conversion.
  1368. /// \returns A 64-bit integer containing the converted value.
  1369. static __inline__ long long __DEFAULT_FN_ATTRS
  1370. _mm_cvttss_si64(__m128 __a)
  1371. {
  1372. return __builtin_ia32_cvttss2si64((__v4sf)__a);
  1373. }
  1374. #endif
  1375. /// Converts two low-order float values in a 128-bit vector of
  1376. /// [4 x float] into a 64-bit vector of [2 x i32], truncating the result
  1377. /// when it is inexact.
  1378. ///
  1379. /// \headerfile <x86intrin.h>
  1380. ///
  1381. /// This intrinsic corresponds to the <c> CVTTPS2PI / VTTPS2PI </c>
  1382. /// instructions.
  1383. ///
  1384. /// \param __a
  1385. /// A 128-bit vector of [4 x float].
  1386. /// \returns A 64-bit integer vector containing the converted values.
  1387. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  1388. _mm_cvttps_pi32(__m128 __a)
  1389. {
  1390. return (__m64)__builtin_ia32_cvttps2pi((__v4sf)__a);
  1391. }
  1392. /// Converts two low-order float values in a 128-bit vector of [4 x
  1393. /// float] into a 64-bit vector of [2 x i32], truncating the result when it
  1394. /// is inexact.
  1395. ///
  1396. /// \headerfile <x86intrin.h>
  1397. ///
  1398. /// This intrinsic corresponds to the <c> CVTTPS2PI </c> instruction.
  1399. ///
  1400. /// \param __a
  1401. /// A 128-bit vector of [4 x float].
  1402. /// \returns A 64-bit integer vector containing the converted values.
  1403. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  1404. _mm_cvtt_ps2pi(__m128 __a)
  1405. {
  1406. return _mm_cvttps_pi32(__a);
  1407. }
  1408. /// Converts a 32-bit signed integer value into a floating point value
  1409. /// and writes it to the lower 32 bits of the destination. The remaining
  1410. /// higher order elements of the destination vector are copied from the
  1411. /// corresponding elements in the first operand.
  1412. ///
  1413. /// \headerfile <x86intrin.h>
  1414. ///
  1415. /// This intrinsic corresponds to the <c> VCVTSI2SS / CVTSI2SS </c> instruction.
  1416. ///
  1417. /// \param __a
  1418. /// A 128-bit vector of [4 x float].
  1419. /// \param __b
  1420. /// A 32-bit signed integer operand containing the value to be converted.
  1421. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
  1422. /// converted value of the second operand. The upper 96 bits are copied from
  1423. /// the upper 96 bits of the first operand.
  1424. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1425. _mm_cvtsi32_ss(__m128 __a, int __b)
  1426. {
  1427. __a[0] = __b;
  1428. return __a;
  1429. }
  1430. /// Converts a 32-bit signed integer value into a floating point value
  1431. /// and writes it to the lower 32 bits of the destination. The remaining
  1432. /// higher order elements of the destination are copied from the
  1433. /// corresponding elements in the first operand.
  1434. ///
  1435. /// \headerfile <x86intrin.h>
  1436. ///
  1437. /// This intrinsic corresponds to the <c> VCVTSI2SS / CVTSI2SS </c> instruction.
  1438. ///
  1439. /// \param __a
  1440. /// A 128-bit vector of [4 x float].
  1441. /// \param __b
  1442. /// A 32-bit signed integer operand containing the value to be converted.
  1443. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
  1444. /// converted value of the second operand. The upper 96 bits are copied from
  1445. /// the upper 96 bits of the first operand.
  1446. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1447. _mm_cvt_si2ss(__m128 __a, int __b)
  1448. {
  1449. return _mm_cvtsi32_ss(__a, __b);
  1450. }
  1451. #ifdef __x86_64__
  1452. /// Converts a 64-bit signed integer value into a floating point value
  1453. /// and writes it to the lower 32 bits of the destination. The remaining
  1454. /// higher order elements of the destination are copied from the
  1455. /// corresponding elements in the first operand.
  1456. ///
  1457. /// \headerfile <x86intrin.h>
  1458. ///
  1459. /// This intrinsic corresponds to the <c> VCVTSI2SS / CVTSI2SS </c> instruction.
  1460. ///
  1461. /// \param __a
  1462. /// A 128-bit vector of [4 x float].
  1463. /// \param __b
  1464. /// A 64-bit signed integer operand containing the value to be converted.
  1465. /// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
  1466. /// converted value of the second operand. The upper 96 bits are copied from
  1467. /// the upper 96 bits of the first operand.
  1468. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1469. _mm_cvtsi64_ss(__m128 __a, long long __b)
  1470. {
  1471. __a[0] = __b;
  1472. return __a;
  1473. }
  1474. #endif
  1475. /// Converts two elements of a 64-bit vector of [2 x i32] into two
  1476. /// floating point values and writes them to the lower 64-bits of the
  1477. /// destination. The remaining higher order elements of the destination are
  1478. /// copied from the corresponding elements in the first operand.
  1479. ///
  1480. /// \headerfile <x86intrin.h>
  1481. ///
  1482. /// This intrinsic corresponds to the <c> CVTPI2PS </c> instruction.
  1483. ///
  1484. /// \param __a
  1485. /// A 128-bit vector of [4 x float].
  1486. /// \param __b
  1487. /// A 64-bit vector of [2 x i32]. The elements in this vector are converted
  1488. /// and written to the corresponding low-order elements in the destination.
  1489. /// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
  1490. /// converted value of the second operand. The upper 64 bits are copied from
  1491. /// the upper 64 bits of the first operand.
  1492. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  1493. _mm_cvtpi32_ps(__m128 __a, __m64 __b)
  1494. {
  1495. return __builtin_ia32_cvtpi2ps((__v4sf)__a, (__v2si)__b);
  1496. }
  1497. /// Converts two elements of a 64-bit vector of [2 x i32] into two
  1498. /// floating point values and writes them to the lower 64-bits of the
  1499. /// destination. The remaining higher order elements of the destination are
  1500. /// copied from the corresponding elements in the first operand.
  1501. ///
  1502. /// \headerfile <x86intrin.h>
  1503. ///
  1504. /// This intrinsic corresponds to the <c> CVTPI2PS </c> instruction.
  1505. ///
  1506. /// \param __a
  1507. /// A 128-bit vector of [4 x float].
  1508. /// \param __b
  1509. /// A 64-bit vector of [2 x i32]. The elements in this vector are converted
  1510. /// and written to the corresponding low-order elements in the destination.
  1511. /// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
  1512. /// converted value from the second operand. The upper 64 bits are copied
  1513. /// from the upper 64 bits of the first operand.
  1514. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  1515. _mm_cvt_pi2ps(__m128 __a, __m64 __b)
  1516. {
  1517. return _mm_cvtpi32_ps(__a, __b);
  1518. }
  1519. /// Extracts a float value contained in the lower 32 bits of a vector of
  1520. /// [4 x float].
  1521. ///
  1522. /// \headerfile <x86intrin.h>
  1523. ///
  1524. /// This intrinsic has no corresponding instruction.
  1525. ///
  1526. /// \param __a
  1527. /// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
  1528. /// used in the extraction.
  1529. /// \returns A 32-bit float containing the extracted value.
  1530. static __inline__ float __DEFAULT_FN_ATTRS
  1531. _mm_cvtss_f32(__m128 __a)
  1532. {
  1533. return __a[0];
  1534. }
  1535. /// Loads two packed float values from the address \a __p into the
  1536. /// high-order bits of a 128-bit vector of [4 x float]. The low-order bits
  1537. /// are copied from the low-order bits of the first operand.
  1538. ///
  1539. /// \headerfile <x86intrin.h>
  1540. ///
  1541. /// This intrinsic corresponds to the <c> VMOVHPD / MOVHPD </c> instruction.
  1542. ///
  1543. /// \param __a
  1544. /// A 128-bit vector of [4 x float]. Bits [63:0] are written to bits [63:0]
  1545. /// of the destination.
  1546. /// \param __p
  1547. /// A pointer to two packed float values. Bits [63:0] are written to bits
  1548. /// [127:64] of the destination.
  1549. /// \returns A 128-bit vector of [4 x float] containing the moved values.
  1550. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1551. _mm_loadh_pi(__m128 __a, const __m64 *__p)
  1552. {
  1553. typedef float __mm_loadh_pi_v2f32 __attribute__((__vector_size__(8)));
  1554. struct __mm_loadh_pi_struct {
  1555. __mm_loadh_pi_v2f32 __u;
  1556. } __attribute__((__packed__, __may_alias__));
  1557. __mm_loadh_pi_v2f32 __b = ((struct __mm_loadh_pi_struct*)__p)->__u;
  1558. __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
  1559. return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
  1560. }
  1561. /// Loads two packed float values from the address \a __p into the
  1562. /// low-order bits of a 128-bit vector of [4 x float]. The high-order bits
  1563. /// are copied from the high-order bits of the first operand.
  1564. ///
  1565. /// \headerfile <x86intrin.h>
  1566. ///
  1567. /// This intrinsic corresponds to the <c> VMOVLPD / MOVLPD </c> instruction.
  1568. ///
  1569. /// \param __a
  1570. /// A 128-bit vector of [4 x float]. Bits [127:64] are written to bits
  1571. /// [127:64] of the destination.
  1572. /// \param __p
  1573. /// A pointer to two packed float values. Bits [63:0] are written to bits
  1574. /// [63:0] of the destination.
  1575. /// \returns A 128-bit vector of [4 x float] containing the moved values.
  1576. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1577. _mm_loadl_pi(__m128 __a, const __m64 *__p)
  1578. {
  1579. typedef float __mm_loadl_pi_v2f32 __attribute__((__vector_size__(8)));
  1580. struct __mm_loadl_pi_struct {
  1581. __mm_loadl_pi_v2f32 __u;
  1582. } __attribute__((__packed__, __may_alias__));
  1583. __mm_loadl_pi_v2f32 __b = ((struct __mm_loadl_pi_struct*)__p)->__u;
  1584. __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1);
  1585. return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3);
  1586. }
  1587. /// Constructs a 128-bit floating-point vector of [4 x float]. The lower
  1588. /// 32 bits of the vector are initialized with the single-precision
  1589. /// floating-point value loaded from a specified memory location. The upper
  1590. /// 96 bits are set to zero.
  1591. ///
  1592. /// \headerfile <x86intrin.h>
  1593. ///
  1594. /// This intrinsic corresponds to the <c> VMOVSS / MOVSS </c> instruction.
  1595. ///
  1596. /// \param __p
  1597. /// A pointer to a 32-bit memory location containing a single-precision
  1598. /// floating-point value.
  1599. /// \returns An initialized 128-bit floating-point vector of [4 x float]. The
  1600. /// lower 32 bits contain the value loaded from the memory location. The
  1601. /// upper 96 bits are set to zero.
  1602. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1603. _mm_load_ss(const float *__p)
  1604. {
  1605. struct __mm_load_ss_struct {
  1606. float __u;
  1607. } __attribute__((__packed__, __may_alias__));
  1608. float __u = ((struct __mm_load_ss_struct*)__p)->__u;
  1609. return __extension__ (__m128){ __u, 0, 0, 0 };
  1610. }
  1611. /// Loads a 32-bit float value and duplicates it to all four vector
  1612. /// elements of a 128-bit vector of [4 x float].
  1613. ///
  1614. /// \headerfile <x86intrin.h>
  1615. ///
  1616. /// This intrinsic corresponds to the <c> VBROADCASTSS / MOVSS + shuffling </c>
  1617. /// instruction.
  1618. ///
  1619. /// \param __p
  1620. /// A pointer to a float value to be loaded and duplicated.
  1621. /// \returns A 128-bit vector of [4 x float] containing the loaded and
  1622. /// duplicated values.
  1623. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1624. _mm_load1_ps(const float *__p)
  1625. {
  1626. struct __mm_load1_ps_struct {
  1627. float __u;
  1628. } __attribute__((__packed__, __may_alias__));
  1629. float __u = ((struct __mm_load1_ps_struct*)__p)->__u;
  1630. return __extension__ (__m128){ __u, __u, __u, __u };
  1631. }
  1632. #define _mm_load_ps1(p) _mm_load1_ps(p)
  1633. /// Loads a 128-bit floating-point vector of [4 x float] from an aligned
  1634. /// memory location.
  1635. ///
  1636. /// \headerfile <x86intrin.h>
  1637. ///
  1638. /// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS </c> instruction.
  1639. ///
  1640. /// \param __p
  1641. /// A pointer to a 128-bit memory location. The address of the memory
  1642. /// location has to be 128-bit aligned.
  1643. /// \returns A 128-bit vector of [4 x float] containing the loaded values.
  1644. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1645. _mm_load_ps(const float *__p)
  1646. {
  1647. return *(__m128*)__p;
  1648. }
  1649. /// Loads a 128-bit floating-point vector of [4 x float] from an
  1650. /// unaligned memory location.
  1651. ///
  1652. /// \headerfile <x86intrin.h>
  1653. ///
  1654. /// This intrinsic corresponds to the <c> VMOVUPS / MOVUPS </c> instruction.
  1655. ///
  1656. /// \param __p
  1657. /// A pointer to a 128-bit memory location. The address of the memory
  1658. /// location does not have to be aligned.
  1659. /// \returns A 128-bit vector of [4 x float] containing the loaded values.
  1660. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1661. _mm_loadu_ps(const float *__p)
  1662. {
  1663. struct __loadu_ps {
  1664. __m128 __v;
  1665. } __attribute__((__packed__, __may_alias__));
  1666. return ((struct __loadu_ps*)__p)->__v;
  1667. }
  1668. /// Loads four packed float values, in reverse order, from an aligned
  1669. /// memory location to 32-bit elements in a 128-bit vector of [4 x float].
  1670. ///
  1671. /// \headerfile <x86intrin.h>
  1672. ///
  1673. /// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS + shuffling </c>
  1674. /// instruction.
  1675. ///
  1676. /// \param __p
  1677. /// A pointer to a 128-bit memory location. The address of the memory
  1678. /// location has to be 128-bit aligned.
  1679. /// \returns A 128-bit vector of [4 x float] containing the moved values, loaded
  1680. /// in reverse order.
  1681. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1682. _mm_loadr_ps(const float *__p)
  1683. {
  1684. __m128 __a = _mm_load_ps(__p);
  1685. return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 3, 2, 1, 0);
  1686. }
  1687. /// Create a 128-bit vector of [4 x float] with undefined values.
  1688. ///
  1689. /// \headerfile <x86intrin.h>
  1690. ///
  1691. /// This intrinsic has no corresponding instruction.
  1692. ///
  1693. /// \returns A 128-bit vector of [4 x float] containing undefined values.
  1694. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1695. _mm_undefined_ps(void)
  1696. {
  1697. return (__m128)__builtin_ia32_undef128();
  1698. }
  1699. /// Constructs a 128-bit floating-point vector of [4 x float]. The lower
  1700. /// 32 bits of the vector are initialized with the specified single-precision
  1701. /// floating-point value. The upper 96 bits are set to zero.
  1702. ///
  1703. /// \headerfile <x86intrin.h>
  1704. ///
  1705. /// This intrinsic corresponds to the <c> VMOVSS / MOVSS </c> instruction.
  1706. ///
  1707. /// \param __w
  1708. /// A single-precision floating-point value used to initialize the lower 32
  1709. /// bits of the result.
  1710. /// \returns An initialized 128-bit floating-point vector of [4 x float]. The
  1711. /// lower 32 bits contain the value provided in the source operand. The
  1712. /// upper 96 bits are set to zero.
  1713. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1714. _mm_set_ss(float __w)
  1715. {
  1716. return __extension__ (__m128){ __w, 0, 0, 0 };
  1717. }
  1718. /// Constructs a 128-bit floating-point vector of [4 x float], with each
  1719. /// of the four single-precision floating-point vector elements set to the
  1720. /// specified single-precision floating-point value.
  1721. ///
  1722. /// \headerfile <x86intrin.h>
  1723. ///
  1724. /// This intrinsic corresponds to the <c> VPERMILPS / PERMILPS </c> instruction.
  1725. ///
  1726. /// \param __w
  1727. /// A single-precision floating-point value used to initialize each vector
  1728. /// element of the result.
  1729. /// \returns An initialized 128-bit floating-point vector of [4 x float].
  1730. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1731. _mm_set1_ps(float __w)
  1732. {
  1733. return __extension__ (__m128){ __w, __w, __w, __w };
  1734. }
  1735. /* Microsoft specific. */
  1736. /// Constructs a 128-bit floating-point vector of [4 x float], with each
  1737. /// of the four single-precision floating-point vector elements set to the
  1738. /// specified single-precision floating-point value.
  1739. ///
  1740. /// \headerfile <x86intrin.h>
  1741. ///
  1742. /// This intrinsic corresponds to the <c> VPERMILPS / PERMILPS </c> instruction.
  1743. ///
  1744. /// \param __w
  1745. /// A single-precision floating-point value used to initialize each vector
  1746. /// element of the result.
  1747. /// \returns An initialized 128-bit floating-point vector of [4 x float].
  1748. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1749. _mm_set_ps1(float __w)
  1750. {
  1751. return _mm_set1_ps(__w);
  1752. }
  1753. /// Constructs a 128-bit floating-point vector of [4 x float]
  1754. /// initialized with the specified single-precision floating-point values.
  1755. ///
  1756. /// \headerfile <x86intrin.h>
  1757. ///
  1758. /// This intrinsic is a utility function and does not correspond to a specific
  1759. /// instruction.
  1760. ///
  1761. /// \param __z
  1762. /// A single-precision floating-point value used to initialize bits [127:96]
  1763. /// of the result.
  1764. /// \param __y
  1765. /// A single-precision floating-point value used to initialize bits [95:64]
  1766. /// of the result.
  1767. /// \param __x
  1768. /// A single-precision floating-point value used to initialize bits [63:32]
  1769. /// of the result.
  1770. /// \param __w
  1771. /// A single-precision floating-point value used to initialize bits [31:0]
  1772. /// of the result.
  1773. /// \returns An initialized 128-bit floating-point vector of [4 x float].
  1774. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1775. _mm_set_ps(float __z, float __y, float __x, float __w)
  1776. {
  1777. return __extension__ (__m128){ __w, __x, __y, __z };
  1778. }
  1779. /// Constructs a 128-bit floating-point vector of [4 x float],
  1780. /// initialized in reverse order with the specified 32-bit single-precision
  1781. /// float-point values.
  1782. ///
  1783. /// \headerfile <x86intrin.h>
  1784. ///
  1785. /// This intrinsic is a utility function and does not correspond to a specific
  1786. /// instruction.
  1787. ///
  1788. /// \param __z
  1789. /// A single-precision floating-point value used to initialize bits [31:0]
  1790. /// of the result.
  1791. /// \param __y
  1792. /// A single-precision floating-point value used to initialize bits [63:32]
  1793. /// of the result.
  1794. /// \param __x
  1795. /// A single-precision floating-point value used to initialize bits [95:64]
  1796. /// of the result.
  1797. /// \param __w
  1798. /// A single-precision floating-point value used to initialize bits [127:96]
  1799. /// of the result.
  1800. /// \returns An initialized 128-bit floating-point vector of [4 x float].
  1801. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1802. _mm_setr_ps(float __z, float __y, float __x, float __w)
  1803. {
  1804. return __extension__ (__m128){ __z, __y, __x, __w };
  1805. }
  1806. /// Constructs a 128-bit floating-point vector of [4 x float] initialized
  1807. /// to zero.
  1808. ///
  1809. /// \headerfile <x86intrin.h>
  1810. ///
  1811. /// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instruction.
  1812. ///
  1813. /// \returns An initialized 128-bit floating-point vector of [4 x float] with
  1814. /// all elements set to zero.
  1815. static __inline__ __m128 __DEFAULT_FN_ATTRS
  1816. _mm_setzero_ps(void)
  1817. {
  1818. return __extension__ (__m128){ 0, 0, 0, 0 };
  1819. }
  1820. /// Stores the upper 64 bits of a 128-bit vector of [4 x float] to a
  1821. /// memory location.
  1822. ///
  1823. /// \headerfile <x86intrin.h>
  1824. ///
  1825. /// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
  1826. ///
  1827. /// \param __p
  1828. /// A pointer to a 64-bit memory location.
  1829. /// \param __a
  1830. /// A 128-bit vector of [4 x float] containing the values to be stored.
  1831. static __inline__ void __DEFAULT_FN_ATTRS
  1832. _mm_storeh_pi(__m64 *__p, __m128 __a)
  1833. {
  1834. __builtin_ia32_storehps((__v2si *)__p, (__v4sf)__a);
  1835. }
  1836. /// Stores the lower 64 bits of a 128-bit vector of [4 x float] to a
  1837. /// memory location.
  1838. ///
  1839. /// \headerfile <x86intrin.h>
  1840. ///
  1841. /// This intrinsic corresponds to the <c> VMOVLPS / MOVLPS </c> instruction.
  1842. ///
  1843. /// \param __p
  1844. /// A pointer to a memory location that will receive the float values.
  1845. /// \param __a
  1846. /// A 128-bit vector of [4 x float] containing the values to be stored.
  1847. static __inline__ void __DEFAULT_FN_ATTRS
  1848. _mm_storel_pi(__m64 *__p, __m128 __a)
  1849. {
  1850. __builtin_ia32_storelps((__v2si *)__p, (__v4sf)__a);
  1851. }
  1852. /// Stores the lower 32 bits of a 128-bit vector of [4 x float] to a
  1853. /// memory location.
  1854. ///
  1855. /// \headerfile <x86intrin.h>
  1856. ///
  1857. /// This intrinsic corresponds to the <c> VMOVSS / MOVSS </c> instruction.
  1858. ///
  1859. /// \param __p
  1860. /// A pointer to a 32-bit memory location.
  1861. /// \param __a
  1862. /// A 128-bit vector of [4 x float] containing the value to be stored.
  1863. static __inline__ void __DEFAULT_FN_ATTRS
  1864. _mm_store_ss(float *__p, __m128 __a)
  1865. {
  1866. struct __mm_store_ss_struct {
  1867. float __u;
  1868. } __attribute__((__packed__, __may_alias__));
  1869. ((struct __mm_store_ss_struct*)__p)->__u = __a[0];
  1870. }
  1871. /// Stores a 128-bit vector of [4 x float] to an unaligned memory
  1872. /// location.
  1873. ///
  1874. /// \headerfile <x86intrin.h>
  1875. ///
  1876. /// This intrinsic corresponds to the <c> VMOVUPS / MOVUPS </c> instruction.
  1877. ///
  1878. /// \param __p
  1879. /// A pointer to a 128-bit memory location. The address of the memory
  1880. /// location does not have to be aligned.
  1881. /// \param __a
  1882. /// A 128-bit vector of [4 x float] containing the values to be stored.
  1883. static __inline__ void __DEFAULT_FN_ATTRS
  1884. _mm_storeu_ps(float *__p, __m128 __a)
  1885. {
  1886. struct __storeu_ps {
  1887. __m128 __v;
  1888. } __attribute__((__packed__, __may_alias__));
  1889. ((struct __storeu_ps*)__p)->__v = __a;
  1890. }
  1891. /// Stores a 128-bit vector of [4 x float] into an aligned memory
  1892. /// location.
  1893. ///
  1894. /// \headerfile <x86intrin.h>
  1895. ///
  1896. /// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS </c> instruction.
  1897. ///
  1898. /// \param __p
  1899. /// A pointer to a 128-bit memory location. The address of the memory
  1900. /// location has to be 16-byte aligned.
  1901. /// \param __a
  1902. /// A 128-bit vector of [4 x float] containing the values to be stored.
  1903. static __inline__ void __DEFAULT_FN_ATTRS
  1904. _mm_store_ps(float *__p, __m128 __a)
  1905. {
  1906. *(__m128*)__p = __a;
  1907. }
  1908. /// Stores the lower 32 bits of a 128-bit vector of [4 x float] into
  1909. /// four contiguous elements in an aligned memory location.
  1910. ///
  1911. /// \headerfile <x86intrin.h>
  1912. ///
  1913. /// This intrinsic corresponds to <c> VMOVAPS / MOVAPS + shuffling </c>
  1914. /// instruction.
  1915. ///
  1916. /// \param __p
  1917. /// A pointer to a 128-bit memory location.
  1918. /// \param __a
  1919. /// A 128-bit vector of [4 x float] whose lower 32 bits are stored to each
  1920. /// of the four contiguous elements pointed by \a __p.
  1921. static __inline__ void __DEFAULT_FN_ATTRS
  1922. _mm_store1_ps(float *__p, __m128 __a)
  1923. {
  1924. __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0);
  1925. _mm_store_ps(__p, __a);
  1926. }
  1927. /// Stores the lower 32 bits of a 128-bit vector of [4 x float] into
  1928. /// four contiguous elements in an aligned memory location.
  1929. ///
  1930. /// \headerfile <x86intrin.h>
  1931. ///
  1932. /// This intrinsic corresponds to <c> VMOVAPS / MOVAPS + shuffling </c>
  1933. /// instruction.
  1934. ///
  1935. /// \param __p
  1936. /// A pointer to a 128-bit memory location.
  1937. /// \param __a
  1938. /// A 128-bit vector of [4 x float] whose lower 32 bits are stored to each
  1939. /// of the four contiguous elements pointed by \a __p.
  1940. static __inline__ void __DEFAULT_FN_ATTRS
  1941. _mm_store_ps1(float *__p, __m128 __a)
  1942. {
  1943. _mm_store1_ps(__p, __a);
  1944. }
  1945. /// Stores float values from a 128-bit vector of [4 x float] to an
  1946. /// aligned memory location in reverse order.
  1947. ///
  1948. /// \headerfile <x86intrin.h>
  1949. ///
  1950. /// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS + shuffling </c>
  1951. /// instruction.
  1952. ///
  1953. /// \param __p
  1954. /// A pointer to a 128-bit memory location. The address of the memory
  1955. /// location has to be 128-bit aligned.
  1956. /// \param __a
  1957. /// A 128-bit vector of [4 x float] containing the values to be stored.
  1958. static __inline__ void __DEFAULT_FN_ATTRS
  1959. _mm_storer_ps(float *__p, __m128 __a)
  1960. {
  1961. __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 3, 2, 1, 0);
  1962. _mm_store_ps(__p, __a);
  1963. }
  1964. #define _MM_HINT_ET0 7
  1965. #define _MM_HINT_ET1 6
  1966. #define _MM_HINT_T0 3
  1967. #define _MM_HINT_T1 2
  1968. #define _MM_HINT_T2 1
  1969. #define _MM_HINT_NTA 0
  1970. #ifndef _MSC_VER
  1971. /* FIXME: We have to #define this because "sel" must be a constant integer, and
  1972. Sema doesn't do any form of constant propagation yet. */
  1973. /// Loads one cache line of data from the specified address to a location
  1974. /// closer to the processor.
  1975. ///
  1976. /// \headerfile <x86intrin.h>
  1977. ///
  1978. /// \code
  1979. /// void _mm_prefetch(const void * a, const int sel);
  1980. /// \endcode
  1981. ///
  1982. /// This intrinsic corresponds to the <c> PREFETCHNTA </c> instruction.
  1983. ///
  1984. /// \param a
  1985. /// A pointer to a memory location containing a cache line of data.
  1986. /// \param sel
  1987. /// A predefined integer constant specifying the type of prefetch
  1988. /// operation: \n
  1989. /// _MM_HINT_NTA: Move data using the non-temporal access (NTA) hint. The
  1990. /// PREFETCHNTA instruction will be generated. \n
  1991. /// _MM_HINT_T0: Move data using the T0 hint. The PREFETCHT0 instruction will
  1992. /// be generated. \n
  1993. /// _MM_HINT_T1: Move data using the T1 hint. The PREFETCHT1 instruction will
  1994. /// be generated. \n
  1995. /// _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
  1996. /// be generated.
  1997. #define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), \
  1998. ((sel) >> 2) & 1, (sel) & 0x3))
  1999. #endif
  2000. /// Stores a 64-bit integer in the specified aligned memory location. To
  2001. /// minimize caching, the data is flagged as non-temporal (unlikely to be
  2002. /// used again soon).
  2003. ///
  2004. /// \headerfile <x86intrin.h>
  2005. ///
  2006. /// This intrinsic corresponds to the <c> MOVNTQ </c> instruction.
  2007. ///
  2008. /// \param __p
  2009. /// A pointer to an aligned memory location used to store the register value.
  2010. /// \param __a
  2011. /// A 64-bit integer containing the value to be stored.
  2012. static __inline__ void __DEFAULT_FN_ATTRS_MMX
  2013. _mm_stream_pi(__m64 *__p, __m64 __a)
  2014. {
  2015. __builtin_ia32_movntq(__p, __a);
  2016. }
  2017. /// Moves packed float values from a 128-bit vector of [4 x float] to a
  2018. /// 128-bit aligned memory location. To minimize caching, the data is flagged
  2019. /// as non-temporal (unlikely to be used again soon).
  2020. ///
  2021. /// \headerfile <x86intrin.h>
  2022. ///
  2023. /// This intrinsic corresponds to the <c> VMOVNTPS / MOVNTPS </c> instruction.
  2024. ///
  2025. /// \param __p
  2026. /// A pointer to a 128-bit aligned memory location that will receive the
  2027. /// single-precision floating-point values.
  2028. /// \param __a
  2029. /// A 128-bit vector of [4 x float] containing the values to be moved.
  2030. static __inline__ void __DEFAULT_FN_ATTRS
  2031. _mm_stream_ps(float *__p, __m128 __a)
  2032. {
  2033. __builtin_nontemporal_store((__v4sf)__a, (__v4sf*)__p);
  2034. }
  2035. #if defined(__cplusplus)
  2036. extern "C" {
  2037. #endif
  2038. /// Forces strong memory ordering (serialization) between store
  2039. /// instructions preceding this instruction and store instructions following
  2040. /// this instruction, ensuring the system completes all previous stores
  2041. /// before executing subsequent stores.
  2042. ///
  2043. /// \headerfile <x86intrin.h>
  2044. ///
  2045. /// This intrinsic corresponds to the <c> SFENCE </c> instruction.
  2046. ///
  2047. void _mm_sfence(void);
  2048. #if defined(__cplusplus)
  2049. } // extern "C"
  2050. #endif
  2051. /// Extracts 16-bit element from a 64-bit vector of [4 x i16] and
  2052. /// returns it, as specified by the immediate integer operand.
  2053. ///
  2054. /// \headerfile <x86intrin.h>
  2055. ///
  2056. /// \code
  2057. /// int _mm_extract_pi16(__m64 a, int n);
  2058. /// \endcode
  2059. ///
  2060. /// This intrinsic corresponds to the <c> VPEXTRW / PEXTRW </c> instruction.
  2061. ///
  2062. /// \param a
  2063. /// A 64-bit vector of [4 x i16].
  2064. /// \param n
  2065. /// An immediate integer operand that determines which bits are extracted: \n
  2066. /// 0: Bits [15:0] are copied to the destination. \n
  2067. /// 1: Bits [31:16] are copied to the destination. \n
  2068. /// 2: Bits [47:32] are copied to the destination. \n
  2069. /// 3: Bits [63:48] are copied to the destination.
  2070. /// \returns A 16-bit integer containing the extracted 16 bits of packed data.
  2071. #define _mm_extract_pi16(a, n) \
  2072. (int)__builtin_ia32_vec_ext_v4hi((__m64)a, (int)n)
  2073. /// Copies data from the 64-bit vector of [4 x i16] to the destination,
  2074. /// and inserts the lower 16-bits of an integer operand at the 16-bit offset
  2075. /// specified by the immediate operand \a n.
  2076. ///
  2077. /// \headerfile <x86intrin.h>
  2078. ///
  2079. /// \code
  2080. /// __m64 _mm_insert_pi16(__m64 a, int d, int n);
  2081. /// \endcode
  2082. ///
  2083. /// This intrinsic corresponds to the <c> PINSRW </c> instruction.
  2084. ///
  2085. /// \param a
  2086. /// A 64-bit vector of [4 x i16].
  2087. /// \param d
  2088. /// An integer. The lower 16-bit value from this operand is written to the
  2089. /// destination at the offset specified by operand \a n.
  2090. /// \param n
  2091. /// An immediate integer operant that determines which the bits to be used
  2092. /// in the destination. \n
  2093. /// 0: Bits [15:0] are copied to the destination. \n
  2094. /// 1: Bits [31:16] are copied to the destination. \n
  2095. /// 2: Bits [47:32] are copied to the destination. \n
  2096. /// 3: Bits [63:48] are copied to the destination. \n
  2097. /// The remaining bits in the destination are copied from the corresponding
  2098. /// bits in operand \a a.
  2099. /// \returns A 64-bit integer vector containing the copied packed data from the
  2100. /// operands.
  2101. #define _mm_insert_pi16(a, d, n) \
  2102. (__m64)__builtin_ia32_vec_set_v4hi((__m64)a, (int)d, (int)n)
  2103. /// Compares each of the corresponding packed 16-bit integer values of
  2104. /// the 64-bit integer vectors, and writes the greater value to the
  2105. /// corresponding bits in the destination.
  2106. ///
  2107. /// \headerfile <x86intrin.h>
  2108. ///
  2109. /// This intrinsic corresponds to the <c> PMAXSW </c> instruction.
  2110. ///
  2111. /// \param __a
  2112. /// A 64-bit integer vector containing one of the source operands.
  2113. /// \param __b
  2114. /// A 64-bit integer vector containing one of the source operands.
  2115. /// \returns A 64-bit integer vector containing the comparison results.
  2116. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2117. _mm_max_pi16(__m64 __a, __m64 __b)
  2118. {
  2119. return (__m64)__builtin_ia32_pmaxsw((__v4hi)__a, (__v4hi)__b);
  2120. }
  2121. /// Compares each of the corresponding packed 8-bit unsigned integer
  2122. /// values of the 64-bit integer vectors, and writes the greater value to the
  2123. /// corresponding bits in the destination.
  2124. ///
  2125. /// \headerfile <x86intrin.h>
  2126. ///
  2127. /// This intrinsic corresponds to the <c> PMAXUB </c> instruction.
  2128. ///
  2129. /// \param __a
  2130. /// A 64-bit integer vector containing one of the source operands.
  2131. /// \param __b
  2132. /// A 64-bit integer vector containing one of the source operands.
  2133. /// \returns A 64-bit integer vector containing the comparison results.
  2134. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2135. _mm_max_pu8(__m64 __a, __m64 __b)
  2136. {
  2137. return (__m64)__builtin_ia32_pmaxub((__v8qi)__a, (__v8qi)__b);
  2138. }
  2139. /// Compares each of the corresponding packed 16-bit integer values of
  2140. /// the 64-bit integer vectors, and writes the lesser value to the
  2141. /// corresponding bits in the destination.
  2142. ///
  2143. /// \headerfile <x86intrin.h>
  2144. ///
  2145. /// This intrinsic corresponds to the <c> PMINSW </c> instruction.
  2146. ///
  2147. /// \param __a
  2148. /// A 64-bit integer vector containing one of the source operands.
  2149. /// \param __b
  2150. /// A 64-bit integer vector containing one of the source operands.
  2151. /// \returns A 64-bit integer vector containing the comparison results.
  2152. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2153. _mm_min_pi16(__m64 __a, __m64 __b)
  2154. {
  2155. return (__m64)__builtin_ia32_pminsw((__v4hi)__a, (__v4hi)__b);
  2156. }
  2157. /// Compares each of the corresponding packed 8-bit unsigned integer
  2158. /// values of the 64-bit integer vectors, and writes the lesser value to the
  2159. /// corresponding bits in the destination.
  2160. ///
  2161. /// \headerfile <x86intrin.h>
  2162. ///
  2163. /// This intrinsic corresponds to the <c> PMINUB </c> instruction.
  2164. ///
  2165. /// \param __a
  2166. /// A 64-bit integer vector containing one of the source operands.
  2167. /// \param __b
  2168. /// A 64-bit integer vector containing one of the source operands.
  2169. /// \returns A 64-bit integer vector containing the comparison results.
  2170. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2171. _mm_min_pu8(__m64 __a, __m64 __b)
  2172. {
  2173. return (__m64)__builtin_ia32_pminub((__v8qi)__a, (__v8qi)__b);
  2174. }
  2175. /// Takes the most significant bit from each 8-bit element in a 64-bit
  2176. /// integer vector to create an 8-bit mask value. Zero-extends the value to
  2177. /// 32-bit integer and writes it to the destination.
  2178. ///
  2179. /// \headerfile <x86intrin.h>
  2180. ///
  2181. /// This intrinsic corresponds to the <c> PMOVMSKB </c> instruction.
  2182. ///
  2183. /// \param __a
  2184. /// A 64-bit integer vector containing the values with bits to be extracted.
  2185. /// \returns The most significant bit from each 8-bit element in \a __a,
  2186. /// written to bits [7:0].
  2187. static __inline__ int __DEFAULT_FN_ATTRS_MMX
  2188. _mm_movemask_pi8(__m64 __a)
  2189. {
  2190. return __builtin_ia32_pmovmskb((__v8qi)__a);
  2191. }
  2192. /// Multiplies packed 16-bit unsigned integer values and writes the
  2193. /// high-order 16 bits of each 32-bit product to the corresponding bits in
  2194. /// the destination.
  2195. ///
  2196. /// \headerfile <x86intrin.h>
  2197. ///
  2198. /// This intrinsic corresponds to the <c> PMULHUW </c> instruction.
  2199. ///
  2200. /// \param __a
  2201. /// A 64-bit integer vector containing one of the source operands.
  2202. /// \param __b
  2203. /// A 64-bit integer vector containing one of the source operands.
  2204. /// \returns A 64-bit integer vector containing the products of both operands.
  2205. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2206. _mm_mulhi_pu16(__m64 __a, __m64 __b)
  2207. {
  2208. return (__m64)__builtin_ia32_pmulhuw((__v4hi)__a, (__v4hi)__b);
  2209. }
  2210. /// Shuffles the 4 16-bit integers from a 64-bit integer vector to the
  2211. /// destination, as specified by the immediate value operand.
  2212. ///
  2213. /// \headerfile <x86intrin.h>
  2214. ///
  2215. /// \code
  2216. /// __m64 _mm_shuffle_pi16(__m64 a, const int n);
  2217. /// \endcode
  2218. ///
  2219. /// This intrinsic corresponds to the <c> PSHUFW </c> instruction.
  2220. ///
  2221. /// \param a
  2222. /// A 64-bit integer vector containing the values to be shuffled.
  2223. /// \param n
  2224. /// An immediate value containing an 8-bit value specifying which elements to
  2225. /// copy from \a a. The destinations within the 64-bit destination are
  2226. /// assigned values as follows: \n
  2227. /// Bits [1:0] are used to assign values to bits [15:0] in the
  2228. /// destination. \n
  2229. /// Bits [3:2] are used to assign values to bits [31:16] in the
  2230. /// destination. \n
  2231. /// Bits [5:4] are used to assign values to bits [47:32] in the
  2232. /// destination. \n
  2233. /// Bits [7:6] are used to assign values to bits [63:48] in the
  2234. /// destination. \n
  2235. /// Bit value assignments: \n
  2236. /// 00: assigned from bits [15:0] of \a a. \n
  2237. /// 01: assigned from bits [31:16] of \a a. \n
  2238. /// 10: assigned from bits [47:32] of \a a. \n
  2239. /// 11: assigned from bits [63:48] of \a a.
  2240. /// \returns A 64-bit integer vector containing the shuffled values.
  2241. #define _mm_shuffle_pi16(a, n) \
  2242. (__m64)__builtin_ia32_pshufw((__v4hi)(__m64)(a), (n))
  2243. /// Conditionally copies the values from each 8-bit element in the first
  2244. /// 64-bit integer vector operand to the specified memory location, as
  2245. /// specified by the most significant bit in the corresponding element in the
  2246. /// second 64-bit integer vector operand.
  2247. ///
  2248. /// To minimize caching, the data is flagged as non-temporal
  2249. /// (unlikely to be used again soon).
  2250. ///
  2251. /// \headerfile <x86intrin.h>
  2252. ///
  2253. /// This intrinsic corresponds to the <c> MASKMOVQ </c> instruction.
  2254. ///
  2255. /// \param __d
  2256. /// A 64-bit integer vector containing the values with elements to be copied.
  2257. /// \param __n
  2258. /// A 64-bit integer vector operand. The most significant bit from each 8-bit
  2259. /// element determines whether the corresponding element in operand \a __d
  2260. /// is copied. If the most significant bit of a given element is 1, the
  2261. /// corresponding element in operand \a __d is copied.
  2262. /// \param __p
  2263. /// A pointer to a 64-bit memory location that will receive the conditionally
  2264. /// copied integer values. The address of the memory location does not have
  2265. /// to be aligned.
  2266. static __inline__ void __DEFAULT_FN_ATTRS_MMX
  2267. _mm_maskmove_si64(__m64 __d, __m64 __n, char *__p)
  2268. {
  2269. __builtin_ia32_maskmovq((__v8qi)__d, (__v8qi)__n, __p);
  2270. }
  2271. /// Computes the rounded averages of the packed unsigned 8-bit integer
  2272. /// values and writes the averages to the corresponding bits in the
  2273. /// destination.
  2274. ///
  2275. /// \headerfile <x86intrin.h>
  2276. ///
  2277. /// This intrinsic corresponds to the <c> PAVGB </c> instruction.
  2278. ///
  2279. /// \param __a
  2280. /// A 64-bit integer vector containing one of the source operands.
  2281. /// \param __b
  2282. /// A 64-bit integer vector containing one of the source operands.
  2283. /// \returns A 64-bit integer vector containing the averages of both operands.
  2284. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2285. _mm_avg_pu8(__m64 __a, __m64 __b)
  2286. {
  2287. return (__m64)__builtin_ia32_pavgb((__v8qi)__a, (__v8qi)__b);
  2288. }
  2289. /// Computes the rounded averages of the packed unsigned 16-bit integer
  2290. /// values and writes the averages to the corresponding bits in the
  2291. /// destination.
  2292. ///
  2293. /// \headerfile <x86intrin.h>
  2294. ///
  2295. /// This intrinsic corresponds to the <c> PAVGW </c> instruction.
  2296. ///
  2297. /// \param __a
  2298. /// A 64-bit integer vector containing one of the source operands.
  2299. /// \param __b
  2300. /// A 64-bit integer vector containing one of the source operands.
  2301. /// \returns A 64-bit integer vector containing the averages of both operands.
  2302. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2303. _mm_avg_pu16(__m64 __a, __m64 __b)
  2304. {
  2305. return (__m64)__builtin_ia32_pavgw((__v4hi)__a, (__v4hi)__b);
  2306. }
  2307. /// Subtracts the corresponding 8-bit unsigned integer values of the two
  2308. /// 64-bit vector operands and computes the absolute value for each of the
  2309. /// difference. Then sum of the 8 absolute differences is written to the
  2310. /// bits [15:0] of the destination; the remaining bits [63:16] are cleared.
  2311. ///
  2312. /// \headerfile <x86intrin.h>
  2313. ///
  2314. /// This intrinsic corresponds to the <c> PSADBW </c> instruction.
  2315. ///
  2316. /// \param __a
  2317. /// A 64-bit integer vector containing one of the source operands.
  2318. /// \param __b
  2319. /// A 64-bit integer vector containing one of the source operands.
  2320. /// \returns A 64-bit integer vector whose lower 16 bits contain the sums of the
  2321. /// sets of absolute differences between both operands. The upper bits are
  2322. /// cleared.
  2323. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2324. _mm_sad_pu8(__m64 __a, __m64 __b)
  2325. {
  2326. return (__m64)__builtin_ia32_psadbw((__v8qi)__a, (__v8qi)__b);
  2327. }
  2328. #if defined(__cplusplus)
  2329. extern "C" {
  2330. #endif
  2331. /// Returns the contents of the MXCSR register as a 32-bit unsigned
  2332. /// integer value.
  2333. ///
  2334. /// There are several groups of macros associated with this
  2335. /// intrinsic, including:
  2336. /// <ul>
  2337. /// <li>
  2338. /// For checking exception states: _MM_EXCEPT_INVALID, _MM_EXCEPT_DIV_ZERO,
  2339. /// _MM_EXCEPT_DENORM, _MM_EXCEPT_OVERFLOW, _MM_EXCEPT_UNDERFLOW,
  2340. /// _MM_EXCEPT_INEXACT. There is a convenience wrapper
  2341. /// _MM_GET_EXCEPTION_STATE().
  2342. /// </li>
  2343. /// <li>
  2344. /// For checking exception masks: _MM_MASK_UNDERFLOW, _MM_MASK_OVERFLOW,
  2345. /// _MM_MASK_INVALID, _MM_MASK_DENORM, _MM_MASK_DIV_ZERO, _MM_MASK_INEXACT.
  2346. /// There is a convenience wrapper _MM_GET_EXCEPTION_MASK().
  2347. /// </li>
  2348. /// <li>
  2349. /// For checking rounding modes: _MM_ROUND_NEAREST, _MM_ROUND_DOWN,
  2350. /// _MM_ROUND_UP, _MM_ROUND_TOWARD_ZERO. There is a convenience wrapper
  2351. /// _MM_GET_ROUNDING_MODE().
  2352. /// </li>
  2353. /// <li>
  2354. /// For checking flush-to-zero mode: _MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_OFF.
  2355. /// There is a convenience wrapper _MM_GET_FLUSH_ZERO_MODE().
  2356. /// </li>
  2357. /// <li>
  2358. /// For checking denormals-are-zero mode: _MM_DENORMALS_ZERO_ON,
  2359. /// _MM_DENORMALS_ZERO_OFF. There is a convenience wrapper
  2360. /// _MM_GET_DENORMALS_ZERO_MODE().
  2361. /// </li>
  2362. /// </ul>
  2363. ///
  2364. /// For example, the following expression checks if an overflow exception has
  2365. /// occurred:
  2366. /// \code
  2367. /// ( _mm_getcsr() & _MM_EXCEPT_OVERFLOW )
  2368. /// \endcode
  2369. ///
  2370. /// The following expression gets the current rounding mode:
  2371. /// \code
  2372. /// _MM_GET_ROUNDING_MODE()
  2373. /// \endcode
  2374. ///
  2375. /// \headerfile <x86intrin.h>
  2376. ///
  2377. /// This intrinsic corresponds to the <c> VSTMXCSR / STMXCSR </c> instruction.
  2378. ///
  2379. /// \returns A 32-bit unsigned integer containing the contents of the MXCSR
  2380. /// register.
  2381. unsigned int _mm_getcsr(void);
  2382. /// Sets the MXCSR register with the 32-bit unsigned integer value.
  2383. ///
  2384. /// There are several groups of macros associated with this intrinsic,
  2385. /// including:
  2386. /// <ul>
  2387. /// <li>
  2388. /// For setting exception states: _MM_EXCEPT_INVALID, _MM_EXCEPT_DIV_ZERO,
  2389. /// _MM_EXCEPT_DENORM, _MM_EXCEPT_OVERFLOW, _MM_EXCEPT_UNDERFLOW,
  2390. /// _MM_EXCEPT_INEXACT. There is a convenience wrapper
  2391. /// _MM_SET_EXCEPTION_STATE(x) where x is one of these macros.
  2392. /// </li>
  2393. /// <li>
  2394. /// For setting exception masks: _MM_MASK_UNDERFLOW, _MM_MASK_OVERFLOW,
  2395. /// _MM_MASK_INVALID, _MM_MASK_DENORM, _MM_MASK_DIV_ZERO, _MM_MASK_INEXACT.
  2396. /// There is a convenience wrapper _MM_SET_EXCEPTION_MASK(x) where x is one
  2397. /// of these macros.
  2398. /// </li>
  2399. /// <li>
  2400. /// For setting rounding modes: _MM_ROUND_NEAREST, _MM_ROUND_DOWN,
  2401. /// _MM_ROUND_UP, _MM_ROUND_TOWARD_ZERO. There is a convenience wrapper
  2402. /// _MM_SET_ROUNDING_MODE(x) where x is one of these macros.
  2403. /// </li>
  2404. /// <li>
  2405. /// For setting flush-to-zero mode: _MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_OFF.
  2406. /// There is a convenience wrapper _MM_SET_FLUSH_ZERO_MODE(x) where x is
  2407. /// one of these macros.
  2408. /// </li>
  2409. /// <li>
  2410. /// For setting denormals-are-zero mode: _MM_DENORMALS_ZERO_ON,
  2411. /// _MM_DENORMALS_ZERO_OFF. There is a convenience wrapper
  2412. /// _MM_SET_DENORMALS_ZERO_MODE(x) where x is one of these macros.
  2413. /// </li>
  2414. /// </ul>
  2415. ///
  2416. /// For example, the following expression causes subsequent floating-point
  2417. /// operations to round up:
  2418. /// _mm_setcsr(_mm_getcsr() | _MM_ROUND_UP)
  2419. ///
  2420. /// The following example sets the DAZ and FTZ flags:
  2421. /// \code
  2422. /// void setFlags() {
  2423. /// _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
  2424. /// _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
  2425. /// }
  2426. /// \endcode
  2427. ///
  2428. /// \headerfile <x86intrin.h>
  2429. ///
  2430. /// This intrinsic corresponds to the <c> VLDMXCSR / LDMXCSR </c> instruction.
  2431. ///
  2432. /// \param __i
  2433. /// A 32-bit unsigned integer value to be written to the MXCSR register.
  2434. void _mm_setcsr(unsigned int __i);
  2435. #if defined(__cplusplus)
  2436. } // extern "C"
  2437. #endif
  2438. /// Selects 4 float values from the 128-bit operands of [4 x float], as
  2439. /// specified by the immediate value operand.
  2440. ///
  2441. /// \headerfile <x86intrin.h>
  2442. ///
  2443. /// \code
  2444. /// __m128 _mm_shuffle_ps(__m128 a, __m128 b, const int mask);
  2445. /// \endcode
  2446. ///
  2447. /// This intrinsic corresponds to the <c> VSHUFPS / SHUFPS </c> instruction.
  2448. ///
  2449. /// \param a
  2450. /// A 128-bit vector of [4 x float].
  2451. /// \param b
  2452. /// A 128-bit vector of [4 x float].
  2453. /// \param mask
  2454. /// An immediate value containing an 8-bit value specifying which elements to
  2455. /// copy from \a a and \a b. \n
  2456. /// Bits [3:0] specify the values copied from operand \a a. \n
  2457. /// Bits [7:4] specify the values copied from operand \a b. \n
  2458. /// The destinations within the 128-bit destination are assigned values as
  2459. /// follows: \n
  2460. /// Bits [1:0] are used to assign values to bits [31:0] in the
  2461. /// destination. \n
  2462. /// Bits [3:2] are used to assign values to bits [63:32] in the
  2463. /// destination. \n
  2464. /// Bits [5:4] are used to assign values to bits [95:64] in the
  2465. /// destination. \n
  2466. /// Bits [7:6] are used to assign values to bits [127:96] in the
  2467. /// destination. \n
  2468. /// Bit value assignments: \n
  2469. /// 00: Bits [31:0] copied from the specified operand. \n
  2470. /// 01: Bits [63:32] copied from the specified operand. \n
  2471. /// 10: Bits [95:64] copied from the specified operand. \n
  2472. /// 11: Bits [127:96] copied from the specified operand.
  2473. /// \returns A 128-bit vector of [4 x float] containing the shuffled values.
  2474. #define _mm_shuffle_ps(a, b, mask) \
  2475. (__m128)__builtin_ia32_shufps((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), \
  2476. (int)(mask))
  2477. /// Unpacks the high-order (index 2,3) values from two 128-bit vectors of
  2478. /// [4 x float] and interleaves them into a 128-bit vector of [4 x float].
  2479. ///
  2480. /// \headerfile <x86intrin.h>
  2481. ///
  2482. /// This intrinsic corresponds to the <c> VUNPCKHPS / UNPCKHPS </c> instruction.
  2483. ///
  2484. /// \param __a
  2485. /// A 128-bit vector of [4 x float]. \n
  2486. /// Bits [95:64] are written to bits [31:0] of the destination. \n
  2487. /// Bits [127:96] are written to bits [95:64] of the destination.
  2488. /// \param __b
  2489. /// A 128-bit vector of [4 x float].
  2490. /// Bits [95:64] are written to bits [63:32] of the destination. \n
  2491. /// Bits [127:96] are written to bits [127:96] of the destination.
  2492. /// \returns A 128-bit vector of [4 x float] containing the interleaved values.
  2493. static __inline__ __m128 __DEFAULT_FN_ATTRS
  2494. _mm_unpackhi_ps(__m128 __a, __m128 __b)
  2495. {
  2496. return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 2, 6, 3, 7);
  2497. }
  2498. /// Unpacks the low-order (index 0,1) values from two 128-bit vectors of
  2499. /// [4 x float] and interleaves them into a 128-bit vector of [4 x float].
  2500. ///
  2501. /// \headerfile <x86intrin.h>
  2502. ///
  2503. /// This intrinsic corresponds to the <c> VUNPCKLPS / UNPCKLPS </c> instruction.
  2504. ///
  2505. /// \param __a
  2506. /// A 128-bit vector of [4 x float]. \n
  2507. /// Bits [31:0] are written to bits [31:0] of the destination. \n
  2508. /// Bits [63:32] are written to bits [95:64] of the destination.
  2509. /// \param __b
  2510. /// A 128-bit vector of [4 x float]. \n
  2511. /// Bits [31:0] are written to bits [63:32] of the destination. \n
  2512. /// Bits [63:32] are written to bits [127:96] of the destination.
  2513. /// \returns A 128-bit vector of [4 x float] containing the interleaved values.
  2514. static __inline__ __m128 __DEFAULT_FN_ATTRS
  2515. _mm_unpacklo_ps(__m128 __a, __m128 __b)
  2516. {
  2517. return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 0, 4, 1, 5);
  2518. }
  2519. /// Constructs a 128-bit floating-point vector of [4 x float]. The lower
  2520. /// 32 bits are set to the lower 32 bits of the second parameter. The upper
  2521. /// 96 bits are set to the upper 96 bits of the first parameter.
  2522. ///
  2523. /// \headerfile <x86intrin.h>
  2524. ///
  2525. /// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS / MOVSS </c>
  2526. /// instruction.
  2527. ///
  2528. /// \param __a
  2529. /// A 128-bit floating-point vector of [4 x float]. The upper 96 bits are
  2530. /// written to the upper 96 bits of the result.
  2531. /// \param __b
  2532. /// A 128-bit floating-point vector of [4 x float]. The lower 32 bits are
  2533. /// written to the lower 32 bits of the result.
  2534. /// \returns A 128-bit floating-point vector of [4 x float].
  2535. static __inline__ __m128 __DEFAULT_FN_ATTRS
  2536. _mm_move_ss(__m128 __a, __m128 __b)
  2537. {
  2538. __a[0] = __b[0];
  2539. return __a;
  2540. }
  2541. /// Constructs a 128-bit floating-point vector of [4 x float]. The lower
  2542. /// 64 bits are set to the upper 64 bits of the second parameter. The upper
  2543. /// 64 bits are set to the upper 64 bits of the first parameter.
  2544. ///
  2545. /// \headerfile <x86intrin.h>
  2546. ///
  2547. /// This intrinsic corresponds to the <c> VUNPCKHPD / UNPCKHPD </c> instruction.
  2548. ///
  2549. /// \param __a
  2550. /// A 128-bit floating-point vector of [4 x float]. The upper 64 bits are
  2551. /// written to the upper 64 bits of the result.
  2552. /// \param __b
  2553. /// A 128-bit floating-point vector of [4 x float]. The upper 64 bits are
  2554. /// written to the lower 64 bits of the result.
  2555. /// \returns A 128-bit floating-point vector of [4 x float].
  2556. static __inline__ __m128 __DEFAULT_FN_ATTRS
  2557. _mm_movehl_ps(__m128 __a, __m128 __b)
  2558. {
  2559. return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 6, 7, 2, 3);
  2560. }
  2561. /// Constructs a 128-bit floating-point vector of [4 x float]. The lower
  2562. /// 64 bits are set to the lower 64 bits of the first parameter. The upper
  2563. /// 64 bits are set to the lower 64 bits of the second parameter.
  2564. ///
  2565. /// \headerfile <x86intrin.h>
  2566. ///
  2567. /// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
  2568. ///
  2569. /// \param __a
  2570. /// A 128-bit floating-point vector of [4 x float]. The lower 64 bits are
  2571. /// written to the lower 64 bits of the result.
  2572. /// \param __b
  2573. /// A 128-bit floating-point vector of [4 x float]. The lower 64 bits are
  2574. /// written to the upper 64 bits of the result.
  2575. /// \returns A 128-bit floating-point vector of [4 x float].
  2576. static __inline__ __m128 __DEFAULT_FN_ATTRS
  2577. _mm_movelh_ps(__m128 __a, __m128 __b)
  2578. {
  2579. return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 0, 1, 4, 5);
  2580. }
  2581. /// Converts a 64-bit vector of [4 x i16] into a 128-bit vector of [4 x
  2582. /// float].
  2583. ///
  2584. /// \headerfile <x86intrin.h>
  2585. ///
  2586. /// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
  2587. ///
  2588. /// \param __a
  2589. /// A 64-bit vector of [4 x i16]. The elements of the destination are copied
  2590. /// from the corresponding elements in this operand.
  2591. /// \returns A 128-bit vector of [4 x float] containing the copied and converted
  2592. /// values from the operand.
  2593. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  2594. _mm_cvtpi16_ps(__m64 __a)
  2595. {
  2596. __m64 __b, __c;
  2597. __m128 __r;
  2598. __b = _mm_setzero_si64();
  2599. __b = _mm_cmpgt_pi16(__b, __a);
  2600. __c = _mm_unpackhi_pi16(__a, __b);
  2601. __r = _mm_setzero_ps();
  2602. __r = _mm_cvtpi32_ps(__r, __c);
  2603. __r = _mm_movelh_ps(__r, __r);
  2604. __c = _mm_unpacklo_pi16(__a, __b);
  2605. __r = _mm_cvtpi32_ps(__r, __c);
  2606. return __r;
  2607. }
  2608. /// Converts a 64-bit vector of 16-bit unsigned integer values into a
  2609. /// 128-bit vector of [4 x float].
  2610. ///
  2611. /// \headerfile <x86intrin.h>
  2612. ///
  2613. /// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
  2614. ///
  2615. /// \param __a
  2616. /// A 64-bit vector of 16-bit unsigned integer values. The elements of the
  2617. /// destination are copied from the corresponding elements in this operand.
  2618. /// \returns A 128-bit vector of [4 x float] containing the copied and converted
  2619. /// values from the operand.
  2620. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  2621. _mm_cvtpu16_ps(__m64 __a)
  2622. {
  2623. __m64 __b, __c;
  2624. __m128 __r;
  2625. __b = _mm_setzero_si64();
  2626. __c = _mm_unpackhi_pi16(__a, __b);
  2627. __r = _mm_setzero_ps();
  2628. __r = _mm_cvtpi32_ps(__r, __c);
  2629. __r = _mm_movelh_ps(__r, __r);
  2630. __c = _mm_unpacklo_pi16(__a, __b);
  2631. __r = _mm_cvtpi32_ps(__r, __c);
  2632. return __r;
  2633. }
  2634. /// Converts the lower four 8-bit values from a 64-bit vector of [8 x i8]
  2635. /// into a 128-bit vector of [4 x float].
  2636. ///
  2637. /// \headerfile <x86intrin.h>
  2638. ///
  2639. /// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
  2640. ///
  2641. /// \param __a
  2642. /// A 64-bit vector of [8 x i8]. The elements of the destination are copied
  2643. /// from the corresponding lower 4 elements in this operand.
  2644. /// \returns A 128-bit vector of [4 x float] containing the copied and converted
  2645. /// values from the operand.
  2646. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  2647. _mm_cvtpi8_ps(__m64 __a)
  2648. {
  2649. __m64 __b;
  2650. __b = _mm_setzero_si64();
  2651. __b = _mm_cmpgt_pi8(__b, __a);
  2652. __b = _mm_unpacklo_pi8(__a, __b);
  2653. return _mm_cvtpi16_ps(__b);
  2654. }
  2655. /// Converts the lower four unsigned 8-bit integer values from a 64-bit
  2656. /// vector of [8 x u8] into a 128-bit vector of [4 x float].
  2657. ///
  2658. /// \headerfile <x86intrin.h>
  2659. ///
  2660. /// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
  2661. ///
  2662. /// \param __a
  2663. /// A 64-bit vector of unsigned 8-bit integer values. The elements of the
  2664. /// destination are copied from the corresponding lower 4 elements in this
  2665. /// operand.
  2666. /// \returns A 128-bit vector of [4 x float] containing the copied and converted
  2667. /// values from the source operand.
  2668. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  2669. _mm_cvtpu8_ps(__m64 __a)
  2670. {
  2671. __m64 __b;
  2672. __b = _mm_setzero_si64();
  2673. __b = _mm_unpacklo_pi8(__a, __b);
  2674. return _mm_cvtpi16_ps(__b);
  2675. }
  2676. /// Converts the two 32-bit signed integer values from each 64-bit vector
  2677. /// operand of [2 x i32] into a 128-bit vector of [4 x float].
  2678. ///
  2679. /// \headerfile <x86intrin.h>
  2680. ///
  2681. /// This intrinsic corresponds to the <c> CVTPI2PS + COMPOSITE </c> instruction.
  2682. ///
  2683. /// \param __a
  2684. /// A 64-bit vector of [2 x i32]. The lower elements of the destination are
  2685. /// copied from the elements in this operand.
  2686. /// \param __b
  2687. /// A 64-bit vector of [2 x i32]. The upper elements of the destination are
  2688. /// copied from the elements in this operand.
  2689. /// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
  2690. /// copied and converted values from the first operand. The upper 64 bits
  2691. /// contain the copied and converted values from the second operand.
  2692. static __inline__ __m128 __DEFAULT_FN_ATTRS_MMX
  2693. _mm_cvtpi32x2_ps(__m64 __a, __m64 __b)
  2694. {
  2695. __m128 __c;
  2696. __c = _mm_setzero_ps();
  2697. __c = _mm_cvtpi32_ps(__c, __b);
  2698. __c = _mm_movelh_ps(__c, __c);
  2699. return _mm_cvtpi32_ps(__c, __a);
  2700. }
  2701. /// Converts each single-precision floating-point element of a 128-bit
  2702. /// floating-point vector of [4 x float] into a 16-bit signed integer, and
  2703. /// packs the results into a 64-bit integer vector of [4 x i16].
  2704. ///
  2705. /// If the floating-point element is NaN or infinity, or if the
  2706. /// floating-point element is greater than 0x7FFFFFFF or less than -0x8000,
  2707. /// it is converted to 0x8000. Otherwise if the floating-point element is
  2708. /// greater than 0x7FFF, it is converted to 0x7FFF.
  2709. ///
  2710. /// \headerfile <x86intrin.h>
  2711. ///
  2712. /// This intrinsic corresponds to the <c> CVTPS2PI + COMPOSITE </c> instruction.
  2713. ///
  2714. /// \param __a
  2715. /// A 128-bit floating-point vector of [4 x float].
  2716. /// \returns A 64-bit integer vector of [4 x i16] containing the converted
  2717. /// values.
  2718. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2719. _mm_cvtps_pi16(__m128 __a)
  2720. {
  2721. __m64 __b, __c;
  2722. __b = _mm_cvtps_pi32(__a);
  2723. __a = _mm_movehl_ps(__a, __a);
  2724. __c = _mm_cvtps_pi32(__a);
  2725. return _mm_packs_pi32(__b, __c);
  2726. }
  2727. /// Converts each single-precision floating-point element of a 128-bit
  2728. /// floating-point vector of [4 x float] into an 8-bit signed integer, and
  2729. /// packs the results into the lower 32 bits of a 64-bit integer vector of
  2730. /// [8 x i8]. The upper 32 bits of the vector are set to 0.
  2731. ///
  2732. /// If the floating-point element is NaN or infinity, or if the
  2733. /// floating-point element is greater than 0x7FFFFFFF or less than -0x80, it
  2734. /// is converted to 0x80. Otherwise if the floating-point element is greater
  2735. /// than 0x7F, it is converted to 0x7F.
  2736. ///
  2737. /// \headerfile <x86intrin.h>
  2738. ///
  2739. /// This intrinsic corresponds to the <c> CVTPS2PI + COMPOSITE </c> instruction.
  2740. ///
  2741. /// \param __a
  2742. /// 128-bit floating-point vector of [4 x float].
  2743. /// \returns A 64-bit integer vector of [8 x i8]. The lower 32 bits contain the
  2744. /// converted values and the uppper 32 bits are set to zero.
  2745. static __inline__ __m64 __DEFAULT_FN_ATTRS_MMX
  2746. _mm_cvtps_pi8(__m128 __a)
  2747. {
  2748. __m64 __b, __c;
  2749. __b = _mm_cvtps_pi16(__a);
  2750. __c = _mm_setzero_si64();
  2751. return _mm_packs_pi16(__b, __c);
  2752. }
  2753. /// Extracts the sign bits from each single-precision floating-point
  2754. /// element of a 128-bit floating-point vector of [4 x float] and returns the
  2755. /// sign bits in bits [0:3] of the result. Bits [31:4] of the result are set
  2756. /// to zero.
  2757. ///
  2758. /// \headerfile <x86intrin.h>
  2759. ///
  2760. /// This intrinsic corresponds to the <c> VMOVMSKPS / MOVMSKPS </c> instruction.
  2761. ///
  2762. /// \param __a
  2763. /// A 128-bit floating-point vector of [4 x float].
  2764. /// \returns A 32-bit integer value. Bits [3:0] contain the sign bits from each
  2765. /// single-precision floating-point element of the parameter. Bits [31:4] are
  2766. /// set to zero.
  2767. static __inline__ int __DEFAULT_FN_ATTRS
  2768. _mm_movemask_ps(__m128 __a)
  2769. {
  2770. return __builtin_ia32_movmskps((__v4sf)__a);
  2771. }
  2772. #define _MM_ALIGN16 __attribute__((aligned(16)))
  2773. #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
  2774. #define _MM_EXCEPT_INVALID (0x0001)
  2775. #define _MM_EXCEPT_DENORM (0x0002)
  2776. #define _MM_EXCEPT_DIV_ZERO (0x0004)
  2777. #define _MM_EXCEPT_OVERFLOW (0x0008)
  2778. #define _MM_EXCEPT_UNDERFLOW (0x0010)
  2779. #define _MM_EXCEPT_INEXACT (0x0020)
  2780. #define _MM_EXCEPT_MASK (0x003f)
  2781. #define _MM_MASK_INVALID (0x0080)
  2782. #define _MM_MASK_DENORM (0x0100)
  2783. #define _MM_MASK_DIV_ZERO (0x0200)
  2784. #define _MM_MASK_OVERFLOW (0x0400)
  2785. #define _MM_MASK_UNDERFLOW (0x0800)
  2786. #define _MM_MASK_INEXACT (0x1000)
  2787. #define _MM_MASK_MASK (0x1f80)
  2788. #define _MM_ROUND_NEAREST (0x0000)
  2789. #define _MM_ROUND_DOWN (0x2000)
  2790. #define _MM_ROUND_UP (0x4000)
  2791. #define _MM_ROUND_TOWARD_ZERO (0x6000)
  2792. #define _MM_ROUND_MASK (0x6000)
  2793. #define _MM_FLUSH_ZERO_MASK (0x8000)
  2794. #define _MM_FLUSH_ZERO_ON (0x8000)
  2795. #define _MM_FLUSH_ZERO_OFF (0x0000)
  2796. #define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)
  2797. #define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK)
  2798. #define _MM_GET_FLUSH_ZERO_MODE() (_mm_getcsr() & _MM_FLUSH_ZERO_MASK)
  2799. #define _MM_GET_ROUNDING_MODE() (_mm_getcsr() & _MM_ROUND_MASK)
  2800. #define _MM_SET_EXCEPTION_MASK(x) (_mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | (x)))
  2801. #define _MM_SET_EXCEPTION_STATE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | (x)))
  2802. #define _MM_SET_FLUSH_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | (x)))
  2803. #define _MM_SET_ROUNDING_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | (x)))
  2804. #define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \
  2805. do { \
  2806. __m128 tmp3, tmp2, tmp1, tmp0; \
  2807. tmp0 = _mm_unpacklo_ps((row0), (row1)); \
  2808. tmp2 = _mm_unpacklo_ps((row2), (row3)); \
  2809. tmp1 = _mm_unpackhi_ps((row0), (row1)); \
  2810. tmp3 = _mm_unpackhi_ps((row2), (row3)); \
  2811. (row0) = _mm_movelh_ps(tmp0, tmp2); \
  2812. (row1) = _mm_movehl_ps(tmp2, tmp0); \
  2813. (row2) = _mm_movelh_ps(tmp1, tmp3); \
  2814. (row3) = _mm_movehl_ps(tmp3, tmp1); \
  2815. } while (0)
  2816. /* Aliases for compatibility. */
  2817. #define _m_pextrw _mm_extract_pi16
  2818. #define _m_pinsrw _mm_insert_pi16
  2819. #define _m_pmaxsw _mm_max_pi16
  2820. #define _m_pmaxub _mm_max_pu8
  2821. #define _m_pminsw _mm_min_pi16
  2822. #define _m_pminub _mm_min_pu8
  2823. #define _m_pmovmskb _mm_movemask_pi8
  2824. #define _m_pmulhuw _mm_mulhi_pu16
  2825. #define _m_pshufw _mm_shuffle_pi16
  2826. #define _m_maskmovq _mm_maskmove_si64
  2827. #define _m_pavgb _mm_avg_pu8
  2828. #define _m_pavgw _mm_avg_pu16
  2829. #define _m_psadbw _mm_sad_pu8
  2830. #define _m_ _mm_
  2831. #define _m_ _mm_
  2832. #undef __DEFAULT_FN_ATTRS
  2833. #undef __DEFAULT_FN_ATTRS_MMX
  2834. /* Ugly hack for backwards-compatibility (compatible with gcc) */
  2835. #if defined(__SSE2__) && !__building_module(_Builtin_intrinsics)
  2836. #include <emmintrin.h>
  2837. #endif
  2838. #endif /* __XMMINTRIN_H */