xmmintrin.h 106 KB

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