avxintrin.h 198 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162
  1. /*===---- avxintrin.h - AVX 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 __IMMINTRIN_H
  24. #error "Never use <avxintrin.h> directly; include <immintrin.h> instead."
  25. #endif
  26. #ifndef __AVXINTRIN_H
  27. #define __AVXINTRIN_H
  28. typedef double __v4df __attribute__ ((__vector_size__ (32)));
  29. typedef float __v8sf __attribute__ ((__vector_size__ (32)));
  30. typedef long long __v4di __attribute__ ((__vector_size__ (32)));
  31. typedef int __v8si __attribute__ ((__vector_size__ (32)));
  32. typedef short __v16hi __attribute__ ((__vector_size__ (32)));
  33. typedef char __v32qi __attribute__ ((__vector_size__ (32)));
  34. /* Unsigned types */
  35. typedef unsigned long long __v4du __attribute__ ((__vector_size__ (32)));
  36. typedef unsigned int __v8su __attribute__ ((__vector_size__ (32)));
  37. typedef unsigned short __v16hu __attribute__ ((__vector_size__ (32)));
  38. typedef unsigned char __v32qu __attribute__ ((__vector_size__ (32)));
  39. /* We need an explicitly signed variant for char. Note that this shouldn't
  40. * appear in the interface though. */
  41. typedef signed char __v32qs __attribute__((__vector_size__(32)));
  42. typedef float __m256 __attribute__ ((__vector_size__ (32)));
  43. typedef double __m256d __attribute__((__vector_size__(32)));
  44. typedef long long __m256i __attribute__((__vector_size__(32)));
  45. /* Define the default attributes for the functions in this file. */
  46. #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx")))
  47. /* Arithmetic */
  48. /// \brief Adds two 256-bit vectors of [4 x double].
  49. ///
  50. /// \headerfile <x86intrin.h>
  51. ///
  52. /// This intrinsic corresponds to the <c> VADDPD </c> instruction.
  53. ///
  54. /// \param __a
  55. /// A 256-bit vector of [4 x double] containing one of the source operands.
  56. /// \param __b
  57. /// A 256-bit vector of [4 x double] containing one of the source operands.
  58. /// \returns A 256-bit vector of [4 x double] containing the sums of both
  59. /// operands.
  60. static __inline __m256d __DEFAULT_FN_ATTRS
  61. _mm256_add_pd(__m256d __a, __m256d __b)
  62. {
  63. return (__m256d)((__v4df)__a+(__v4df)__b);
  64. }
  65. /// \brief Adds two 256-bit vectors of [8 x float].
  66. ///
  67. /// \headerfile <x86intrin.h>
  68. ///
  69. /// This intrinsic corresponds to the <c> VADDPS </c> instruction.
  70. ///
  71. /// \param __a
  72. /// A 256-bit vector of [8 x float] containing one of the source operands.
  73. /// \param __b
  74. /// A 256-bit vector of [8 x float] containing one of the source operands.
  75. /// \returns A 256-bit vector of [8 x float] containing the sums of both
  76. /// operands.
  77. static __inline __m256 __DEFAULT_FN_ATTRS
  78. _mm256_add_ps(__m256 __a, __m256 __b)
  79. {
  80. return (__m256)((__v8sf)__a+(__v8sf)__b);
  81. }
  82. /// \brief Subtracts two 256-bit vectors of [4 x double].
  83. ///
  84. /// \headerfile <x86intrin.h>
  85. ///
  86. /// This intrinsic corresponds to the <c> VSUBPD </c> instruction.
  87. ///
  88. /// \param __a
  89. /// A 256-bit vector of [4 x double] containing the minuend.
  90. /// \param __b
  91. /// A 256-bit vector of [4 x double] containing the subtrahend.
  92. /// \returns A 256-bit vector of [4 x double] containing the differences between
  93. /// both operands.
  94. static __inline __m256d __DEFAULT_FN_ATTRS
  95. _mm256_sub_pd(__m256d __a, __m256d __b)
  96. {
  97. return (__m256d)((__v4df)__a-(__v4df)__b);
  98. }
  99. /// \brief Subtracts two 256-bit vectors of [8 x float].
  100. ///
  101. /// \headerfile <x86intrin.h>
  102. ///
  103. /// This intrinsic corresponds to the <c> VSUBPS </c> instruction.
  104. ///
  105. /// \param __a
  106. /// A 256-bit vector of [8 x float] containing the minuend.
  107. /// \param __b
  108. /// A 256-bit vector of [8 x float] containing the subtrahend.
  109. /// \returns A 256-bit vector of [8 x float] containing the differences between
  110. /// both operands.
  111. static __inline __m256 __DEFAULT_FN_ATTRS
  112. _mm256_sub_ps(__m256 __a, __m256 __b)
  113. {
  114. return (__m256)((__v8sf)__a-(__v8sf)__b);
  115. }
  116. /// \brief Adds the even-indexed values and subtracts the odd-indexed values of
  117. /// two 256-bit vectors of [4 x double].
  118. ///
  119. /// \headerfile <x86intrin.h>
  120. ///
  121. /// This intrinsic corresponds to the <c> VADDSUBPD </c> instruction.
  122. ///
  123. /// \param __a
  124. /// A 256-bit vector of [4 x double] containing the left source operand.
  125. /// \param __b
  126. /// A 256-bit vector of [4 x double] containing the right source operand.
  127. /// \returns A 256-bit vector of [4 x double] containing the alternating sums
  128. /// and differences between both operands.
  129. static __inline __m256d __DEFAULT_FN_ATTRS
  130. _mm256_addsub_pd(__m256d __a, __m256d __b)
  131. {
  132. return (__m256d)__builtin_ia32_addsubpd256((__v4df)__a, (__v4df)__b);
  133. }
  134. /// \brief Adds the even-indexed values and subtracts the odd-indexed values of
  135. /// two 256-bit vectors of [8 x float].
  136. ///
  137. /// \headerfile <x86intrin.h>
  138. ///
  139. /// This intrinsic corresponds to the <c> VADDSUBPS </c> instruction.
  140. ///
  141. /// \param __a
  142. /// A 256-bit vector of [8 x float] containing the left source operand.
  143. /// \param __b
  144. /// A 256-bit vector of [8 x float] containing the right source operand.
  145. /// \returns A 256-bit vector of [8 x float] containing the alternating sums and
  146. /// differences between both operands.
  147. static __inline __m256 __DEFAULT_FN_ATTRS
  148. _mm256_addsub_ps(__m256 __a, __m256 __b)
  149. {
  150. return (__m256)__builtin_ia32_addsubps256((__v8sf)__a, (__v8sf)__b);
  151. }
  152. /// \brief Divides two 256-bit vectors of [4 x double].
  153. ///
  154. /// \headerfile <x86intrin.h>
  155. ///
  156. /// This intrinsic corresponds to the <c> VDIVPD </c> instruction.
  157. ///
  158. /// \param __a
  159. /// A 256-bit vector of [4 x double] containing the dividend.
  160. /// \param __b
  161. /// A 256-bit vector of [4 x double] containing the divisor.
  162. /// \returns A 256-bit vector of [4 x double] containing the quotients of both
  163. /// operands.
  164. static __inline __m256d __DEFAULT_FN_ATTRS
  165. _mm256_div_pd(__m256d __a, __m256d __b)
  166. {
  167. return (__m256d)((__v4df)__a/(__v4df)__b);
  168. }
  169. /// \brief Divides two 256-bit vectors of [8 x float].
  170. ///
  171. /// \headerfile <x86intrin.h>
  172. ///
  173. /// This intrinsic corresponds to the <c> VDIVPS </c> instruction.
  174. ///
  175. /// \param __a
  176. /// A 256-bit vector of [8 x float] containing the dividend.
  177. /// \param __b
  178. /// A 256-bit vector of [8 x float] containing the divisor.
  179. /// \returns A 256-bit vector of [8 x float] containing the quotients of both
  180. /// operands.
  181. static __inline __m256 __DEFAULT_FN_ATTRS
  182. _mm256_div_ps(__m256 __a, __m256 __b)
  183. {
  184. return (__m256)((__v8sf)__a/(__v8sf)__b);
  185. }
  186. /// \brief Compares two 256-bit vectors of [4 x double] and returns the greater
  187. /// of each pair of values.
  188. ///
  189. /// \headerfile <x86intrin.h>
  190. ///
  191. /// This intrinsic corresponds to the <c> VMAXPD </c> instruction.
  192. ///
  193. /// \param __a
  194. /// A 256-bit vector of [4 x double] containing one of the operands.
  195. /// \param __b
  196. /// A 256-bit vector of [4 x double] containing one of the operands.
  197. /// \returns A 256-bit vector of [4 x double] containing the maximum values
  198. /// between both operands.
  199. static __inline __m256d __DEFAULT_FN_ATTRS
  200. _mm256_max_pd(__m256d __a, __m256d __b)
  201. {
  202. return (__m256d)__builtin_ia32_maxpd256((__v4df)__a, (__v4df)__b);
  203. }
  204. /// \brief Compares two 256-bit vectors of [8 x float] and returns the greater
  205. /// of each pair of values.
  206. ///
  207. /// \headerfile <x86intrin.h>
  208. ///
  209. /// This intrinsic corresponds to the <c> VMAXPS </c> instruction.
  210. ///
  211. /// \param __a
  212. /// A 256-bit vector of [8 x float] containing one of the operands.
  213. /// \param __b
  214. /// A 256-bit vector of [8 x float] containing one of the operands.
  215. /// \returns A 256-bit vector of [8 x float] containing the maximum values
  216. /// between both operands.
  217. static __inline __m256 __DEFAULT_FN_ATTRS
  218. _mm256_max_ps(__m256 __a, __m256 __b)
  219. {
  220. return (__m256)__builtin_ia32_maxps256((__v8sf)__a, (__v8sf)__b);
  221. }
  222. /// \brief Compares two 256-bit vectors of [4 x double] and returns the lesser
  223. /// of each pair of values.
  224. ///
  225. /// \headerfile <x86intrin.h>
  226. ///
  227. /// This intrinsic corresponds to the <c> VMINPD </c> instruction.
  228. ///
  229. /// \param __a
  230. /// A 256-bit vector of [4 x double] containing one of the operands.
  231. /// \param __b
  232. /// A 256-bit vector of [4 x double] containing one of the operands.
  233. /// \returns A 256-bit vector of [4 x double] containing the minimum values
  234. /// between both operands.
  235. static __inline __m256d __DEFAULT_FN_ATTRS
  236. _mm256_min_pd(__m256d __a, __m256d __b)
  237. {
  238. return (__m256d)__builtin_ia32_minpd256((__v4df)__a, (__v4df)__b);
  239. }
  240. /// \brief Compares two 256-bit vectors of [8 x float] and returns the lesser
  241. /// of each pair of values.
  242. ///
  243. /// \headerfile <x86intrin.h>
  244. ///
  245. /// This intrinsic corresponds to the <c> VMINPS </c> instruction.
  246. ///
  247. /// \param __a
  248. /// A 256-bit vector of [8 x float] containing one of the operands.
  249. /// \param __b
  250. /// A 256-bit vector of [8 x float] containing one of the operands.
  251. /// \returns A 256-bit vector of [8 x float] containing the minimum values
  252. /// between both operands.
  253. static __inline __m256 __DEFAULT_FN_ATTRS
  254. _mm256_min_ps(__m256 __a, __m256 __b)
  255. {
  256. return (__m256)__builtin_ia32_minps256((__v8sf)__a, (__v8sf)__b);
  257. }
  258. /// \brief Multiplies two 256-bit vectors of [4 x double].
  259. ///
  260. /// \headerfile <x86intrin.h>
  261. ///
  262. /// This intrinsic corresponds to the <c> VMULPD </c> instruction.
  263. ///
  264. /// \param __a
  265. /// A 256-bit vector of [4 x double] containing one of the operands.
  266. /// \param __b
  267. /// A 256-bit vector of [4 x double] containing one of the operands.
  268. /// \returns A 256-bit vector of [4 x double] containing the products of both
  269. /// operands.
  270. static __inline __m256d __DEFAULT_FN_ATTRS
  271. _mm256_mul_pd(__m256d __a, __m256d __b)
  272. {
  273. return (__m256d)((__v4df)__a * (__v4df)__b);
  274. }
  275. /// \brief Multiplies two 256-bit vectors of [8 x float].
  276. ///
  277. /// \headerfile <x86intrin.h>
  278. ///
  279. /// This intrinsic corresponds to the <c> VMULPS </c> instruction.
  280. ///
  281. /// \param __a
  282. /// A 256-bit vector of [8 x float] containing one of the operands.
  283. /// \param __b
  284. /// A 256-bit vector of [8 x float] containing one of the operands.
  285. /// \returns A 256-bit vector of [8 x float] containing the products of both
  286. /// operands.
  287. static __inline __m256 __DEFAULT_FN_ATTRS
  288. _mm256_mul_ps(__m256 __a, __m256 __b)
  289. {
  290. return (__m256)((__v8sf)__a * (__v8sf)__b);
  291. }
  292. /// \brief Calculates the square roots of the values in a 256-bit vector of
  293. /// [4 x double].
  294. ///
  295. /// \headerfile <x86intrin.h>
  296. ///
  297. /// This intrinsic corresponds to the <c> VSQRTPD </c> instruction.
  298. ///
  299. /// \param __a
  300. /// A 256-bit vector of [4 x double].
  301. /// \returns A 256-bit vector of [4 x double] containing the square roots of the
  302. /// values in the operand.
  303. static __inline __m256d __DEFAULT_FN_ATTRS
  304. _mm256_sqrt_pd(__m256d __a)
  305. {
  306. return (__m256d)__builtin_ia32_sqrtpd256((__v4df)__a);
  307. }
  308. /// \brief Calculates the square roots of the values in a 256-bit vector of
  309. /// [8 x float].
  310. ///
  311. /// \headerfile <x86intrin.h>
  312. ///
  313. /// This intrinsic corresponds to the <c> VSQRTPS </c> instruction.
  314. ///
  315. /// \param __a
  316. /// A 256-bit vector of [8 x float].
  317. /// \returns A 256-bit vector of [8 x float] containing the square roots of the
  318. /// values in the operand.
  319. static __inline __m256 __DEFAULT_FN_ATTRS
  320. _mm256_sqrt_ps(__m256 __a)
  321. {
  322. return (__m256)__builtin_ia32_sqrtps256((__v8sf)__a);
  323. }
  324. /// \brief Calculates the reciprocal square roots of the values in a 256-bit
  325. /// vector of [8 x float].
  326. ///
  327. /// \headerfile <x86intrin.h>
  328. ///
  329. /// This intrinsic corresponds to the <c> VRSQRTPS </c> instruction.
  330. ///
  331. /// \param __a
  332. /// A 256-bit vector of [8 x float].
  333. /// \returns A 256-bit vector of [8 x float] containing the reciprocal square
  334. /// roots of the values in the operand.
  335. static __inline __m256 __DEFAULT_FN_ATTRS
  336. _mm256_rsqrt_ps(__m256 __a)
  337. {
  338. return (__m256)__builtin_ia32_rsqrtps256((__v8sf)__a);
  339. }
  340. /// \brief Calculates the reciprocals of the values in a 256-bit vector of
  341. /// [8 x float].
  342. ///
  343. /// \headerfile <x86intrin.h>
  344. ///
  345. /// This intrinsic corresponds to the <c> VRCPPS </c> instruction.
  346. ///
  347. /// \param __a
  348. /// A 256-bit vector of [8 x float].
  349. /// \returns A 256-bit vector of [8 x float] containing the reciprocals of the
  350. /// values in the operand.
  351. static __inline __m256 __DEFAULT_FN_ATTRS
  352. _mm256_rcp_ps(__m256 __a)
  353. {
  354. return (__m256)__builtin_ia32_rcpps256((__v8sf)__a);
  355. }
  356. /// \brief Rounds the values in a 256-bit vector of [4 x double] as specified
  357. /// by the byte operand. The source values are rounded to integer values and
  358. /// returned as 64-bit double-precision floating-point values.
  359. ///
  360. /// \headerfile <x86intrin.h>
  361. ///
  362. /// \code
  363. /// __m256d _mm256_round_pd(__m256d V, const int M);
  364. /// \endcode
  365. ///
  366. /// This intrinsic corresponds to the <c> VROUNDPD </c> instruction.
  367. ///
  368. /// \param V
  369. /// A 256-bit vector of [4 x double].
  370. /// \param M
  371. /// An integer value that specifies the rounding operation. \n
  372. /// Bits [7:4] are reserved. \n
  373. /// Bit [3] is a precision exception value: \n
  374. /// 0: A normal PE exception is used. \n
  375. /// 1: The PE field is not updated. \n
  376. /// Bit [2] is the rounding control source: \n
  377. /// 0: Use bits [1:0] of \a M. \n
  378. /// 1: Use the current MXCSR setting. \n
  379. /// Bits [1:0] contain the rounding control definition: \n
  380. /// 00: Nearest. \n
  381. /// 01: Downward (toward negative infinity). \n
  382. /// 10: Upward (toward positive infinity). \n
  383. /// 11: Truncated.
  384. /// \returns A 256-bit vector of [4 x double] containing the rounded values.
  385. #define _mm256_round_pd(V, M) __extension__ ({ \
  386. (__m256d)__builtin_ia32_roundpd256((__v4df)(__m256d)(V), (M)); })
  387. /// \brief Rounds the values stored in a 256-bit vector of [8 x float] as
  388. /// specified by the byte operand. The source values are rounded to integer
  389. /// values and returned as floating-point values.
  390. ///
  391. /// \headerfile <x86intrin.h>
  392. ///
  393. /// \code
  394. /// __m256 _mm256_round_ps(__m256 V, const int M);
  395. /// \endcode
  396. ///
  397. /// This intrinsic corresponds to the <c> VROUNDPS </c> instruction.
  398. ///
  399. /// \param V
  400. /// A 256-bit vector of [8 x float].
  401. /// \param M
  402. /// An integer value that specifies the rounding operation. \n
  403. /// Bits [7:4] are reserved. \n
  404. /// Bit [3] is a precision exception value: \n
  405. /// 0: A normal PE exception is used. \n
  406. /// 1: The PE field is not updated. \n
  407. /// Bit [2] is the rounding control source: \n
  408. /// 0: Use bits [1:0] of \a M. \n
  409. /// 1: Use the current MXCSR setting. \n
  410. /// Bits [1:0] contain the rounding control definition: \n
  411. /// 00: Nearest. \n
  412. /// 01: Downward (toward negative infinity). \n
  413. /// 10: Upward (toward positive infinity). \n
  414. /// 11: Truncated.
  415. /// \returns A 256-bit vector of [8 x float] containing the rounded values.
  416. #define _mm256_round_ps(V, M) __extension__ ({ \
  417. (__m256)__builtin_ia32_roundps256((__v8sf)(__m256)(V), (M)); })
  418. /// \brief Rounds up the values stored in a 256-bit vector of [4 x double]. The
  419. /// source values are rounded up to integer values and returned as 64-bit
  420. /// double-precision floating-point values.
  421. ///
  422. /// \headerfile <x86intrin.h>
  423. ///
  424. /// \code
  425. /// __m256d _mm256_ceil_pd(__m256d V);
  426. /// \endcode
  427. ///
  428. /// This intrinsic corresponds to the <c> VROUNDPD </c> instruction.
  429. ///
  430. /// \param V
  431. /// A 256-bit vector of [4 x double].
  432. /// \returns A 256-bit vector of [4 x double] containing the rounded up values.
  433. #define _mm256_ceil_pd(V) _mm256_round_pd((V), _MM_FROUND_CEIL)
  434. /// \brief Rounds down the values stored in a 256-bit vector of [4 x double].
  435. /// The source values are rounded down to integer values and returned as
  436. /// 64-bit double-precision floating-point values.
  437. ///
  438. /// \headerfile <x86intrin.h>
  439. ///
  440. /// \code
  441. /// __m256d _mm256_floor_pd(__m256d V);
  442. /// \endcode
  443. ///
  444. /// This intrinsic corresponds to the <c> VROUNDPD </c> instruction.
  445. ///
  446. /// \param V
  447. /// A 256-bit vector of [4 x double].
  448. /// \returns A 256-bit vector of [4 x double] containing the rounded down
  449. /// values.
  450. #define _mm256_floor_pd(V) _mm256_round_pd((V), _MM_FROUND_FLOOR)
  451. /// \brief Rounds up the values stored in a 256-bit vector of [8 x float]. The
  452. /// source values are rounded up to integer values and returned as
  453. /// floating-point values.
  454. ///
  455. /// \headerfile <x86intrin.h>
  456. ///
  457. /// \code
  458. /// __m256 _mm256_ceil_ps(__m256 V);
  459. /// \endcode
  460. ///
  461. /// This intrinsic corresponds to the <c> VROUNDPS </c> instruction.
  462. ///
  463. /// \param V
  464. /// A 256-bit vector of [8 x float].
  465. /// \returns A 256-bit vector of [8 x float] containing the rounded up values.
  466. #define _mm256_ceil_ps(V) _mm256_round_ps((V), _MM_FROUND_CEIL)
  467. /// \brief Rounds down the values stored in a 256-bit vector of [8 x float]. The
  468. /// source values are rounded down to integer values and returned as
  469. /// floating-point values.
  470. ///
  471. /// \headerfile <x86intrin.h>
  472. ///
  473. /// \code
  474. /// __m256 _mm256_floor_ps(__m256 V);
  475. /// \endcode
  476. ///
  477. /// This intrinsic corresponds to the <c> VROUNDPS </c> instruction.
  478. ///
  479. /// \param V
  480. /// A 256-bit vector of [8 x float].
  481. /// \returns A 256-bit vector of [8 x float] containing the rounded down values.
  482. #define _mm256_floor_ps(V) _mm256_round_ps((V), _MM_FROUND_FLOOR)
  483. /* Logical */
  484. /// \brief Performs a bitwise AND of two 256-bit vectors of [4 x double].
  485. ///
  486. /// \headerfile <x86intrin.h>
  487. ///
  488. /// This intrinsic corresponds to the <c> VANDPD </c> instruction.
  489. ///
  490. /// \param __a
  491. /// A 256-bit vector of [4 x double] containing one of the source operands.
  492. /// \param __b
  493. /// A 256-bit vector of [4 x double] containing one of the source operands.
  494. /// \returns A 256-bit vector of [4 x double] containing the bitwise AND of the
  495. /// values between both operands.
  496. static __inline __m256d __DEFAULT_FN_ATTRS
  497. _mm256_and_pd(__m256d __a, __m256d __b)
  498. {
  499. return (__m256d)((__v4du)__a & (__v4du)__b);
  500. }
  501. /// \brief Performs a bitwise AND of two 256-bit vectors of [8 x float].
  502. ///
  503. /// \headerfile <x86intrin.h>
  504. ///
  505. /// This intrinsic corresponds to the <c> VANDPS </c> instruction.
  506. ///
  507. /// \param __a
  508. /// A 256-bit vector of [8 x float] containing one of the source operands.
  509. /// \param __b
  510. /// A 256-bit vector of [8 x float] containing one of the source operands.
  511. /// \returns A 256-bit vector of [8 x float] containing the bitwise AND of the
  512. /// values between both operands.
  513. static __inline __m256 __DEFAULT_FN_ATTRS
  514. _mm256_and_ps(__m256 __a, __m256 __b)
  515. {
  516. return (__m256)((__v8su)__a & (__v8su)__b);
  517. }
  518. /// \brief Performs a bitwise AND of two 256-bit vectors of [4 x double], using
  519. /// the one's complement of the values contained in the first source operand.
  520. ///
  521. /// \headerfile <x86intrin.h>
  522. ///
  523. /// This intrinsic corresponds to the <c> VANDNPD </c> instruction.
  524. ///
  525. /// \param __a
  526. /// A 256-bit vector of [4 x double] containing the left source operand. The
  527. /// one's complement of this value is used in the bitwise AND.
  528. /// \param __b
  529. /// A 256-bit vector of [4 x double] containing the right source operand.
  530. /// \returns A 256-bit vector of [4 x double] containing the bitwise AND of the
  531. /// values of the second operand and the one's complement of the first
  532. /// operand.
  533. static __inline __m256d __DEFAULT_FN_ATTRS
  534. _mm256_andnot_pd(__m256d __a, __m256d __b)
  535. {
  536. return (__m256d)(~(__v4du)__a & (__v4du)__b);
  537. }
  538. /// \brief Performs a bitwise AND of two 256-bit vectors of [8 x float], using
  539. /// the one's complement of the values contained in the first source operand.
  540. ///
  541. /// \headerfile <x86intrin.h>
  542. ///
  543. /// This intrinsic corresponds to the <c> VANDNPS </c> instruction.
  544. ///
  545. /// \param __a
  546. /// A 256-bit vector of [8 x float] containing the left source operand. The
  547. /// one's complement of this value is used in the bitwise AND.
  548. /// \param __b
  549. /// A 256-bit vector of [8 x float] containing the right source operand.
  550. /// \returns A 256-bit vector of [8 x float] containing the bitwise AND of the
  551. /// values of the second operand and the one's complement of the first
  552. /// operand.
  553. static __inline __m256 __DEFAULT_FN_ATTRS
  554. _mm256_andnot_ps(__m256 __a, __m256 __b)
  555. {
  556. return (__m256)(~(__v8su)__a & (__v8su)__b);
  557. }
  558. /// \brief Performs a bitwise OR of two 256-bit vectors of [4 x double].
  559. ///
  560. /// \headerfile <x86intrin.h>
  561. ///
  562. /// This intrinsic corresponds to the <c> VORPD </c> instruction.
  563. ///
  564. /// \param __a
  565. /// A 256-bit vector of [4 x double] containing one of the source operands.
  566. /// \param __b
  567. /// A 256-bit vector of [4 x double] containing one of the source operands.
  568. /// \returns A 256-bit vector of [4 x double] containing the bitwise OR of the
  569. /// values between both operands.
  570. static __inline __m256d __DEFAULT_FN_ATTRS
  571. _mm256_or_pd(__m256d __a, __m256d __b)
  572. {
  573. return (__m256d)((__v4du)__a | (__v4du)__b);
  574. }
  575. /// \brief Performs a bitwise OR of two 256-bit vectors of [8 x float].
  576. ///
  577. /// \headerfile <x86intrin.h>
  578. ///
  579. /// This intrinsic corresponds to the <c> VORPS </c> instruction.
  580. ///
  581. /// \param __a
  582. /// A 256-bit vector of [8 x float] containing one of the source operands.
  583. /// \param __b
  584. /// A 256-bit vector of [8 x float] containing one of the source operands.
  585. /// \returns A 256-bit vector of [8 x float] containing the bitwise OR of the
  586. /// values between both operands.
  587. static __inline __m256 __DEFAULT_FN_ATTRS
  588. _mm256_or_ps(__m256 __a, __m256 __b)
  589. {
  590. return (__m256)((__v8su)__a | (__v8su)__b);
  591. }
  592. /// \brief Performs a bitwise XOR of two 256-bit vectors of [4 x double].
  593. ///
  594. /// \headerfile <x86intrin.h>
  595. ///
  596. /// This intrinsic corresponds to the <c> VXORPD </c> instruction.
  597. ///
  598. /// \param __a
  599. /// A 256-bit vector of [4 x double] containing one of the source operands.
  600. /// \param __b
  601. /// A 256-bit vector of [4 x double] containing one of the source operands.
  602. /// \returns A 256-bit vector of [4 x double] containing the bitwise XOR of the
  603. /// values between both operands.
  604. static __inline __m256d __DEFAULT_FN_ATTRS
  605. _mm256_xor_pd(__m256d __a, __m256d __b)
  606. {
  607. return (__m256d)((__v4du)__a ^ (__v4du)__b);
  608. }
  609. /// \brief Performs a bitwise XOR of two 256-bit vectors of [8 x float].
  610. ///
  611. /// \headerfile <x86intrin.h>
  612. ///
  613. /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
  614. ///
  615. /// \param __a
  616. /// A 256-bit vector of [8 x float] containing one of the source operands.
  617. /// \param __b
  618. /// A 256-bit vector of [8 x float] containing one of the source operands.
  619. /// \returns A 256-bit vector of [8 x float] containing the bitwise XOR of the
  620. /// values between both operands.
  621. static __inline __m256 __DEFAULT_FN_ATTRS
  622. _mm256_xor_ps(__m256 __a, __m256 __b)
  623. {
  624. return (__m256)((__v8su)__a ^ (__v8su)__b);
  625. }
  626. /* Horizontal arithmetic */
  627. /// \brief Horizontally adds the adjacent pairs of values contained in two
  628. /// 256-bit vectors of [4 x double].
  629. ///
  630. /// \headerfile <x86intrin.h>
  631. ///
  632. /// This intrinsic corresponds to the <c> VHADDPD </c> instruction.
  633. ///
  634. /// \param __a
  635. /// A 256-bit vector of [4 x double] containing one of the source operands.
  636. /// The horizontal sums of the values are returned in the even-indexed
  637. /// elements of a vector of [4 x double].
  638. /// \param __b
  639. /// A 256-bit vector of [4 x double] containing one of the source operands.
  640. /// The horizontal sums of the values are returned in the odd-indexed
  641. /// elements of a vector of [4 x double].
  642. /// \returns A 256-bit vector of [4 x double] containing the horizontal sums of
  643. /// both operands.
  644. static __inline __m256d __DEFAULT_FN_ATTRS
  645. _mm256_hadd_pd(__m256d __a, __m256d __b)
  646. {
  647. return (__m256d)__builtin_ia32_haddpd256((__v4df)__a, (__v4df)__b);
  648. }
  649. /// \brief Horizontally adds the adjacent pairs of values contained in two
  650. /// 256-bit vectors of [8 x float].
  651. ///
  652. /// \headerfile <x86intrin.h>
  653. ///
  654. /// This intrinsic corresponds to the <c> VHADDPS </c> instruction.
  655. ///
  656. /// \param __a
  657. /// A 256-bit vector of [8 x float] containing one of the source operands.
  658. /// The horizontal sums of the values are returned in the elements with
  659. /// index 0, 1, 4, 5 of a vector of [8 x float].
  660. /// \param __b
  661. /// A 256-bit vector of [8 x float] containing one of the source operands.
  662. /// The horizontal sums of the values are returned in the elements with
  663. /// index 2, 3, 6, 7 of a vector of [8 x float].
  664. /// \returns A 256-bit vector of [8 x float] containing the horizontal sums of
  665. /// both operands.
  666. static __inline __m256 __DEFAULT_FN_ATTRS
  667. _mm256_hadd_ps(__m256 __a, __m256 __b)
  668. {
  669. return (__m256)__builtin_ia32_haddps256((__v8sf)__a, (__v8sf)__b);
  670. }
  671. /// \brief Horizontally subtracts the adjacent pairs of values contained in two
  672. /// 256-bit vectors of [4 x double].
  673. ///
  674. /// \headerfile <x86intrin.h>
  675. ///
  676. /// This intrinsic corresponds to the <c> VHSUBPD </c> instruction.
  677. ///
  678. /// \param __a
  679. /// A 256-bit vector of [4 x double] containing one of the source operands.
  680. /// The horizontal differences between the values are returned in the
  681. /// even-indexed elements of a vector of [4 x double].
  682. /// \param __b
  683. /// A 256-bit vector of [4 x double] containing one of the source operands.
  684. /// The horizontal differences between the values are returned in the
  685. /// odd-indexed elements of a vector of [4 x double].
  686. /// \returns A 256-bit vector of [4 x double] containing the horizontal
  687. /// differences of both operands.
  688. static __inline __m256d __DEFAULT_FN_ATTRS
  689. _mm256_hsub_pd(__m256d __a, __m256d __b)
  690. {
  691. return (__m256d)__builtin_ia32_hsubpd256((__v4df)__a, (__v4df)__b);
  692. }
  693. /// \brief Horizontally subtracts the adjacent pairs of values contained in two
  694. /// 256-bit vectors of [8 x float].
  695. ///
  696. /// \headerfile <x86intrin.h>
  697. ///
  698. /// This intrinsic corresponds to the <c> VHSUBPS </c> instruction.
  699. ///
  700. /// \param __a
  701. /// A 256-bit vector of [8 x float] containing one of the source operands.
  702. /// The horizontal differences between the values are returned in the
  703. /// elements with index 0, 1, 4, 5 of a vector of [8 x float].
  704. /// \param __b
  705. /// A 256-bit vector of [8 x float] containing one of the source operands.
  706. /// The horizontal differences between the values are returned in the
  707. /// elements with index 2, 3, 6, 7 of a vector of [8 x float].
  708. /// \returns A 256-bit vector of [8 x float] containing the horizontal
  709. /// differences of both operands.
  710. static __inline __m256 __DEFAULT_FN_ATTRS
  711. _mm256_hsub_ps(__m256 __a, __m256 __b)
  712. {
  713. return (__m256)__builtin_ia32_hsubps256((__v8sf)__a, (__v8sf)__b);
  714. }
  715. /* Vector permutations */
  716. /// \brief Copies the values in a 128-bit vector of [2 x double] as specified
  717. /// by the 128-bit integer vector operand.
  718. ///
  719. /// \headerfile <x86intrin.h>
  720. ///
  721. /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
  722. ///
  723. /// \param __a
  724. /// A 128-bit vector of [2 x double].
  725. /// \param __c
  726. /// A 128-bit integer vector operand specifying how the values are to be
  727. /// copied. \n
  728. /// Bit [1]: \n
  729. /// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned
  730. /// vector. \n
  731. /// 1: Bits [127:64] of the source are copied to bits [63:0] of the
  732. /// returned vector. \n
  733. /// Bit [65]: \n
  734. /// 0: Bits [63:0] of the source are copied to bits [127:64] of the
  735. /// returned vector. \n
  736. /// 1: Bits [127:64] of the source are copied to bits [127:64] of the
  737. /// returned vector.
  738. /// \returns A 128-bit vector of [2 x double] containing the copied values.
  739. static __inline __m128d __DEFAULT_FN_ATTRS
  740. _mm_permutevar_pd(__m128d __a, __m128i __c)
  741. {
  742. return (__m128d)__builtin_ia32_vpermilvarpd((__v2df)__a, (__v2di)__c);
  743. }
  744. /// \brief Copies the values in a 256-bit vector of [4 x double] as specified
  745. /// by the 256-bit integer vector operand.
  746. ///
  747. /// \headerfile <x86intrin.h>
  748. ///
  749. /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
  750. ///
  751. /// \param __a
  752. /// A 256-bit vector of [4 x double].
  753. /// \param __c
  754. /// A 256-bit integer vector operand specifying how the values are to be
  755. /// copied. \n
  756. /// Bit [1]: \n
  757. /// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned
  758. /// vector. \n
  759. /// 1: Bits [127:64] of the source are copied to bits [63:0] of the
  760. /// returned vector. \n
  761. /// Bit [65]: \n
  762. /// 0: Bits [63:0] of the source are copied to bits [127:64] of the
  763. /// returned vector. \n
  764. /// 1: Bits [127:64] of the source are copied to bits [127:64] of the
  765. /// returned vector. \n
  766. /// Bit [129]: \n
  767. /// 0: Bits [191:128] of the source are copied to bits [191:128] of the
  768. /// returned vector. \n
  769. /// 1: Bits [255:192] of the source are copied to bits [191:128] of the
  770. /// returned vector. \n
  771. /// Bit [193]: \n
  772. /// 0: Bits [191:128] of the source are copied to bits [255:192] of the
  773. /// returned vector. \n
  774. /// 1: Bits [255:192] of the source are copied to bits [255:192] of the
  775. /// returned vector.
  776. /// \returns A 256-bit vector of [4 x double] containing the copied values.
  777. static __inline __m256d __DEFAULT_FN_ATTRS
  778. _mm256_permutevar_pd(__m256d __a, __m256i __c)
  779. {
  780. return (__m256d)__builtin_ia32_vpermilvarpd256((__v4df)__a, (__v4di)__c);
  781. }
  782. /// \brief Copies the values stored in a 128-bit vector of [4 x float] as
  783. /// specified by the 128-bit integer vector operand.
  784. /// \headerfile <x86intrin.h>
  785. ///
  786. /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
  787. ///
  788. /// \param __a
  789. /// A 128-bit vector of [4 x float].
  790. /// \param __c
  791. /// A 128-bit integer vector operand specifying how the values are to be
  792. /// copied. \n
  793. /// Bits [1:0]: \n
  794. /// 00: Bits [31:0] of the source are copied to bits [31:0] of the
  795. /// returned vector. \n
  796. /// 01: Bits [63:32] of the source are copied to bits [31:0] of the
  797. /// returned vector. \n
  798. /// 10: Bits [95:64] of the source are copied to bits [31:0] of the
  799. /// returned vector. \n
  800. /// 11: Bits [127:96] of the source are copied to bits [31:0] of the
  801. /// returned vector. \n
  802. /// Bits [33:32]: \n
  803. /// 00: Bits [31:0] of the source are copied to bits [63:32] of the
  804. /// returned vector. \n
  805. /// 01: Bits [63:32] of the source are copied to bits [63:32] of the
  806. /// returned vector. \n
  807. /// 10: Bits [95:64] of the source are copied to bits [63:32] of the
  808. /// returned vector. \n
  809. /// 11: Bits [127:96] of the source are copied to bits [63:32] of the
  810. /// returned vector. \n
  811. /// Bits [65:64]: \n
  812. /// 00: Bits [31:0] of the source are copied to bits [95:64] of the
  813. /// returned vector. \n
  814. /// 01: Bits [63:32] of the source are copied to bits [95:64] of the
  815. /// returned vector. \n
  816. /// 10: Bits [95:64] of the source are copied to bits [95:64] of the
  817. /// returned vector. \n
  818. /// 11: Bits [127:96] of the source are copied to bits [95:64] of the
  819. /// returned vector. \n
  820. /// Bits [97:96]: \n
  821. /// 00: Bits [31:0] of the source are copied to bits [127:96] of the
  822. /// returned vector. \n
  823. /// 01: Bits [63:32] of the source are copied to bits [127:96] of the
  824. /// returned vector. \n
  825. /// 10: Bits [95:64] of the source are copied to bits [127:96] of the
  826. /// returned vector. \n
  827. /// 11: Bits [127:96] of the source are copied to bits [127:96] of the
  828. /// returned vector.
  829. /// \returns A 128-bit vector of [4 x float] containing the copied values.
  830. static __inline __m128 __DEFAULT_FN_ATTRS
  831. _mm_permutevar_ps(__m128 __a, __m128i __c)
  832. {
  833. return (__m128)__builtin_ia32_vpermilvarps((__v4sf)__a, (__v4si)__c);
  834. }
  835. /// \brief Copies the values stored in a 256-bit vector of [8 x float] as
  836. /// specified by the 256-bit integer vector operand.
  837. ///
  838. /// \headerfile <x86intrin.h>
  839. ///
  840. /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
  841. ///
  842. /// \param __a
  843. /// A 256-bit vector of [8 x float].
  844. /// \param __c
  845. /// A 256-bit integer vector operand specifying how the values are to be
  846. /// copied. \n
  847. /// Bits [1:0]: \n
  848. /// 00: Bits [31:0] of the source are copied to bits [31:0] of the
  849. /// returned vector. \n
  850. /// 01: Bits [63:32] of the source are copied to bits [31:0] of the
  851. /// returned vector. \n
  852. /// 10: Bits [95:64] of the source are copied to bits [31:0] of the
  853. /// returned vector. \n
  854. /// 11: Bits [127:96] of the source are copied to bits [31:0] of the
  855. /// returned vector. \n
  856. /// Bits [33:32]: \n
  857. /// 00: Bits [31:0] of the source are copied to bits [63:32] of the
  858. /// returned vector. \n
  859. /// 01: Bits [63:32] of the source are copied to bits [63:32] of the
  860. /// returned vector. \n
  861. /// 10: Bits [95:64] of the source are copied to bits [63:32] of the
  862. /// returned vector. \n
  863. /// 11: Bits [127:96] of the source are copied to bits [63:32] of the
  864. /// returned vector. \n
  865. /// Bits [65:64]: \n
  866. /// 00: Bits [31:0] of the source are copied to bits [95:64] of the
  867. /// returned vector. \n
  868. /// 01: Bits [63:32] of the source are copied to bits [95:64] of the
  869. /// returned vector. \n
  870. /// 10: Bits [95:64] of the source are copied to bits [95:64] of the
  871. /// returned vector. \n
  872. /// 11: Bits [127:96] of the source are copied to bits [95:64] of the
  873. /// returned vector. \n
  874. /// Bits [97:96]: \n
  875. /// 00: Bits [31:0] of the source are copied to bits [127:96] of the
  876. /// returned vector. \n
  877. /// 01: Bits [63:32] of the source are copied to bits [127:96] of the
  878. /// returned vector. \n
  879. /// 10: Bits [95:64] of the source are copied to bits [127:96] of the
  880. /// returned vector. \n
  881. /// 11: Bits [127:96] of the source are copied to bits [127:96] of the
  882. /// returned vector. \n
  883. /// Bits [129:128]: \n
  884. /// 00: Bits [159:128] of the source are copied to bits [159:128] of the
  885. /// returned vector. \n
  886. /// 01: Bits [191:160] of the source are copied to bits [159:128] of the
  887. /// returned vector. \n
  888. /// 10: Bits [223:192] of the source are copied to bits [159:128] of the
  889. /// returned vector. \n
  890. /// 11: Bits [255:224] of the source are copied to bits [159:128] of the
  891. /// returned vector. \n
  892. /// Bits [161:160]: \n
  893. /// 00: Bits [159:128] of the source are copied to bits [191:160] of the
  894. /// returned vector. \n
  895. /// 01: Bits [191:160] of the source are copied to bits [191:160] of the
  896. /// returned vector. \n
  897. /// 10: Bits [223:192] of the source are copied to bits [191:160] of the
  898. /// returned vector. \n
  899. /// 11: Bits [255:224] of the source are copied to bits [191:160] of the
  900. /// returned vector. \n
  901. /// Bits [193:192]: \n
  902. /// 00: Bits [159:128] of the source are copied to bits [223:192] of the
  903. /// returned vector. \n
  904. /// 01: Bits [191:160] of the source are copied to bits [223:192] of the
  905. /// returned vector. \n
  906. /// 10: Bits [223:192] of the source are copied to bits [223:192] of the
  907. /// returned vector. \n
  908. /// 11: Bits [255:224] of the source are copied to bits [223:192] of the
  909. /// returned vector. \n
  910. /// Bits [225:224]: \n
  911. /// 00: Bits [159:128] of the source are copied to bits [255:224] of the
  912. /// returned vector. \n
  913. /// 01: Bits [191:160] of the source are copied to bits [255:224] of the
  914. /// returned vector. \n
  915. /// 10: Bits [223:192] of the source are copied to bits [255:224] of the
  916. /// returned vector. \n
  917. /// 11: Bits [255:224] of the source are copied to bits [255:224] of the
  918. /// returned vector.
  919. /// \returns A 256-bit vector of [8 x float] containing the copied values.
  920. static __inline __m256 __DEFAULT_FN_ATTRS
  921. _mm256_permutevar_ps(__m256 __a, __m256i __c)
  922. {
  923. return (__m256)__builtin_ia32_vpermilvarps256((__v8sf)__a, (__v8si)__c);
  924. }
  925. /// \brief Copies the values in a 128-bit vector of [2 x double] as specified
  926. /// by the immediate integer operand.
  927. ///
  928. /// \headerfile <x86intrin.h>
  929. ///
  930. /// \code
  931. /// __m128d _mm_permute_pd(__m128d A, const int C);
  932. /// \endcode
  933. ///
  934. /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
  935. ///
  936. /// \param A
  937. /// A 128-bit vector of [2 x double].
  938. /// \param C
  939. /// An immediate integer operand specifying how the values are to be
  940. /// copied. \n
  941. /// Bit [0]: \n
  942. /// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned
  943. /// vector. \n
  944. /// 1: Bits [127:64] of the source are copied to bits [63:0] of the
  945. /// returned vector. \n
  946. /// Bit [1]: \n
  947. /// 0: Bits [63:0] of the source are copied to bits [127:64] of the
  948. /// returned vector. \n
  949. /// 1: Bits [127:64] of the source are copied to bits [127:64] of the
  950. /// returned vector.
  951. /// \returns A 128-bit vector of [2 x double] containing the copied values.
  952. #define _mm_permute_pd(A, C) __extension__ ({ \
  953. (__m128d)__builtin_shufflevector((__v2df)(__m128d)(A), \
  954. (__v2df)_mm_undefined_pd(), \
  955. ((C) >> 0) & 0x1, ((C) >> 1) & 0x1); })
  956. /// \brief Copies the values in a 256-bit vector of [4 x double] as specified by
  957. /// the immediate integer operand.
  958. ///
  959. /// \headerfile <x86intrin.h>
  960. ///
  961. /// \code
  962. /// __m256d _mm256_permute_pd(__m256d A, const int C);
  963. /// \endcode
  964. ///
  965. /// This intrinsic corresponds to the <c> VPERMILPD </c> instruction.
  966. ///
  967. /// \param A
  968. /// A 256-bit vector of [4 x double].
  969. /// \param C
  970. /// An immediate integer operand specifying how the values are to be
  971. /// copied. \n
  972. /// Bit [0]: \n
  973. /// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned
  974. /// vector. \n
  975. /// 1: Bits [127:64] of the source are copied to bits [63:0] of the
  976. /// returned vector. \n
  977. /// Bit [1]: \n
  978. /// 0: Bits [63:0] of the source are copied to bits [127:64] of the
  979. /// returned vector. \n
  980. /// 1: Bits [127:64] of the source are copied to bits [127:64] of the
  981. /// returned vector. \n
  982. /// Bit [2]: \n
  983. /// 0: Bits [191:128] of the source are copied to bits [191:128] of the
  984. /// returned vector. \n
  985. /// 1: Bits [255:192] of the source are copied to bits [191:128] of the
  986. /// returned vector. \n
  987. /// Bit [3]: \n
  988. /// 0: Bits [191:128] of the source are copied to bits [255:192] of the
  989. /// returned vector. \n
  990. /// 1: Bits [255:192] of the source are copied to bits [255:192] of the
  991. /// returned vector.
  992. /// \returns A 256-bit vector of [4 x double] containing the copied values.
  993. #define _mm256_permute_pd(A, C) __extension__ ({ \
  994. (__m256d)__builtin_shufflevector((__v4df)(__m256d)(A), \
  995. (__v4df)_mm256_undefined_pd(), \
  996. 0 + (((C) >> 0) & 0x1), \
  997. 0 + (((C) >> 1) & 0x1), \
  998. 2 + (((C) >> 2) & 0x1), \
  999. 2 + (((C) >> 3) & 0x1)); })
  1000. /// \brief Copies the values in a 128-bit vector of [4 x float] as specified by
  1001. /// the immediate integer operand.
  1002. ///
  1003. /// \headerfile <x86intrin.h>
  1004. ///
  1005. /// \code
  1006. /// __m128 _mm_permute_ps(__m128 A, const int C);
  1007. /// \endcode
  1008. ///
  1009. /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
  1010. ///
  1011. /// \param A
  1012. /// A 128-bit vector of [4 x float].
  1013. /// \param C
  1014. /// An immediate integer operand specifying how the values are to be
  1015. /// copied. \n
  1016. /// Bits [1:0]: \n
  1017. /// 00: Bits [31:0] of the source are copied to bits [31:0] of the
  1018. /// returned vector. \n
  1019. /// 01: Bits [63:32] of the source are copied to bits [31:0] of the
  1020. /// returned vector. \n
  1021. /// 10: Bits [95:64] of the source are copied to bits [31:0] of the
  1022. /// returned vector. \n
  1023. /// 11: Bits [127:96] of the source are copied to bits [31:0] of the
  1024. /// returned vector. \n
  1025. /// Bits [3:2]: \n
  1026. /// 00: Bits [31:0] of the source are copied to bits [63:32] of the
  1027. /// returned vector. \n
  1028. /// 01: Bits [63:32] of the source are copied to bits [63:32] of the
  1029. /// returned vector. \n
  1030. /// 10: Bits [95:64] of the source are copied to bits [63:32] of the
  1031. /// returned vector. \n
  1032. /// 11: Bits [127:96] of the source are copied to bits [63:32] of the
  1033. /// returned vector. \n
  1034. /// Bits [5:4]: \n
  1035. /// 00: Bits [31:0] of the source are copied to bits [95:64] of the
  1036. /// returned vector. \n
  1037. /// 01: Bits [63:32] of the source are copied to bits [95:64] of the
  1038. /// returned vector. \n
  1039. /// 10: Bits [95:64] of the source are copied to bits [95:64] of the
  1040. /// returned vector. \n
  1041. /// 11: Bits [127:96] of the source are copied to bits [95:64] of the
  1042. /// returned vector. \n
  1043. /// Bits [7:6]: \n
  1044. /// 00: Bits [31:0] of the source are copied to bits [127:96] of the
  1045. /// returned vector. \n
  1046. /// 01: Bits [63:32] of the source are copied to bits [127:96] of the
  1047. /// returned vector. \n
  1048. /// 10: Bits [95:64] of the source are copied to bits [127:96] of the
  1049. /// returned vector. \n
  1050. /// 11: Bits [127:96] of the source are copied to bits [127:96] of the
  1051. /// returned vector.
  1052. /// \returns A 128-bit vector of [4 x float] containing the copied values.
  1053. #define _mm_permute_ps(A, C) __extension__ ({ \
  1054. (__m128)__builtin_shufflevector((__v4sf)(__m128)(A), \
  1055. (__v4sf)_mm_undefined_ps(), \
  1056. ((C) >> 0) & 0x3, ((C) >> 2) & 0x3, \
  1057. ((C) >> 4) & 0x3, ((C) >> 6) & 0x3); })
  1058. /// \brief Copies the values in a 256-bit vector of [8 x float] as specified by
  1059. /// the immediate integer operand.
  1060. ///
  1061. /// \headerfile <x86intrin.h>
  1062. ///
  1063. /// \code
  1064. /// __m256 _mm256_permute_ps(__m256 A, const int C);
  1065. /// \endcode
  1066. ///
  1067. /// This intrinsic corresponds to the <c> VPERMILPS </c> instruction.
  1068. ///
  1069. /// \param A
  1070. /// A 256-bit vector of [8 x float].
  1071. /// \param C
  1072. /// An immediate integer operand specifying how the values are to be \n
  1073. /// copied. \n
  1074. /// Bits [1:0]: \n
  1075. /// 00: Bits [31:0] of the source are copied to bits [31:0] of the
  1076. /// returned vector. \n
  1077. /// 01: Bits [63:32] of the source are copied to bits [31:0] of the
  1078. /// returned vector. \n
  1079. /// 10: Bits [95:64] of the source are copied to bits [31:0] of the
  1080. /// returned vector. \n
  1081. /// 11: Bits [127:96] of the source are copied to bits [31:0] of the
  1082. /// returned vector. \n
  1083. /// Bits [3:2]: \n
  1084. /// 00: Bits [31:0] of the source are copied to bits [63:32] of the
  1085. /// returned vector. \n
  1086. /// 01: Bits [63:32] of the source are copied to bits [63:32] of the
  1087. /// returned vector. \n
  1088. /// 10: Bits [95:64] of the source are copied to bits [63:32] of the
  1089. /// returned vector. \n
  1090. /// 11: Bits [127:96] of the source are copied to bits [63:32] of the
  1091. /// returned vector. \n
  1092. /// Bits [5:4]: \n
  1093. /// 00: Bits [31:0] of the source are copied to bits [95:64] of the
  1094. /// returned vector. \n
  1095. /// 01: Bits [63:32] of the source are copied to bits [95:64] of the
  1096. /// returned vector. \n
  1097. /// 10: Bits [95:64] of the source are copied to bits [95:64] of the
  1098. /// returned vector. \n
  1099. /// 11: Bits [127:96] of the source are copied to bits [95:64] of the
  1100. /// returned vector. \n
  1101. /// Bits [7:6]: \n
  1102. /// 00: Bits [31:qq0] of the source are copied to bits [127:96] of the
  1103. /// returned vector. \n
  1104. /// 01: Bits [63:32] of the source are copied to bits [127:96] of the
  1105. /// returned vector. \n
  1106. /// 10: Bits [95:64] of the source are copied to bits [127:96] of the
  1107. /// returned vector. \n
  1108. /// 11: Bits [127:96] of the source are copied to bits [127:96] of the
  1109. /// returned vector. \n
  1110. /// Bits [1:0]: \n
  1111. /// 00: Bits [159:128] of the source are copied to bits [159:128] of the
  1112. /// returned vector. \n
  1113. /// 01: Bits [191:160] of the source are copied to bits [159:128] of the
  1114. /// returned vector. \n
  1115. /// 10: Bits [223:192] of the source are copied to bits [159:128] of the
  1116. /// returned vector. \n
  1117. /// 11: Bits [255:224] of the source are copied to bits [159:128] of the
  1118. /// returned vector. \n
  1119. /// Bits [3:2]: \n
  1120. /// 00: Bits [159:128] of the source are copied to bits [191:160] of the
  1121. /// returned vector. \n
  1122. /// 01: Bits [191:160] of the source are copied to bits [191:160] of the
  1123. /// returned vector. \n
  1124. /// 10: Bits [223:192] of the source are copied to bits [191:160] of the
  1125. /// returned vector. \n
  1126. /// 11: Bits [255:224] of the source are copied to bits [191:160] of the
  1127. /// returned vector. \n
  1128. /// Bits [5:4]: \n
  1129. /// 00: Bits [159:128] of the source are copied to bits [223:192] of the
  1130. /// returned vector. \n
  1131. /// 01: Bits [191:160] of the source are copied to bits [223:192] of the
  1132. /// returned vector. \n
  1133. /// 10: Bits [223:192] of the source are copied to bits [223:192] of the
  1134. /// returned vector. \n
  1135. /// 11: Bits [255:224] of the source are copied to bits [223:192] of the
  1136. /// returned vector. \n
  1137. /// Bits [7:6]: \n
  1138. /// 00: Bits [159:128] of the source are copied to bits [255:224] of the
  1139. /// returned vector. \n
  1140. /// 01: Bits [191:160] of the source are copied to bits [255:224] of the
  1141. /// returned vector. \n
  1142. /// 10: Bits [223:192] of the source are copied to bits [255:224] of the
  1143. /// returned vector. \n
  1144. /// 11: Bits [255:224] of the source are copied to bits [255:224] of the
  1145. /// returned vector.
  1146. /// \returns A 256-bit vector of [8 x float] containing the copied values.
  1147. #define _mm256_permute_ps(A, C) __extension__ ({ \
  1148. (__m256)__builtin_shufflevector((__v8sf)(__m256)(A), \
  1149. (__v8sf)_mm256_undefined_ps(), \
  1150. 0 + (((C) >> 0) & 0x3), \
  1151. 0 + (((C) >> 2) & 0x3), \
  1152. 0 + (((C) >> 4) & 0x3), \
  1153. 0 + (((C) >> 6) & 0x3), \
  1154. 4 + (((C) >> 0) & 0x3), \
  1155. 4 + (((C) >> 2) & 0x3), \
  1156. 4 + (((C) >> 4) & 0x3), \
  1157. 4 + (((C) >> 6) & 0x3)); })
  1158. /// \brief Permutes 128-bit data values stored in two 256-bit vectors of
  1159. /// [4 x double], as specified by the immediate integer operand.
  1160. ///
  1161. /// \headerfile <x86intrin.h>
  1162. ///
  1163. /// \code
  1164. /// __m256d _mm256_permute2f128_pd(__m256d V1, __m256d V2, const int M);
  1165. /// \endcode
  1166. ///
  1167. /// This intrinsic corresponds to the <c> VPERM2F128 </c> instruction.
  1168. ///
  1169. /// \param V1
  1170. /// A 256-bit vector of [4 x double].
  1171. /// \param V2
  1172. /// A 256-bit vector of [4 x double.
  1173. /// \param M
  1174. /// An immediate integer operand specifying how the values are to be
  1175. /// permuted. \n
  1176. /// Bits [1:0]: \n
  1177. /// 00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the
  1178. /// destination. \n
  1179. /// 01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the
  1180. /// destination. \n
  1181. /// 10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the
  1182. /// destination. \n
  1183. /// 11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the
  1184. /// destination. \n
  1185. /// Bits [5:4]: \n
  1186. /// 00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the
  1187. /// destination. \n
  1188. /// 01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the
  1189. /// destination. \n
  1190. /// 10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the
  1191. /// destination. \n
  1192. /// 11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the
  1193. /// destination.
  1194. /// \returns A 256-bit vector of [4 x double] containing the copied values.
  1195. #define _mm256_permute2f128_pd(V1, V2, M) __extension__ ({ \
  1196. (__m256d)__builtin_ia32_vperm2f128_pd256((__v4df)(__m256d)(V1), \
  1197. (__v4df)(__m256d)(V2), (M)); })
  1198. /// \brief Permutes 128-bit data values stored in two 256-bit vectors of
  1199. /// [8 x float], as specified by the immediate integer operand.
  1200. ///
  1201. /// \headerfile <x86intrin.h>
  1202. ///
  1203. /// \code
  1204. /// __m256 _mm256_permute2f128_ps(__m256 V1, __m256 V2, const int M);
  1205. /// \endcode
  1206. ///
  1207. /// This intrinsic corresponds to the <c> VPERM2F128 </c> instruction.
  1208. ///
  1209. /// \param V1
  1210. /// A 256-bit vector of [8 x float].
  1211. /// \param V2
  1212. /// A 256-bit vector of [8 x float].
  1213. /// \param M
  1214. /// An immediate integer operand specifying how the values are to be
  1215. /// permuted. \n
  1216. /// Bits [1:0]: \n
  1217. /// 00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the
  1218. /// destination. \n
  1219. /// 01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the
  1220. /// destination. \n
  1221. /// 10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the
  1222. /// destination. \n
  1223. /// 11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the
  1224. /// destination. \n
  1225. /// Bits [5:4]: \n
  1226. /// 00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the
  1227. /// destination. \n
  1228. /// 01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the
  1229. /// destination. \n
  1230. /// 10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the
  1231. /// destination. \n
  1232. /// 11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the
  1233. /// destination.
  1234. /// \returns A 256-bit vector of [8 x float] containing the copied values.
  1235. #define _mm256_permute2f128_ps(V1, V2, M) __extension__ ({ \
  1236. (__m256)__builtin_ia32_vperm2f128_ps256((__v8sf)(__m256)(V1), \
  1237. (__v8sf)(__m256)(V2), (M)); })
  1238. /// \brief Permutes 128-bit data values stored in two 256-bit integer vectors,
  1239. /// as specified by the immediate integer operand.
  1240. ///
  1241. /// \headerfile <x86intrin.h>
  1242. ///
  1243. /// \code
  1244. /// __m256i _mm256_permute2f128_si256(__m256i V1, __m256i V2, const int M);
  1245. /// \endcode
  1246. ///
  1247. /// This intrinsic corresponds to the <c> VPERM2F128 </c> instruction.
  1248. ///
  1249. /// \param V1
  1250. /// A 256-bit integer vector.
  1251. /// \param V2
  1252. /// A 256-bit integer vector.
  1253. /// \param M
  1254. /// An immediate integer operand specifying how the values are to be copied.
  1255. /// Bits [1:0]: \n
  1256. /// 00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the
  1257. /// destination. \n
  1258. /// 01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the
  1259. /// destination. \n
  1260. /// 10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the
  1261. /// destination. \n
  1262. /// 11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the
  1263. /// destination. \n
  1264. /// Bits [5:4]: \n
  1265. /// 00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the
  1266. /// destination. \n
  1267. /// 01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the
  1268. /// destination. \n
  1269. /// 10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the
  1270. /// destination. \n
  1271. /// 11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the
  1272. /// destination.
  1273. /// \returns A 256-bit integer vector containing the copied values.
  1274. #define _mm256_permute2f128_si256(V1, V2, M) __extension__ ({ \
  1275. (__m256i)__builtin_ia32_vperm2f128_si256((__v8si)(__m256i)(V1), \
  1276. (__v8si)(__m256i)(V2), (M)); })
  1277. /* Vector Blend */
  1278. /// \brief Merges 64-bit double-precision data values stored in either of the
  1279. /// two 256-bit vectors of [4 x double], as specified by the immediate
  1280. /// integer operand.
  1281. ///
  1282. /// \headerfile <x86intrin.h>
  1283. ///
  1284. /// \code
  1285. /// __m256d _mm256_blend_pd(__m256d V1, __m256d V2, const int M);
  1286. /// \endcode
  1287. ///
  1288. /// This intrinsic corresponds to the <c> VBLENDPD </c> instruction.
  1289. ///
  1290. /// \param V1
  1291. /// A 256-bit vector of [4 x double].
  1292. /// \param V2
  1293. /// A 256-bit vector of [4 x double].
  1294. /// \param M
  1295. /// An immediate integer operand, with mask bits [3:0] specifying how the
  1296. /// values are to be copied. The position of the mask bit corresponds to the
  1297. /// index of a copied value. When a mask bit is 0, the corresponding 64-bit
  1298. /// element in operand \a V1 is copied to the same position in the
  1299. /// destination. When a mask bit is 1, the corresponding 64-bit element in
  1300. /// operand \a V2 is copied to the same position in the destination.
  1301. /// \returns A 256-bit vector of [4 x double] containing the copied values.
  1302. #define _mm256_blend_pd(V1, V2, M) __extension__ ({ \
  1303. (__m256d)__builtin_shufflevector((__v4df)(__m256d)(V1), \
  1304. (__v4df)(__m256d)(V2), \
  1305. (((M) & 0x01) ? 4 : 0), \
  1306. (((M) & 0x02) ? 5 : 1), \
  1307. (((M) & 0x04) ? 6 : 2), \
  1308. (((M) & 0x08) ? 7 : 3)); })
  1309. /// \brief Merges 32-bit single-precision data values stored in either of the
  1310. /// two 256-bit vectors of [8 x float], as specified by the immediate
  1311. /// integer operand.
  1312. ///
  1313. /// \headerfile <x86intrin.h>
  1314. ///
  1315. /// \code
  1316. /// __m256 _mm256_blend_ps(__m256 V1, __m256 V2, const int M);
  1317. /// \endcode
  1318. ///
  1319. /// This intrinsic corresponds to the <c> VBLENDPS </c> instruction.
  1320. ///
  1321. /// \param V1
  1322. /// A 256-bit vector of [8 x float].
  1323. /// \param V2
  1324. /// A 256-bit vector of [8 x float].
  1325. /// \param M
  1326. /// An immediate integer operand, with mask bits [7:0] specifying how the
  1327. /// values are to be copied. The position of the mask bit corresponds to the
  1328. /// index of a copied value. When a mask bit is 0, the corresponding 32-bit
  1329. /// element in operand \a V1 is copied to the same position in the
  1330. /// destination. When a mask bit is 1, the corresponding 32-bit element in
  1331. /// operand \a V2 is copied to the same position in the destination.
  1332. /// \returns A 256-bit vector of [8 x float] containing the copied values.
  1333. #define _mm256_blend_ps(V1, V2, M) __extension__ ({ \
  1334. (__m256)__builtin_shufflevector((__v8sf)(__m256)(V1), \
  1335. (__v8sf)(__m256)(V2), \
  1336. (((M) & 0x01) ? 8 : 0), \
  1337. (((M) & 0x02) ? 9 : 1), \
  1338. (((M) & 0x04) ? 10 : 2), \
  1339. (((M) & 0x08) ? 11 : 3), \
  1340. (((M) & 0x10) ? 12 : 4), \
  1341. (((M) & 0x20) ? 13 : 5), \
  1342. (((M) & 0x40) ? 14 : 6), \
  1343. (((M) & 0x80) ? 15 : 7)); })
  1344. /// \brief Merges 64-bit double-precision data values stored in either of the
  1345. /// two 256-bit vectors of [4 x double], as specified by the 256-bit vector
  1346. /// operand.
  1347. ///
  1348. /// \headerfile <x86intrin.h>
  1349. ///
  1350. /// This intrinsic corresponds to the <c> VBLENDVPD </c> instruction.
  1351. ///
  1352. /// \param __a
  1353. /// A 256-bit vector of [4 x double].
  1354. /// \param __b
  1355. /// A 256-bit vector of [4 x double].
  1356. /// \param __c
  1357. /// A 256-bit vector operand, with mask bits 255, 191, 127, and 63 specifying
  1358. /// how the values are to be copied. The position of the mask bit corresponds
  1359. /// to the most significant bit of a copied value. When a mask bit is 0, the
  1360. /// corresponding 64-bit element in operand \a __a is copied to the same
  1361. /// position in the destination. When a mask bit is 1, the corresponding
  1362. /// 64-bit element in operand \a __b is copied to the same position in the
  1363. /// destination.
  1364. /// \returns A 256-bit vector of [4 x double] containing the copied values.
  1365. static __inline __m256d __DEFAULT_FN_ATTRS
  1366. _mm256_blendv_pd(__m256d __a, __m256d __b, __m256d __c)
  1367. {
  1368. return (__m256d)__builtin_ia32_blendvpd256(
  1369. (__v4df)__a, (__v4df)__b, (__v4df)__c);
  1370. }
  1371. /// \brief Merges 32-bit single-precision data values stored in either of the
  1372. /// two 256-bit vectors of [8 x float], as specified by the 256-bit vector
  1373. /// operand.
  1374. ///
  1375. /// \headerfile <x86intrin.h>
  1376. ///
  1377. /// This intrinsic corresponds to the <c> VBLENDVPS </c> instruction.
  1378. ///
  1379. /// \param __a
  1380. /// A 256-bit vector of [8 x float].
  1381. /// \param __b
  1382. /// A 256-bit vector of [8 x float].
  1383. /// \param __c
  1384. /// A 256-bit vector operand, with mask bits 255, 223, 191, 159, 127, 95, 63,
  1385. /// and 31 specifying how the values are to be copied. The position of the
  1386. /// mask bit corresponds to the most significant bit of a copied value. When
  1387. /// a mask bit is 0, the corresponding 32-bit element in operand \a __a is
  1388. /// copied to the same position in the destination. When a mask bit is 1, the
  1389. /// corresponding 32-bit element in operand \a __b is copied to the same
  1390. /// position in the destination.
  1391. /// \returns A 256-bit vector of [8 x float] containing the copied values.
  1392. static __inline __m256 __DEFAULT_FN_ATTRS
  1393. _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
  1394. {
  1395. return (__m256)__builtin_ia32_blendvps256(
  1396. (__v8sf)__a, (__v8sf)__b, (__v8sf)__c);
  1397. }
  1398. /* Vector Dot Product */
  1399. /// \brief Computes two dot products in parallel, using the lower and upper
  1400. /// halves of two [8 x float] vectors as input to the two computations, and
  1401. /// returning the two dot products in the lower and upper halves of the
  1402. /// [8 x float] result.
  1403. ///
  1404. /// The immediate integer operand controls which input elements will
  1405. /// contribute to the dot product, and where the final results are returned.
  1406. /// In general, for each dot product, the four corresponding elements of the
  1407. /// input vectors are multiplied; the first two and second two products are
  1408. /// summed, then the two sums are added to form the final result.
  1409. ///
  1410. /// \headerfile <x86intrin.h>
  1411. ///
  1412. /// \code
  1413. /// __m256 _mm256_dp_ps(__m256 V1, __m256 V2, const int M);
  1414. /// \endcode
  1415. ///
  1416. /// This intrinsic corresponds to the <c> VDPPS </c> instruction.
  1417. ///
  1418. /// \param V1
  1419. /// A vector of [8 x float] values, treated as two [4 x float] vectors.
  1420. /// \param V2
  1421. /// A vector of [8 x float] values, treated as two [4 x float] vectors.
  1422. /// \param M
  1423. /// An immediate integer argument. Bits [7:4] determine which elements of
  1424. /// the input vectors are used, with bit [4] corresponding to the lowest
  1425. /// element and bit [7] corresponding to the highest element of each [4 x
  1426. /// float] subvector. If a bit is set, the corresponding elements from the
  1427. /// two input vectors are used as an input for dot product; otherwise that
  1428. /// input is treated as zero. Bits [3:0] determine which elements of the
  1429. /// result will receive a copy of the final dot product, with bit [0]
  1430. /// corresponding to the lowest element and bit [3] corresponding to the
  1431. /// highest element of each [4 x float] subvector. If a bit is set, the dot
  1432. /// product is returned in the corresponding element; otherwise that element
  1433. /// is set to zero. The bitmask is applied in the same way to each of the
  1434. /// two parallel dot product computations.
  1435. /// \returns A 256-bit vector of [8 x float] containing the two dot products.
  1436. #define _mm256_dp_ps(V1, V2, M) __extension__ ({ \
  1437. (__m256)__builtin_ia32_dpps256((__v8sf)(__m256)(V1), \
  1438. (__v8sf)(__m256)(V2), (M)); })
  1439. /* Vector shuffle */
  1440. /// \brief Selects 8 float values from the 256-bit operands of [8 x float], as
  1441. /// specified by the immediate value operand.
  1442. ///
  1443. /// The four selected elements in each operand are copied to the destination
  1444. /// according to the bits specified in the immediate operand. The selected
  1445. /// elements from the first 256-bit operand are copied to bits [63:0] and
  1446. /// bits [191:128] of the destination, and the selected elements from the
  1447. /// second 256-bit operand are copied to bits [127:64] and bits [255:192] of
  1448. /// the destination. For example, if bits [7:0] of the immediate operand
  1449. /// contain a value of 0xFF, the 256-bit destination vector would contain the
  1450. /// following values: b[7], b[7], a[7], a[7], b[3], b[3], a[3], a[3].
  1451. ///
  1452. /// \headerfile <x86intrin.h>
  1453. ///
  1454. /// \code
  1455. /// __m256 _mm256_shuffle_ps(__m256 a, __m256 b, const int mask);
  1456. /// \endcode
  1457. ///
  1458. /// This intrinsic corresponds to the <c> VSHUFPS </c> instruction.
  1459. ///
  1460. /// \param a
  1461. /// A 256-bit vector of [8 x float]. The four selected elements in this
  1462. /// operand are copied to bits [63:0] and bits [191:128] in the destination,
  1463. /// according to the bits specified in the immediate operand.
  1464. /// \param b
  1465. /// A 256-bit vector of [8 x float]. The four selected elements in this
  1466. /// operand are copied to bits [127:64] and bits [255:192] in the
  1467. /// destination, according to the bits specified in the immediate operand.
  1468. /// \param mask
  1469. /// An immediate value containing an 8-bit value specifying which elements to
  1470. /// copy from \a a and \a b \n.
  1471. /// Bits [3:0] specify the values copied from operand \a a. \n
  1472. /// Bits [7:4] specify the values copied from operand \a b. \n
  1473. /// The destinations within the 256-bit destination are assigned values as
  1474. /// follows, according to the bit value assignments described below: \n
  1475. /// Bits [1:0] are used to assign values to bits [31:0] and [159:128] in the
  1476. /// destination. \n
  1477. /// Bits [3:2] are used to assign values to bits [63:32] and [191:160] in the
  1478. /// destination. \n
  1479. /// Bits [5:4] are used to assign values to bits [95:64] and [223:192] in the
  1480. /// destination. \n
  1481. /// Bits [7:6] are used to assign values to bits [127:96] and [255:224] in
  1482. /// the destination. \n
  1483. /// Bit value assignments: \n
  1484. /// 00: Bits [31:0] and [159:128] are copied from the selected operand. \n
  1485. /// 01: Bits [63:32] and [191:160] are copied from the selected operand. \n
  1486. /// 10: Bits [95:64] and [223:192] are copied from the selected operand. \n
  1487. /// 11: Bits [127:96] and [255:224] are copied from the selected operand.
  1488. /// \returns A 256-bit vector of [8 x float] containing the shuffled values.
  1489. #define _mm256_shuffle_ps(a, b, mask) __extension__ ({ \
  1490. (__m256)__builtin_shufflevector((__v8sf)(__m256)(a), \
  1491. (__v8sf)(__m256)(b), \
  1492. 0 + (((mask) >> 0) & 0x3), \
  1493. 0 + (((mask) >> 2) & 0x3), \
  1494. 8 + (((mask) >> 4) & 0x3), \
  1495. 8 + (((mask) >> 6) & 0x3), \
  1496. 4 + (((mask) >> 0) & 0x3), \
  1497. 4 + (((mask) >> 2) & 0x3), \
  1498. 12 + (((mask) >> 4) & 0x3), \
  1499. 12 + (((mask) >> 6) & 0x3)); })
  1500. /// \brief Selects four double-precision values from the 256-bit operands of
  1501. /// [4 x double], as specified by the immediate value operand.
  1502. ///
  1503. /// The selected elements from the first 256-bit operand are copied to bits
  1504. /// [63:0] and bits [191:128] in the destination, and the selected elements
  1505. /// from the second 256-bit operand are copied to bits [127:64] and bits
  1506. /// [255:192] in the destination. For example, if bits [3:0] of the immediate
  1507. /// operand contain a value of 0xF, the 256-bit destination vector would
  1508. /// contain the following values: b[3], a[3], b[1], a[1].
  1509. ///
  1510. /// \headerfile <x86intrin.h>
  1511. ///
  1512. /// \code
  1513. /// __m256d _mm256_shuffle_pd(__m256d a, __m256d b, const int mask);
  1514. /// \endcode
  1515. ///
  1516. /// This intrinsic corresponds to the <c> VSHUFPD </c> instruction.
  1517. ///
  1518. /// \param a
  1519. /// A 256-bit vector of [4 x double].
  1520. /// \param b
  1521. /// A 256-bit vector of [4 x double].
  1522. /// \param mask
  1523. /// An immediate value containing 8-bit values specifying which elements to
  1524. /// copy from \a a and \a b: \n
  1525. /// Bit [0]=0: Bits [63:0] are copied from \a a to bits [63:0] of the
  1526. /// destination. \n
  1527. /// Bit [0]=1: Bits [127:64] are copied from \a a to bits [63:0] of the
  1528. /// destination. \n
  1529. /// Bit [1]=0: Bits [63:0] are copied from \a b to bits [127:64] of the
  1530. /// destination. \n
  1531. /// Bit [1]=1: Bits [127:64] are copied from \a b to bits [127:64] of the
  1532. /// destination. \n
  1533. /// Bit [2]=0: Bits [191:128] are copied from \a a to bits [191:128] of the
  1534. /// destination. \n
  1535. /// Bit [2]=1: Bits [255:192] are copied from \a a to bits [191:128] of the
  1536. /// destination. \n
  1537. /// Bit [3]=0: Bits [191:128] are copied from \a b to bits [255:192] of the
  1538. /// destination. \n
  1539. /// Bit [3]=1: Bits [255:192] are copied from \a b to bits [255:192] of the
  1540. /// destination.
  1541. /// \returns A 256-bit vector of [4 x double] containing the shuffled values.
  1542. #define _mm256_shuffle_pd(a, b, mask) __extension__ ({ \
  1543. (__m256d)__builtin_shufflevector((__v4df)(__m256d)(a), \
  1544. (__v4df)(__m256d)(b), \
  1545. 0 + (((mask) >> 0) & 0x1), \
  1546. 4 + (((mask) >> 1) & 0x1), \
  1547. 2 + (((mask) >> 2) & 0x1), \
  1548. 6 + (((mask) >> 3) & 0x1)); })
  1549. /* Compare */
  1550. #define _CMP_EQ_OQ 0x00 /* Equal (ordered, non-signaling) */
  1551. #define _CMP_LT_OS 0x01 /* Less-than (ordered, signaling) */
  1552. #define _CMP_LE_OS 0x02 /* Less-than-or-equal (ordered, signaling) */
  1553. #define _CMP_UNORD_Q 0x03 /* Unordered (non-signaling) */
  1554. #define _CMP_NEQ_UQ 0x04 /* Not-equal (unordered, non-signaling) */
  1555. #define _CMP_NLT_US 0x05 /* Not-less-than (unordered, signaling) */
  1556. #define _CMP_NLE_US 0x06 /* Not-less-than-or-equal (unordered, signaling) */
  1557. #define _CMP_ORD_Q 0x07 /* Ordered (non-signaling) */
  1558. #define _CMP_EQ_UQ 0x08 /* Equal (unordered, non-signaling) */
  1559. #define _CMP_NGE_US 0x09 /* Not-greater-than-or-equal (unordered, signaling) */
  1560. #define _CMP_NGT_US 0x0a /* Not-greater-than (unordered, signaling) */
  1561. #define _CMP_FALSE_OQ 0x0b /* False (ordered, non-signaling) */
  1562. #define _CMP_NEQ_OQ 0x0c /* Not-equal (ordered, non-signaling) */
  1563. #define _CMP_GE_OS 0x0d /* Greater-than-or-equal (ordered, signaling) */
  1564. #define _CMP_GT_OS 0x0e /* Greater-than (ordered, signaling) */
  1565. #define _CMP_TRUE_UQ 0x0f /* True (unordered, non-signaling) */
  1566. #define _CMP_EQ_OS 0x10 /* Equal (ordered, signaling) */
  1567. #define _CMP_LT_OQ 0x11 /* Less-than (ordered, non-signaling) */
  1568. #define _CMP_LE_OQ 0x12 /* Less-than-or-equal (ordered, non-signaling) */
  1569. #define _CMP_UNORD_S 0x13 /* Unordered (signaling) */
  1570. #define _CMP_NEQ_US 0x14 /* Not-equal (unordered, signaling) */
  1571. #define _CMP_NLT_UQ 0x15 /* Not-less-than (unordered, non-signaling) */
  1572. #define _CMP_NLE_UQ 0x16 /* Not-less-than-or-equal (unordered, non-signaling) */
  1573. #define _CMP_ORD_S 0x17 /* Ordered (signaling) */
  1574. #define _CMP_EQ_US 0x18 /* Equal (unordered, signaling) */
  1575. #define _CMP_NGE_UQ 0x19 /* Not-greater-than-or-equal (unordered, non-signaling) */
  1576. #define _CMP_NGT_UQ 0x1a /* Not-greater-than (unordered, non-signaling) */
  1577. #define _CMP_FALSE_OS 0x1b /* False (ordered, signaling) */
  1578. #define _CMP_NEQ_OS 0x1c /* Not-equal (ordered, signaling) */
  1579. #define _CMP_GE_OQ 0x1d /* Greater-than-or-equal (ordered, non-signaling) */
  1580. #define _CMP_GT_OQ 0x1e /* Greater-than (ordered, non-signaling) */
  1581. #define _CMP_TRUE_US 0x1f /* True (unordered, signaling) */
  1582. /// \brief Compares each of the corresponding double-precision values of two
  1583. /// 128-bit vectors of [2 x double], using the operation specified by the
  1584. /// immediate integer operand.
  1585. ///
  1586. /// Returns a [2 x double] vector consisting of two doubles corresponding to
  1587. /// the two comparison results: zero if the comparison is false, and all 1's
  1588. /// if the comparison is true.
  1589. ///
  1590. /// \headerfile <x86intrin.h>
  1591. ///
  1592. /// \code
  1593. /// __m128d _mm_cmp_pd(__m128d a, __m128d b, const int c);
  1594. /// \endcode
  1595. ///
  1596. /// This intrinsic corresponds to the <c> VCMPPD </c> instruction.
  1597. ///
  1598. /// \param a
  1599. /// A 128-bit vector of [2 x double].
  1600. /// \param b
  1601. /// A 128-bit vector of [2 x double].
  1602. /// \param c
  1603. /// An immediate integer operand, with bits [4:0] specifying which comparison
  1604. /// operation to use: \n
  1605. /// 0x00 : Equal (ordered, non-signaling)
  1606. /// 0x01 : Less-than (ordered, signaling)
  1607. /// 0x02 : Less-than-or-equal (ordered, signaling)
  1608. /// 0x03 : Unordered (non-signaling)
  1609. /// 0x04 : Not-equal (unordered, non-signaling)
  1610. /// 0x05 : Not-less-than (unordered, signaling)
  1611. /// 0x06 : Not-less-than-or-equal (unordered, signaling)
  1612. /// 0x07 : Ordered (non-signaling)
  1613. /// 0x08 : Equal (unordered, non-signaling)
  1614. /// 0x09 : Not-greater-than-or-equal (unordered, signaling)
  1615. /// 0x0a : Not-greater-than (unordered, signaling)
  1616. /// 0x0b : False (ordered, non-signaling)
  1617. /// 0x0c : Not-equal (ordered, non-signaling)
  1618. /// 0x0d : Greater-than-or-equal (ordered, signaling)
  1619. /// 0x0e : Greater-than (ordered, signaling)
  1620. /// 0x0f : True (unordered, non-signaling)
  1621. /// 0x10 : Equal (ordered, signaling)
  1622. /// 0x11 : Less-than (ordered, non-signaling)
  1623. /// 0x12 : Less-than-or-equal (ordered, non-signaling)
  1624. /// 0x13 : Unordered (signaling)
  1625. /// 0x14 : Not-equal (unordered, signaling)
  1626. /// 0x15 : Not-less-than (unordered, non-signaling)
  1627. /// 0x16 : Not-less-than-or-equal (unordered, non-signaling)
  1628. /// 0x17 : Ordered (signaling)
  1629. /// 0x18 : Equal (unordered, signaling)
  1630. /// 0x19 : Not-greater-than-or-equal (unordered, non-signaling)
  1631. /// 0x1a : Not-greater-than (unordered, non-signaling)
  1632. /// 0x1b : False (ordered, signaling)
  1633. /// 0x1c : Not-equal (ordered, signaling)
  1634. /// 0x1d : Greater-than-or-equal (ordered, non-signaling)
  1635. /// 0x1e : Greater-than (ordered, non-signaling)
  1636. /// 0x1f : True (unordered, signaling)
  1637. /// \returns A 128-bit vector of [2 x double] containing the comparison results.
  1638. #define _mm_cmp_pd(a, b, c) __extension__ ({ \
  1639. (__m128d)__builtin_ia32_cmppd((__v2df)(__m128d)(a), \
  1640. (__v2df)(__m128d)(b), (c)); })
  1641. /// \brief Compares each of the corresponding values of two 128-bit vectors of
  1642. /// [4 x float], using the operation specified by the immediate integer
  1643. /// operand.
  1644. ///
  1645. /// Returns a [4 x float] vector consisting of four floats corresponding to
  1646. /// the four comparison results: zero if the comparison is false, and all 1's
  1647. /// if the comparison is true.
  1648. ///
  1649. /// \headerfile <x86intrin.h>
  1650. ///
  1651. /// \code
  1652. /// __m128 _mm_cmp_ps(__m128 a, __m128 b, const int c);
  1653. /// \endcode
  1654. ///
  1655. /// This intrinsic corresponds to the <c> VCMPPS </c> instruction.
  1656. ///
  1657. /// \param a
  1658. /// A 128-bit vector of [4 x float].
  1659. /// \param b
  1660. /// A 128-bit vector of [4 x float].
  1661. /// \param c
  1662. /// An immediate integer operand, with bits [4:0] specifying which comparison
  1663. /// operation to use: \n
  1664. /// 0x00 : Equal (ordered, non-signaling)
  1665. /// 0x01 : Less-than (ordered, signaling)
  1666. /// 0x02 : Less-than-or-equal (ordered, signaling)
  1667. /// 0x03 : Unordered (non-signaling)
  1668. /// 0x04 : Not-equal (unordered, non-signaling)
  1669. /// 0x05 : Not-less-than (unordered, signaling)
  1670. /// 0x06 : Not-less-than-or-equal (unordered, signaling)
  1671. /// 0x07 : Ordered (non-signaling)
  1672. /// 0x08 : Equal (unordered, non-signaling)
  1673. /// 0x09 : Not-greater-than-or-equal (unordered, signaling)
  1674. /// 0x0a : Not-greater-than (unordered, signaling)
  1675. /// 0x0b : False (ordered, non-signaling)
  1676. /// 0x0c : Not-equal (ordered, non-signaling)
  1677. /// 0x0d : Greater-than-or-equal (ordered, signaling)
  1678. /// 0x0e : Greater-than (ordered, signaling)
  1679. /// 0x0f : True (unordered, non-signaling)
  1680. /// 0x10 : Equal (ordered, signaling)
  1681. /// 0x11 : Less-than (ordered, non-signaling)
  1682. /// 0x12 : Less-than-or-equal (ordered, non-signaling)
  1683. /// 0x13 : Unordered (signaling)
  1684. /// 0x14 : Not-equal (unordered, signaling)
  1685. /// 0x15 : Not-less-than (unordered, non-signaling)
  1686. /// 0x16 : Not-less-than-or-equal (unordered, non-signaling)
  1687. /// 0x17 : Ordered (signaling)
  1688. /// 0x18 : Equal (unordered, signaling)
  1689. /// 0x19 : Not-greater-than-or-equal (unordered, non-signaling)
  1690. /// 0x1a : Not-greater-than (unordered, non-signaling)
  1691. /// 0x1b : False (ordered, signaling)
  1692. /// 0x1c : Not-equal (ordered, signaling)
  1693. /// 0x1d : Greater-than-or-equal (ordered, non-signaling)
  1694. /// 0x1e : Greater-than (ordered, non-signaling)
  1695. /// 0x1f : True (unordered, signaling)
  1696. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  1697. #define _mm_cmp_ps(a, b, c) __extension__ ({ \
  1698. (__m128)__builtin_ia32_cmpps((__v4sf)(__m128)(a), \
  1699. (__v4sf)(__m128)(b), (c)); })
  1700. /// \brief Compares each of the corresponding double-precision values of two
  1701. /// 256-bit vectors of [4 x double], using the operation specified by the
  1702. /// immediate integer operand.
  1703. ///
  1704. /// Returns a [4 x double] vector consisting of four doubles corresponding to
  1705. /// the four comparison results: zero if the comparison is false, and all 1's
  1706. /// if the comparison is true.
  1707. ///
  1708. /// \headerfile <x86intrin.h>
  1709. ///
  1710. /// \code
  1711. /// __m256d _mm256_cmp_pd(__m256d a, __m256d b, const int c);
  1712. /// \endcode
  1713. ///
  1714. /// This intrinsic corresponds to the <c> VCMPPD </c> instruction.
  1715. ///
  1716. /// \param a
  1717. /// A 256-bit vector of [4 x double].
  1718. /// \param b
  1719. /// A 256-bit vector of [4 x double].
  1720. /// \param c
  1721. /// An immediate integer operand, with bits [4:0] specifying which comparison
  1722. /// operation to use: \n
  1723. /// 0x00 : Equal (ordered, non-signaling)
  1724. /// 0x01 : Less-than (ordered, signaling)
  1725. /// 0x02 : Less-than-or-equal (ordered, signaling)
  1726. /// 0x03 : Unordered (non-signaling)
  1727. /// 0x04 : Not-equal (unordered, non-signaling)
  1728. /// 0x05 : Not-less-than (unordered, signaling)
  1729. /// 0x06 : Not-less-than-or-equal (unordered, signaling)
  1730. /// 0x07 : Ordered (non-signaling)
  1731. /// 0x08 : Equal (unordered, non-signaling)
  1732. /// 0x09 : Not-greater-than-or-equal (unordered, signaling)
  1733. /// 0x0a : Not-greater-than (unordered, signaling)
  1734. /// 0x0b : False (ordered, non-signaling)
  1735. /// 0x0c : Not-equal (ordered, non-signaling)
  1736. /// 0x0d : Greater-than-or-equal (ordered, signaling)
  1737. /// 0x0e : Greater-than (ordered, signaling)
  1738. /// 0x0f : True (unordered, non-signaling)
  1739. /// 0x10 : Equal (ordered, signaling)
  1740. /// 0x11 : Less-than (ordered, non-signaling)
  1741. /// 0x12 : Less-than-or-equal (ordered, non-signaling)
  1742. /// 0x13 : Unordered (signaling)
  1743. /// 0x14 : Not-equal (unordered, signaling)
  1744. /// 0x15 : Not-less-than (unordered, non-signaling)
  1745. /// 0x16 : Not-less-than-or-equal (unordered, non-signaling)
  1746. /// 0x17 : Ordered (signaling)
  1747. /// 0x18 : Equal (unordered, signaling)
  1748. /// 0x19 : Not-greater-than-or-equal (unordered, non-signaling)
  1749. /// 0x1a : Not-greater-than (unordered, non-signaling)
  1750. /// 0x1b : False (ordered, signaling)
  1751. /// 0x1c : Not-equal (ordered, signaling)
  1752. /// 0x1d : Greater-than-or-equal (ordered, non-signaling)
  1753. /// 0x1e : Greater-than (ordered, non-signaling)
  1754. /// 0x1f : True (unordered, signaling)
  1755. /// \returns A 256-bit vector of [4 x double] containing the comparison results.
  1756. #define _mm256_cmp_pd(a, b, c) __extension__ ({ \
  1757. (__m256d)__builtin_ia32_cmppd256((__v4df)(__m256d)(a), \
  1758. (__v4df)(__m256d)(b), (c)); })
  1759. /// \brief Compares each of the corresponding values of two 256-bit vectors of
  1760. /// [8 x float], using the operation specified by the immediate integer
  1761. /// operand.
  1762. ///
  1763. /// Returns a [8 x float] vector consisting of eight floats corresponding to
  1764. /// the eight comparison results: zero if the comparison is false, and all
  1765. /// 1's if the comparison is true.
  1766. ///
  1767. /// \headerfile <x86intrin.h>
  1768. ///
  1769. /// \code
  1770. /// __m256 _mm256_cmp_ps(__m256 a, __m256 b, const int c);
  1771. /// \endcode
  1772. ///
  1773. /// This intrinsic corresponds to the <c> VCMPPS </c> instruction.
  1774. ///
  1775. /// \param a
  1776. /// A 256-bit vector of [8 x float].
  1777. /// \param b
  1778. /// A 256-bit vector of [8 x float].
  1779. /// \param c
  1780. /// An immediate integer operand, with bits [4:0] specifying which comparison
  1781. /// operation to use: \n
  1782. /// 0x00 : Equal (ordered, non-signaling)
  1783. /// 0x01 : Less-than (ordered, signaling)
  1784. /// 0x02 : Less-than-or-equal (ordered, signaling)
  1785. /// 0x03 : Unordered (non-signaling)
  1786. /// 0x04 : Not-equal (unordered, non-signaling)
  1787. /// 0x05 : Not-less-than (unordered, signaling)
  1788. /// 0x06 : Not-less-than-or-equal (unordered, signaling)
  1789. /// 0x07 : Ordered (non-signaling)
  1790. /// 0x08 : Equal (unordered, non-signaling)
  1791. /// 0x09 : Not-greater-than-or-equal (unordered, signaling)
  1792. /// 0x0a : Not-greater-than (unordered, signaling)
  1793. /// 0x0b : False (ordered, non-signaling)
  1794. /// 0x0c : Not-equal (ordered, non-signaling)
  1795. /// 0x0d : Greater-than-or-equal (ordered, signaling)
  1796. /// 0x0e : Greater-than (ordered, signaling)
  1797. /// 0x0f : True (unordered, non-signaling)
  1798. /// 0x10 : Equal (ordered, signaling)
  1799. /// 0x11 : Less-than (ordered, non-signaling)
  1800. /// 0x12 : Less-than-or-equal (ordered, non-signaling)
  1801. /// 0x13 : Unordered (signaling)
  1802. /// 0x14 : Not-equal (unordered, signaling)
  1803. /// 0x15 : Not-less-than (unordered, non-signaling)
  1804. /// 0x16 : Not-less-than-or-equal (unordered, non-signaling)
  1805. /// 0x17 : Ordered (signaling)
  1806. /// 0x18 : Equal (unordered, signaling)
  1807. /// 0x19 : Not-greater-than-or-equal (unordered, non-signaling)
  1808. /// 0x1a : Not-greater-than (unordered, non-signaling)
  1809. /// 0x1b : False (ordered, signaling)
  1810. /// 0x1c : Not-equal (ordered, signaling)
  1811. /// 0x1d : Greater-than-or-equal (ordered, non-signaling)
  1812. /// 0x1e : Greater-than (ordered, non-signaling)
  1813. /// 0x1f : True (unordered, signaling)
  1814. /// \returns A 256-bit vector of [8 x float] containing the comparison results.
  1815. #define _mm256_cmp_ps(a, b, c) __extension__ ({ \
  1816. (__m256)__builtin_ia32_cmpps256((__v8sf)(__m256)(a), \
  1817. (__v8sf)(__m256)(b), (c)); })
  1818. /// \brief Compares each of the corresponding scalar double-precision values of
  1819. /// two 128-bit vectors of [2 x double], using the operation specified by the
  1820. /// immediate integer operand.
  1821. ///
  1822. /// If the result is true, all 64 bits of the destination vector are set;
  1823. /// otherwise they are cleared.
  1824. ///
  1825. /// \headerfile <x86intrin.h>
  1826. ///
  1827. /// \code
  1828. /// __m128d _mm_cmp_sd(__m128d a, __m128d b, const int c);
  1829. /// \endcode
  1830. ///
  1831. /// This intrinsic corresponds to the <c> VCMPSD </c> instruction.
  1832. ///
  1833. /// \param a
  1834. /// A 128-bit vector of [2 x double].
  1835. /// \param b
  1836. /// A 128-bit vector of [2 x double].
  1837. /// \param c
  1838. /// An immediate integer operand, with bits [4:0] specifying which comparison
  1839. /// operation to use: \n
  1840. /// 0x00 : Equal (ordered, non-signaling)
  1841. /// 0x01 : Less-than (ordered, signaling)
  1842. /// 0x02 : Less-than-or-equal (ordered, signaling)
  1843. /// 0x03 : Unordered (non-signaling)
  1844. /// 0x04 : Not-equal (unordered, non-signaling)
  1845. /// 0x05 : Not-less-than (unordered, signaling)
  1846. /// 0x06 : Not-less-than-or-equal (unordered, signaling)
  1847. /// 0x07 : Ordered (non-signaling)
  1848. /// 0x08 : Equal (unordered, non-signaling)
  1849. /// 0x09 : Not-greater-than-or-equal (unordered, signaling)
  1850. /// 0x0a : Not-greater-than (unordered, signaling)
  1851. /// 0x0b : False (ordered, non-signaling)
  1852. /// 0x0c : Not-equal (ordered, non-signaling)
  1853. /// 0x0d : Greater-than-or-equal (ordered, signaling)
  1854. /// 0x0e : Greater-than (ordered, signaling)
  1855. /// 0x0f : True (unordered, non-signaling)
  1856. /// 0x10 : Equal (ordered, signaling)
  1857. /// 0x11 : Less-than (ordered, non-signaling)
  1858. /// 0x12 : Less-than-or-equal (ordered, non-signaling)
  1859. /// 0x13 : Unordered (signaling)
  1860. /// 0x14 : Not-equal (unordered, signaling)
  1861. /// 0x15 : Not-less-than (unordered, non-signaling)
  1862. /// 0x16 : Not-less-than-or-equal (unordered, non-signaling)
  1863. /// 0x17 : Ordered (signaling)
  1864. /// 0x18 : Equal (unordered, signaling)
  1865. /// 0x19 : Not-greater-than-or-equal (unordered, non-signaling)
  1866. /// 0x1a : Not-greater-than (unordered, non-signaling)
  1867. /// 0x1b : False (ordered, signaling)
  1868. /// 0x1c : Not-equal (ordered, signaling)
  1869. /// 0x1d : Greater-than-or-equal (ordered, non-signaling)
  1870. /// 0x1e : Greater-than (ordered, non-signaling)
  1871. /// 0x1f : True (unordered, signaling)
  1872. /// \returns A 128-bit vector of [2 x double] containing the comparison results.
  1873. #define _mm_cmp_sd(a, b, c) __extension__ ({ \
  1874. (__m128d)__builtin_ia32_cmpsd((__v2df)(__m128d)(a), \
  1875. (__v2df)(__m128d)(b), (c)); })
  1876. /// \brief Compares each of the corresponding scalar values of two 128-bit
  1877. /// vectors of [4 x float], using the operation specified by the immediate
  1878. /// integer operand.
  1879. ///
  1880. /// If the result is true, all 32 bits of the destination vector are set;
  1881. /// otherwise they are cleared.
  1882. ///
  1883. /// \headerfile <x86intrin.h>
  1884. ///
  1885. /// \code
  1886. /// __m128 _mm_cmp_ss(__m128 a, __m128 b, const int c);
  1887. /// \endcode
  1888. ///
  1889. /// This intrinsic corresponds to the <c> VCMPSS </c> instruction.
  1890. ///
  1891. /// \param a
  1892. /// A 128-bit vector of [4 x float].
  1893. /// \param b
  1894. /// A 128-bit vector of [4 x float].
  1895. /// \param c
  1896. /// An immediate integer operand, with bits [4:0] specifying which comparison
  1897. /// operation to use: \n
  1898. /// 0x00 : Equal (ordered, non-signaling)
  1899. /// 0x01 : Less-than (ordered, signaling)
  1900. /// 0x02 : Less-than-or-equal (ordered, signaling)
  1901. /// 0x03 : Unordered (non-signaling)
  1902. /// 0x04 : Not-equal (unordered, non-signaling)
  1903. /// 0x05 : Not-less-than (unordered, signaling)
  1904. /// 0x06 : Not-less-than-or-equal (unordered, signaling)
  1905. /// 0x07 : Ordered (non-signaling)
  1906. /// 0x08 : Equal (unordered, non-signaling)
  1907. /// 0x09 : Not-greater-than-or-equal (unordered, signaling)
  1908. /// 0x0a : Not-greater-than (unordered, signaling)
  1909. /// 0x0b : False (ordered, non-signaling)
  1910. /// 0x0c : Not-equal (ordered, non-signaling)
  1911. /// 0x0d : Greater-than-or-equal (ordered, signaling)
  1912. /// 0x0e : Greater-than (ordered, signaling)
  1913. /// 0x0f : True (unordered, non-signaling)
  1914. /// 0x10 : Equal (ordered, signaling)
  1915. /// 0x11 : Less-than (ordered, non-signaling)
  1916. /// 0x12 : Less-than-or-equal (ordered, non-signaling)
  1917. /// 0x13 : Unordered (signaling)
  1918. /// 0x14 : Not-equal (unordered, signaling)
  1919. /// 0x15 : Not-less-than (unordered, non-signaling)
  1920. /// 0x16 : Not-less-than-or-equal (unordered, non-signaling)
  1921. /// 0x17 : Ordered (signaling)
  1922. /// 0x18 : Equal (unordered, signaling)
  1923. /// 0x19 : Not-greater-than-or-equal (unordered, non-signaling)
  1924. /// 0x1a : Not-greater-than (unordered, non-signaling)
  1925. /// 0x1b : False (ordered, signaling)
  1926. /// 0x1c : Not-equal (ordered, signaling)
  1927. /// 0x1d : Greater-than-or-equal (ordered, non-signaling)
  1928. /// 0x1e : Greater-than (ordered, non-signaling)
  1929. /// 0x1f : True (unordered, signaling)
  1930. /// \returns A 128-bit vector of [4 x float] containing the comparison results.
  1931. #define _mm_cmp_ss(a, b, c) __extension__ ({ \
  1932. (__m128)__builtin_ia32_cmpss((__v4sf)(__m128)(a), \
  1933. (__v4sf)(__m128)(b), (c)); })
  1934. /// \brief Takes a [8 x i32] vector and returns the vector element value
  1935. /// indexed by the immediate constant operand.
  1936. ///
  1937. /// \headerfile <x86intrin.h>
  1938. ///
  1939. /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
  1940. /// instruction.
  1941. ///
  1942. /// \param __a
  1943. /// A 256-bit vector of [8 x i32].
  1944. /// \param __imm
  1945. /// An immediate integer operand with bits [2:0] determining which vector
  1946. /// element is extracted and returned.
  1947. /// \returns A 32-bit integer containing the extracted 32 bits of extended
  1948. /// packed data.
  1949. static __inline int __DEFAULT_FN_ATTRS
  1950. _mm256_extract_epi32(__m256i __a, const int __imm)
  1951. {
  1952. __v8si __b = (__v8si)__a;
  1953. return __b[__imm & 7];
  1954. }
  1955. /// \brief Takes a [16 x i16] vector and returns the vector element value
  1956. /// indexed by the immediate constant operand.
  1957. ///
  1958. /// \headerfile <x86intrin.h>
  1959. ///
  1960. /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
  1961. /// instruction.
  1962. ///
  1963. /// \param __a
  1964. /// A 256-bit integer vector of [16 x i16].
  1965. /// \param __imm
  1966. /// An immediate integer operand with bits [3:0] determining which vector
  1967. /// element is extracted and returned.
  1968. /// \returns A 32-bit integer containing the extracted 16 bits of zero extended
  1969. /// packed data.
  1970. static __inline int __DEFAULT_FN_ATTRS
  1971. _mm256_extract_epi16(__m256i __a, const int __imm)
  1972. {
  1973. __v16hi __b = (__v16hi)__a;
  1974. return (unsigned short)__b[__imm & 15];
  1975. }
  1976. /// \brief Takes a [32 x i8] vector and returns the vector element value
  1977. /// indexed by the immediate constant operand.
  1978. ///
  1979. /// \headerfile <x86intrin.h>
  1980. ///
  1981. /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
  1982. /// instruction.
  1983. ///
  1984. /// \param __a
  1985. /// A 256-bit integer vector of [32 x i8].
  1986. /// \param __imm
  1987. /// An immediate integer operand with bits [4:0] determining which vector
  1988. /// element is extracted and returned.
  1989. /// \returns A 32-bit integer containing the extracted 8 bits of zero extended
  1990. /// packed data.
  1991. static __inline int __DEFAULT_FN_ATTRS
  1992. _mm256_extract_epi8(__m256i __a, const int __imm)
  1993. {
  1994. __v32qi __b = (__v32qi)__a;
  1995. return (unsigned char)__b[__imm & 31];
  1996. }
  1997. #ifdef __x86_64__
  1998. /// \brief Takes a [4 x i64] vector and returns the vector element value
  1999. /// indexed by the immediate constant operand.
  2000. ///
  2001. /// \headerfile <x86intrin.h>
  2002. ///
  2003. /// This intrinsic corresponds to the <c> VEXTRACTF128+COMPOSITE </c>
  2004. /// instruction.
  2005. ///
  2006. /// \param __a
  2007. /// A 256-bit integer vector of [4 x i64].
  2008. /// \param __imm
  2009. /// An immediate integer operand with bits [1:0] determining which vector
  2010. /// element is extracted and returned.
  2011. /// \returns A 64-bit integer containing the extracted 64 bits of extended
  2012. /// packed data.
  2013. static __inline long long __DEFAULT_FN_ATTRS
  2014. _mm256_extract_epi64(__m256i __a, const int __imm)
  2015. {
  2016. __v4di __b = (__v4di)__a;
  2017. return __b[__imm & 3];
  2018. }
  2019. #endif
  2020. /// \brief Takes a [8 x i32] vector and replaces the vector element value
  2021. /// indexed by the immediate constant operand by a new value. Returns the
  2022. /// modified vector.
  2023. ///
  2024. /// \headerfile <x86intrin.h>
  2025. ///
  2026. /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
  2027. /// instruction.
  2028. ///
  2029. /// \param __a
  2030. /// A vector of [8 x i32] to be used by the insert operation.
  2031. /// \param __b
  2032. /// An integer value. The replacement value for the insert operation.
  2033. /// \param __imm
  2034. /// An immediate integer specifying the index of the vector element to be
  2035. /// replaced.
  2036. /// \returns A copy of vector \a __a, after replacing its element indexed by
  2037. /// \a __imm with \a __b.
  2038. static __inline __m256i __DEFAULT_FN_ATTRS
  2039. _mm256_insert_epi32(__m256i __a, int __b, int const __imm)
  2040. {
  2041. __v8si __c = (__v8si)__a;
  2042. __c[__imm & 7] = __b;
  2043. return (__m256i)__c;
  2044. }
  2045. /// \brief Takes a [16 x i16] vector and replaces the vector element value
  2046. /// indexed by the immediate constant operand with a new value. Returns the
  2047. /// modified vector.
  2048. ///
  2049. /// \headerfile <x86intrin.h>
  2050. ///
  2051. /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
  2052. /// instruction.
  2053. ///
  2054. /// \param __a
  2055. /// A vector of [16 x i16] to be used by the insert operation.
  2056. /// \param __b
  2057. /// An i16 integer value. The replacement value for the insert operation.
  2058. /// \param __imm
  2059. /// An immediate integer specifying the index of the vector element to be
  2060. /// replaced.
  2061. /// \returns A copy of vector \a __a, after replacing its element indexed by
  2062. /// \a __imm with \a __b.
  2063. static __inline __m256i __DEFAULT_FN_ATTRS
  2064. _mm256_insert_epi16(__m256i __a, int __b, int const __imm)
  2065. {
  2066. __v16hi __c = (__v16hi)__a;
  2067. __c[__imm & 15] = __b;
  2068. return (__m256i)__c;
  2069. }
  2070. /// \brief Takes a [32 x i8] vector and replaces the vector element value
  2071. /// indexed by the immediate constant operand with a new value. Returns the
  2072. /// modified vector.
  2073. ///
  2074. /// \headerfile <x86intrin.h>
  2075. ///
  2076. /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
  2077. /// instruction.
  2078. ///
  2079. /// \param __a
  2080. /// A vector of [32 x i8] to be used by the insert operation.
  2081. /// \param __b
  2082. /// An i8 integer value. The replacement value for the insert operation.
  2083. /// \param __imm
  2084. /// An immediate integer specifying the index of the vector element to be
  2085. /// replaced.
  2086. /// \returns A copy of vector \a __a, after replacing its element indexed by
  2087. /// \a __imm with \a __b.
  2088. static __inline __m256i __DEFAULT_FN_ATTRS
  2089. _mm256_insert_epi8(__m256i __a, int __b, int const __imm)
  2090. {
  2091. __v32qi __c = (__v32qi)__a;
  2092. __c[__imm & 31] = __b;
  2093. return (__m256i)__c;
  2094. }
  2095. #ifdef __x86_64__
  2096. /// \brief Takes a [4 x i64] vector and replaces the vector element value
  2097. /// indexed by the immediate constant operand with a new value. Returns the
  2098. /// modified vector.
  2099. ///
  2100. /// \headerfile <x86intrin.h>
  2101. ///
  2102. /// This intrinsic corresponds to the <c> VINSERTF128+COMPOSITE </c>
  2103. /// instruction.
  2104. ///
  2105. /// \param __a
  2106. /// A vector of [4 x i64] to be used by the insert operation.
  2107. /// \param __b
  2108. /// A 64-bit integer value. The replacement value for the insert operation.
  2109. /// \param __imm
  2110. /// An immediate integer specifying the index of the vector element to be
  2111. /// replaced.
  2112. /// \returns A copy of vector \a __a, after replacing its element indexed by
  2113. /// \a __imm with \a __b.
  2114. static __inline __m256i __DEFAULT_FN_ATTRS
  2115. _mm256_insert_epi64(__m256i __a, long long __b, int const __imm)
  2116. {
  2117. __v4di __c = (__v4di)__a;
  2118. __c[__imm & 3] = __b;
  2119. return (__m256i)__c;
  2120. }
  2121. #endif
  2122. /* Conversion */
  2123. /// \brief Converts a vector of [4 x i32] into a vector of [4 x double].
  2124. ///
  2125. /// \headerfile <x86intrin.h>
  2126. ///
  2127. /// This intrinsic corresponds to the <c> VCVTDQ2PD </c> instruction.
  2128. ///
  2129. /// \param __a
  2130. /// A 128-bit integer vector of [4 x i32].
  2131. /// \returns A 256-bit vector of [4 x double] containing the converted values.
  2132. static __inline __m256d __DEFAULT_FN_ATTRS
  2133. _mm256_cvtepi32_pd(__m128i __a)
  2134. {
  2135. return (__m256d)__builtin_convertvector((__v4si)__a, __v4df);
  2136. }
  2137. /// \brief Converts a vector of [8 x i32] into a vector of [8 x float].
  2138. ///
  2139. /// \headerfile <x86intrin.h>
  2140. ///
  2141. /// This intrinsic corresponds to the <c> VCVTDQ2PS </c> instruction.
  2142. ///
  2143. /// \param __a
  2144. /// A 256-bit integer vector.
  2145. /// \returns A 256-bit vector of [8 x float] containing the converted values.
  2146. static __inline __m256 __DEFAULT_FN_ATTRS
  2147. _mm256_cvtepi32_ps(__m256i __a)
  2148. {
  2149. return (__m256)__builtin_ia32_cvtdq2ps256((__v8si) __a);
  2150. }
  2151. /// \brief Converts a 256-bit vector of [4 x double] into a 128-bit vector of
  2152. /// [4 x float].
  2153. ///
  2154. /// \headerfile <x86intrin.h>
  2155. ///
  2156. /// This intrinsic corresponds to the <c> VCVTPD2PS </c> instruction.
  2157. ///
  2158. /// \param __a
  2159. /// A 256-bit vector of [4 x double].
  2160. /// \returns A 128-bit vector of [4 x float] containing the converted values.
  2161. static __inline __m128 __DEFAULT_FN_ATTRS
  2162. _mm256_cvtpd_ps(__m256d __a)
  2163. {
  2164. return (__m128)__builtin_ia32_cvtpd2ps256((__v4df) __a);
  2165. }
  2166. /// \brief Converts a vector of [8 x float] into a vector of [8 x i32].
  2167. ///
  2168. /// \headerfile <x86intrin.h>
  2169. ///
  2170. /// This intrinsic corresponds to the <c> VCVTPS2DQ </c> instruction.
  2171. ///
  2172. /// \param __a
  2173. /// A 256-bit vector of [8 x float].
  2174. /// \returns A 256-bit integer vector containing the converted values.
  2175. static __inline __m256i __DEFAULT_FN_ATTRS
  2176. _mm256_cvtps_epi32(__m256 __a)
  2177. {
  2178. return (__m256i)__builtin_ia32_cvtps2dq256((__v8sf) __a);
  2179. }
  2180. /// \brief Converts a 128-bit vector of [4 x float] into a 256-bit vector of [4
  2181. /// x double].
  2182. ///
  2183. /// \headerfile <x86intrin.h>
  2184. ///
  2185. /// This intrinsic corresponds to the <c> VCVTPS2PD </c> instruction.
  2186. ///
  2187. /// \param __a
  2188. /// A 128-bit vector of [4 x float].
  2189. /// \returns A 256-bit vector of [4 x double] containing the converted values.
  2190. static __inline __m256d __DEFAULT_FN_ATTRS
  2191. _mm256_cvtps_pd(__m128 __a)
  2192. {
  2193. return (__m256d)__builtin_convertvector((__v4sf)__a, __v4df);
  2194. }
  2195. /// \brief Converts a 256-bit vector of [4 x double] into a 128-bit vector of [4
  2196. /// x i32], truncating the result by rounding towards zero when it is
  2197. /// inexact.
  2198. ///
  2199. /// \headerfile <x86intrin.h>
  2200. ///
  2201. /// This intrinsic corresponds to the <c> VCVTTPD2DQ </c> instruction.
  2202. ///
  2203. /// \param __a
  2204. /// A 256-bit vector of [4 x double].
  2205. /// \returns A 128-bit integer vector containing the converted values.
  2206. static __inline __m128i __DEFAULT_FN_ATTRS
  2207. _mm256_cvttpd_epi32(__m256d __a)
  2208. {
  2209. return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a);
  2210. }
  2211. /// \brief Converts a 256-bit vector of [4 x double] into a 128-bit vector of [4
  2212. /// x i32]. When a conversion is inexact, the value returned is rounded
  2213. /// according to the rounding control bits in the MXCSR register.
  2214. ///
  2215. /// \headerfile <x86intrin.h>
  2216. ///
  2217. /// This intrinsic corresponds to the <c> VCVTPD2DQ </c> instruction.
  2218. ///
  2219. /// \param __a
  2220. /// A 256-bit vector of [4 x double].
  2221. /// \returns A 128-bit integer vector containing the converted values.
  2222. static __inline __m128i __DEFAULT_FN_ATTRS
  2223. _mm256_cvtpd_epi32(__m256d __a)
  2224. {
  2225. return (__m128i)__builtin_ia32_cvtpd2dq256((__v4df) __a);
  2226. }
  2227. /// \brief Converts a vector of [8 x float] into a vector of [8 x i32],
  2228. /// truncating the result by rounding towards zero when it is inexact.
  2229. ///
  2230. /// \headerfile <x86intrin.h>
  2231. ///
  2232. /// This intrinsic corresponds to the <c> VCVTTPS2DQ </c> instruction.
  2233. ///
  2234. /// \param __a
  2235. /// A 256-bit vector of [8 x float].
  2236. /// \returns A 256-bit integer vector containing the converted values.
  2237. static __inline __m256i __DEFAULT_FN_ATTRS
  2238. _mm256_cvttps_epi32(__m256 __a)
  2239. {
  2240. return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a);
  2241. }
  2242. /// \brief Returns the first element of the input vector of [4 x double].
  2243. ///
  2244. /// \headerfile <avxintrin.h>
  2245. ///
  2246. /// This intrinsic is a utility function and does not correspond to a specific
  2247. /// instruction.
  2248. ///
  2249. /// \param __a
  2250. /// A 256-bit vector of [4 x double].
  2251. /// \returns A 64 bit double containing the first element of the input vector.
  2252. static __inline double __DEFAULT_FN_ATTRS
  2253. _mm256_cvtsd_f64(__m256d __a)
  2254. {
  2255. return __a[0];
  2256. }
  2257. /// \brief Returns the first element of the input vector of [8 x i32].
  2258. ///
  2259. /// \headerfile <avxintrin.h>
  2260. ///
  2261. /// This intrinsic is a utility function and does not correspond to a specific
  2262. /// instruction.
  2263. ///
  2264. /// \param __a
  2265. /// A 256-bit vector of [8 x i32].
  2266. /// \returns A 32 bit integer containing the first element of the input vector.
  2267. static __inline int __DEFAULT_FN_ATTRS
  2268. _mm256_cvtsi256_si32(__m256i __a)
  2269. {
  2270. __v8si __b = (__v8si)__a;
  2271. return __b[0];
  2272. }
  2273. /// \brief Returns the first element of the input vector of [8 x float].
  2274. ///
  2275. /// \headerfile <avxintrin.h>
  2276. ///
  2277. /// This intrinsic is a utility function and does not correspond to a specific
  2278. /// instruction.
  2279. ///
  2280. /// \param __a
  2281. /// A 256-bit vector of [8 x float].
  2282. /// \returns A 32 bit float containing the first element of the input vector.
  2283. static __inline float __DEFAULT_FN_ATTRS
  2284. _mm256_cvtss_f32(__m256 __a)
  2285. {
  2286. return __a[0];
  2287. }
  2288. /* Vector replicate */
  2289. /// \brief Moves and duplicates high-order (odd-indexed) values from a 256-bit
  2290. /// vector of [8 x float] to float values in a 256-bit vector of
  2291. /// [8 x float].
  2292. ///
  2293. /// \headerfile <x86intrin.h>
  2294. ///
  2295. /// This intrinsic corresponds to the <c> VMOVSHDUP </c> instruction.
  2296. ///
  2297. /// \param __a
  2298. /// A 256-bit vector of [8 x float]. \n
  2299. /// Bits [255:224] of \a __a are written to bits [255:224] and [223:192] of
  2300. /// the return value. \n
  2301. /// Bits [191:160] of \a __a are written to bits [191:160] and [159:128] of
  2302. /// the return value. \n
  2303. /// Bits [127:96] of \a __a are written to bits [127:96] and [95:64] of the
  2304. /// return value. \n
  2305. /// Bits [63:32] of \a __a are written to bits [63:32] and [31:0] of the
  2306. /// return value.
  2307. /// \returns A 256-bit vector of [8 x float] containing the moved and duplicated
  2308. /// values.
  2309. static __inline __m256 __DEFAULT_FN_ATTRS
  2310. _mm256_movehdup_ps(__m256 __a)
  2311. {
  2312. return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 1, 1, 3, 3, 5, 5, 7, 7);
  2313. }
  2314. /// \brief Moves and duplicates low-order (even-indexed) values from a 256-bit
  2315. /// vector of [8 x float] to float values in a 256-bit vector of [8 x float].
  2316. ///
  2317. /// \headerfile <x86intrin.h>
  2318. ///
  2319. /// This intrinsic corresponds to the <c> VMOVSLDUP </c> instruction.
  2320. ///
  2321. /// \param __a
  2322. /// A 256-bit vector of [8 x float]. \n
  2323. /// Bits [223:192] of \a __a are written to bits [255:224] and [223:192] of
  2324. /// the return value. \n
  2325. /// Bits [159:128] of \a __a are written to bits [191:160] and [159:128] of
  2326. /// the return value. \n
  2327. /// Bits [95:64] of \a __a are written to bits [127:96] and [95:64] of the
  2328. /// return value. \n
  2329. /// Bits [31:0] of \a __a are written to bits [63:32] and [31:0] of the
  2330. /// return value.
  2331. /// \returns A 256-bit vector of [8 x float] containing the moved and duplicated
  2332. /// values.
  2333. static __inline __m256 __DEFAULT_FN_ATTRS
  2334. _mm256_moveldup_ps(__m256 __a)
  2335. {
  2336. return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 0, 0, 2, 2, 4, 4, 6, 6);
  2337. }
  2338. /// \brief Moves and duplicates double-precision floating point values from a
  2339. /// 256-bit vector of [4 x double] to double-precision values in a 256-bit
  2340. /// vector of [4 x double].
  2341. ///
  2342. /// \headerfile <x86intrin.h>
  2343. ///
  2344. /// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction.
  2345. ///
  2346. /// \param __a
  2347. /// A 256-bit vector of [4 x double]. \n
  2348. /// Bits [63:0] of \a __a are written to bits [127:64] and [63:0] of the
  2349. /// return value. \n
  2350. /// Bits [191:128] of \a __a are written to bits [255:192] and [191:128] of
  2351. /// the return value.
  2352. /// \returns A 256-bit vector of [4 x double] containing the moved and
  2353. /// duplicated values.
  2354. static __inline __m256d __DEFAULT_FN_ATTRS
  2355. _mm256_movedup_pd(__m256d __a)
  2356. {
  2357. return __builtin_shufflevector((__v4df)__a, (__v4df)__a, 0, 0, 2, 2);
  2358. }
  2359. /* Unpack and Interleave */
  2360. /// \brief Unpacks the odd-indexed vector elements from two 256-bit vectors of
  2361. /// [4 x double] and interleaves them into a 256-bit vector of [4 x double].
  2362. ///
  2363. /// \headerfile <x86intrin.h>
  2364. ///
  2365. /// This intrinsic corresponds to the <c> VUNPCKHPD </c> instruction.
  2366. ///
  2367. /// \param __a
  2368. /// A 256-bit floating-point vector of [4 x double]. \n
  2369. /// Bits [127:64] are written to bits [63:0] of the return value. \n
  2370. /// Bits [255:192] are written to bits [191:128] of the return value. \n
  2371. /// \param __b
  2372. /// A 256-bit floating-point vector of [4 x double]. \n
  2373. /// Bits [127:64] are written to bits [127:64] of the return value. \n
  2374. /// Bits [255:192] are written to bits [255:192] of the return value. \n
  2375. /// \returns A 256-bit vector of [4 x double] containing the interleaved values.
  2376. static __inline __m256d __DEFAULT_FN_ATTRS
  2377. _mm256_unpackhi_pd(__m256d __a, __m256d __b)
  2378. {
  2379. return __builtin_shufflevector((__v4df)__a, (__v4df)__b, 1, 5, 1+2, 5+2);
  2380. }
  2381. /// \brief Unpacks the even-indexed vector elements from two 256-bit vectors of
  2382. /// [4 x double] and interleaves them into a 256-bit vector of [4 x double].
  2383. ///
  2384. /// \headerfile <x86intrin.h>
  2385. ///
  2386. /// This intrinsic corresponds to the <c> VUNPCKLPD </c> instruction.
  2387. ///
  2388. /// \param __a
  2389. /// A 256-bit floating-point vector of [4 x double]. \n
  2390. /// Bits [63:0] are written to bits [63:0] of the return value. \n
  2391. /// Bits [191:128] are written to bits [191:128] of the return value.
  2392. /// \param __b
  2393. /// A 256-bit floating-point vector of [4 x double]. \n
  2394. /// Bits [63:0] are written to bits [127:64] of the return value. \n
  2395. /// Bits [191:128] are written to bits [255:192] of the return value. \n
  2396. /// \returns A 256-bit vector of [4 x double] containing the interleaved values.
  2397. static __inline __m256d __DEFAULT_FN_ATTRS
  2398. _mm256_unpacklo_pd(__m256d __a, __m256d __b)
  2399. {
  2400. return __builtin_shufflevector((__v4df)__a, (__v4df)__b, 0, 4, 0+2, 4+2);
  2401. }
  2402. /// \brief Unpacks the 32-bit vector elements 2, 3, 6 and 7 from each of the
  2403. /// two 256-bit vectors of [8 x float] and interleaves them into a 256-bit
  2404. /// vector of [8 x float].
  2405. ///
  2406. /// \headerfile <x86intrin.h>
  2407. ///
  2408. /// This intrinsic corresponds to the <c> VUNPCKHPS </c> instruction.
  2409. ///
  2410. /// \param __a
  2411. /// A 256-bit vector of [8 x float]. \n
  2412. /// Bits [95:64] are written to bits [31:0] of the return value. \n
  2413. /// Bits [127:96] are written to bits [95:64] of the return value. \n
  2414. /// Bits [223:192] are written to bits [159:128] of the return value. \n
  2415. /// Bits [255:224] are written to bits [223:192] of the return value.
  2416. /// \param __b
  2417. /// A 256-bit vector of [8 x float]. \n
  2418. /// Bits [95:64] are written to bits [63:32] of the return value. \n
  2419. /// Bits [127:96] are written to bits [127:96] of the return value. \n
  2420. /// Bits [223:192] are written to bits [191:160] of the return value. \n
  2421. /// Bits [255:224] are written to bits [255:224] of the return value.
  2422. /// \returns A 256-bit vector of [8 x float] containing the interleaved values.
  2423. static __inline __m256 __DEFAULT_FN_ATTRS
  2424. _mm256_unpackhi_ps(__m256 __a, __m256 __b)
  2425. {
  2426. return __builtin_shufflevector((__v8sf)__a, (__v8sf)__b, 2, 10, 2+1, 10+1, 6, 14, 6+1, 14+1);
  2427. }
  2428. /// \brief Unpacks the 32-bit vector elements 0, 1, 4 and 5 from each of the
  2429. /// two 256-bit vectors of [8 x float] and interleaves them into a 256-bit
  2430. /// vector of [8 x float].
  2431. ///
  2432. /// \headerfile <x86intrin.h>
  2433. ///
  2434. /// This intrinsic corresponds to the <c> VUNPCKLPS </c> instruction.
  2435. ///
  2436. /// \param __a
  2437. /// A 256-bit vector of [8 x float]. \n
  2438. /// Bits [31:0] are written to bits [31:0] of the return value. \n
  2439. /// Bits [63:32] are written to bits [95:64] of the return value. \n
  2440. /// Bits [159:128] are written to bits [159:128] of the return value. \n
  2441. /// Bits [191:160] are written to bits [223:192] of the return value.
  2442. /// \param __b
  2443. /// A 256-bit vector of [8 x float]. \n
  2444. /// Bits [31:0] are written to bits [63:32] of the return value. \n
  2445. /// Bits [63:32] are written to bits [127:96] of the return value. \n
  2446. /// Bits [159:128] are written to bits [191:160] of the return value. \n
  2447. /// Bits [191:160] are written to bits [255:224] of the return value.
  2448. /// \returns A 256-bit vector of [8 x float] containing the interleaved values.
  2449. static __inline __m256 __DEFAULT_FN_ATTRS
  2450. _mm256_unpacklo_ps(__m256 __a, __m256 __b)
  2451. {
  2452. return __builtin_shufflevector((__v8sf)__a, (__v8sf)__b, 0, 8, 0+1, 8+1, 4, 12, 4+1, 12+1);
  2453. }
  2454. /* Bit Test */
  2455. /// \brief Given two 128-bit floating-point vectors of [2 x double], perform an
  2456. /// element-by-element comparison of the double-precision element in the
  2457. /// first source vector and the corresponding element in the second source
  2458. /// vector.
  2459. ///
  2460. /// The EFLAGS register is updated as follows: \n
  2461. /// If there is at least one pair of double-precision elements where the
  2462. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2463. /// ZF flag is set to 1. \n
  2464. /// If there is at least one pair of double-precision elements where the
  2465. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2466. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2467. /// This intrinsic returns the value of the ZF flag.
  2468. ///
  2469. /// \headerfile <x86intrin.h>
  2470. ///
  2471. /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
  2472. ///
  2473. /// \param __a
  2474. /// A 128-bit vector of [2 x double].
  2475. /// \param __b
  2476. /// A 128-bit vector of [2 x double].
  2477. /// \returns the ZF flag in the EFLAGS register.
  2478. static __inline int __DEFAULT_FN_ATTRS
  2479. _mm_testz_pd(__m128d __a, __m128d __b)
  2480. {
  2481. return __builtin_ia32_vtestzpd((__v2df)__a, (__v2df)__b);
  2482. }
  2483. /// \brief Given two 128-bit floating-point vectors of [2 x double], perform an
  2484. /// element-by-element comparison of the double-precision element in the
  2485. /// first source vector and the corresponding element in the second source
  2486. /// vector.
  2487. ///
  2488. /// The EFLAGS register is updated as follows: \n
  2489. /// If there is at least one pair of double-precision elements where the
  2490. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2491. /// ZF flag is set to 1. \n
  2492. /// If there is at least one pair of double-precision elements where the
  2493. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2494. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2495. /// This intrinsic returns the value of the CF flag.
  2496. ///
  2497. /// \headerfile <x86intrin.h>
  2498. ///
  2499. /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
  2500. ///
  2501. /// \param __a
  2502. /// A 128-bit vector of [2 x double].
  2503. /// \param __b
  2504. /// A 128-bit vector of [2 x double].
  2505. /// \returns the CF flag in the EFLAGS register.
  2506. static __inline int __DEFAULT_FN_ATTRS
  2507. _mm_testc_pd(__m128d __a, __m128d __b)
  2508. {
  2509. return __builtin_ia32_vtestcpd((__v2df)__a, (__v2df)__b);
  2510. }
  2511. /// \brief Given two 128-bit floating-point vectors of [2 x double], perform an
  2512. /// element-by-element comparison of the double-precision element in the
  2513. /// first source vector and the corresponding element in the second source
  2514. /// vector.
  2515. ///
  2516. /// The EFLAGS register is updated as follows: \n
  2517. /// If there is at least one pair of double-precision elements where the
  2518. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2519. /// ZF flag is set to 1. \n
  2520. /// If there is at least one pair of double-precision elements where the
  2521. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2522. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2523. /// This intrinsic returns 1 if both the ZF and CF flags are set to 0,
  2524. /// otherwise it returns 0.
  2525. ///
  2526. /// \headerfile <x86intrin.h>
  2527. ///
  2528. /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
  2529. ///
  2530. /// \param __a
  2531. /// A 128-bit vector of [2 x double].
  2532. /// \param __b
  2533. /// A 128-bit vector of [2 x double].
  2534. /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
  2535. static __inline int __DEFAULT_FN_ATTRS
  2536. _mm_testnzc_pd(__m128d __a, __m128d __b)
  2537. {
  2538. return __builtin_ia32_vtestnzcpd((__v2df)__a, (__v2df)__b);
  2539. }
  2540. /// \brief Given two 128-bit floating-point vectors of [4 x float], perform an
  2541. /// element-by-element comparison of the single-precision element in the
  2542. /// first source vector and the corresponding element in the second source
  2543. /// vector.
  2544. ///
  2545. /// The EFLAGS register is updated as follows: \n
  2546. /// If there is at least one pair of single-precision elements where the
  2547. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2548. /// ZF flag is set to 1. \n
  2549. /// If there is at least one pair of single-precision elements where the
  2550. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2551. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2552. /// This intrinsic returns the value of the ZF flag.
  2553. ///
  2554. /// \headerfile <x86intrin.h>
  2555. ///
  2556. /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
  2557. ///
  2558. /// \param __a
  2559. /// A 128-bit vector of [4 x float].
  2560. /// \param __b
  2561. /// A 128-bit vector of [4 x float].
  2562. /// \returns the ZF flag.
  2563. static __inline int __DEFAULT_FN_ATTRS
  2564. _mm_testz_ps(__m128 __a, __m128 __b)
  2565. {
  2566. return __builtin_ia32_vtestzps((__v4sf)__a, (__v4sf)__b);
  2567. }
  2568. /// \brief Given two 128-bit floating-point vectors of [4 x float], perform an
  2569. /// element-by-element comparison of the single-precision element in the
  2570. /// first source vector and the corresponding element in the second source
  2571. /// vector.
  2572. ///
  2573. /// The EFLAGS register is updated as follows: \n
  2574. /// If there is at least one pair of single-precision elements where the
  2575. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2576. /// ZF flag is set to 1. \n
  2577. /// If there is at least one pair of single-precision elements where the
  2578. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2579. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2580. /// This intrinsic returns the value of the CF flag.
  2581. ///
  2582. /// \headerfile <x86intrin.h>
  2583. ///
  2584. /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
  2585. ///
  2586. /// \param __a
  2587. /// A 128-bit vector of [4 x float].
  2588. /// \param __b
  2589. /// A 128-bit vector of [4 x float].
  2590. /// \returns the CF flag.
  2591. static __inline int __DEFAULT_FN_ATTRS
  2592. _mm_testc_ps(__m128 __a, __m128 __b)
  2593. {
  2594. return __builtin_ia32_vtestcps((__v4sf)__a, (__v4sf)__b);
  2595. }
  2596. /// \brief Given two 128-bit floating-point vectors of [4 x float], perform an
  2597. /// element-by-element comparison of the single-precision element in the
  2598. /// first source vector and the corresponding element in the second source
  2599. /// vector.
  2600. ///
  2601. /// The EFLAGS register is updated as follows: \n
  2602. /// If there is at least one pair of single-precision elements where the
  2603. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2604. /// ZF flag is set to 1. \n
  2605. /// If there is at least one pair of single-precision elements where the
  2606. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2607. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2608. /// This intrinsic returns 1 if both the ZF and CF flags are set to 0,
  2609. /// otherwise it returns 0.
  2610. ///
  2611. /// \headerfile <x86intrin.h>
  2612. ///
  2613. /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
  2614. ///
  2615. /// \param __a
  2616. /// A 128-bit vector of [4 x float].
  2617. /// \param __b
  2618. /// A 128-bit vector of [4 x float].
  2619. /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
  2620. static __inline int __DEFAULT_FN_ATTRS
  2621. _mm_testnzc_ps(__m128 __a, __m128 __b)
  2622. {
  2623. return __builtin_ia32_vtestnzcps((__v4sf)__a, (__v4sf)__b);
  2624. }
  2625. /// \brief Given two 256-bit floating-point vectors of [4 x double], perform an
  2626. /// element-by-element comparison of the double-precision elements in the
  2627. /// first source vector and the corresponding elements in the second source
  2628. /// vector.
  2629. ///
  2630. /// The EFLAGS register is updated as follows: \n
  2631. /// If there is at least one pair of double-precision elements where the
  2632. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2633. /// ZF flag is set to 1. \n
  2634. /// If there is at least one pair of double-precision elements where the
  2635. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2636. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2637. /// This intrinsic returns the value of the ZF flag.
  2638. ///
  2639. /// \headerfile <x86intrin.h>
  2640. ///
  2641. /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
  2642. ///
  2643. /// \param __a
  2644. /// A 256-bit vector of [4 x double].
  2645. /// \param __b
  2646. /// A 256-bit vector of [4 x double].
  2647. /// \returns the ZF flag.
  2648. static __inline int __DEFAULT_FN_ATTRS
  2649. _mm256_testz_pd(__m256d __a, __m256d __b)
  2650. {
  2651. return __builtin_ia32_vtestzpd256((__v4df)__a, (__v4df)__b);
  2652. }
  2653. /// \brief Given two 256-bit floating-point vectors of [4 x double], perform an
  2654. /// element-by-element comparison of the double-precision elements in the
  2655. /// first source vector and the corresponding elements in the second source
  2656. /// vector.
  2657. ///
  2658. /// The EFLAGS register is updated as follows: \n
  2659. /// If there is at least one pair of double-precision elements where the
  2660. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2661. /// ZF flag is set to 1. \n
  2662. /// If there is at least one pair of double-precision elements where the
  2663. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2664. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2665. /// This intrinsic returns the value of the CF flag.
  2666. ///
  2667. /// \headerfile <x86intrin.h>
  2668. ///
  2669. /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
  2670. ///
  2671. /// \param __a
  2672. /// A 256-bit vector of [4 x double].
  2673. /// \param __b
  2674. /// A 256-bit vector of [4 x double].
  2675. /// \returns the CF flag.
  2676. static __inline int __DEFAULT_FN_ATTRS
  2677. _mm256_testc_pd(__m256d __a, __m256d __b)
  2678. {
  2679. return __builtin_ia32_vtestcpd256((__v4df)__a, (__v4df)__b);
  2680. }
  2681. /// \brief Given two 256-bit floating-point vectors of [4 x double], perform an
  2682. /// element-by-element comparison of the double-precision elements in the
  2683. /// first source vector and the corresponding elements in the second source
  2684. /// vector.
  2685. ///
  2686. /// The EFLAGS register is updated as follows: \n
  2687. /// If there is at least one pair of double-precision elements where the
  2688. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2689. /// ZF flag is set to 1. \n
  2690. /// If there is at least one pair of double-precision elements where the
  2691. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2692. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2693. /// This intrinsic returns 1 if both the ZF and CF flags are set to 0,
  2694. /// otherwise it returns 0.
  2695. ///
  2696. /// \headerfile <x86intrin.h>
  2697. ///
  2698. /// This intrinsic corresponds to the <c> VTESTPD </c> instruction.
  2699. ///
  2700. /// \param __a
  2701. /// A 256-bit vector of [4 x double].
  2702. /// \param __b
  2703. /// A 256-bit vector of [4 x double].
  2704. /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
  2705. static __inline int __DEFAULT_FN_ATTRS
  2706. _mm256_testnzc_pd(__m256d __a, __m256d __b)
  2707. {
  2708. return __builtin_ia32_vtestnzcpd256((__v4df)__a, (__v4df)__b);
  2709. }
  2710. /// \brief Given two 256-bit floating-point vectors of [8 x float], perform an
  2711. /// element-by-element comparison of the single-precision element in the
  2712. /// first source vector and the corresponding element in the second source
  2713. /// vector.
  2714. ///
  2715. /// The EFLAGS register is updated as follows: \n
  2716. /// If there is at least one pair of single-precision elements where the
  2717. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2718. /// ZF flag is set to 1. \n
  2719. /// If there is at least one pair of single-precision elements where the
  2720. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2721. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2722. /// This intrinsic returns the value of the ZF flag.
  2723. ///
  2724. /// \headerfile <x86intrin.h>
  2725. ///
  2726. /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
  2727. ///
  2728. /// \param __a
  2729. /// A 256-bit vector of [8 x float].
  2730. /// \param __b
  2731. /// A 256-bit vector of [8 x float].
  2732. /// \returns the ZF flag.
  2733. static __inline int __DEFAULT_FN_ATTRS
  2734. _mm256_testz_ps(__m256 __a, __m256 __b)
  2735. {
  2736. return __builtin_ia32_vtestzps256((__v8sf)__a, (__v8sf)__b);
  2737. }
  2738. /// \brief Given two 256-bit floating-point vectors of [8 x float], perform an
  2739. /// element-by-element comparison of the single-precision element in the
  2740. /// first source vector and the corresponding element in the second source
  2741. /// vector.
  2742. ///
  2743. /// The EFLAGS register is updated as follows: \n
  2744. /// If there is at least one pair of single-precision elements where the
  2745. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2746. /// ZF flag is set to 1. \n
  2747. /// If there is at least one pair of single-precision elements where the
  2748. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2749. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2750. /// This intrinsic returns the value of the CF flag.
  2751. ///
  2752. /// \headerfile <x86intrin.h>
  2753. ///
  2754. /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
  2755. ///
  2756. /// \param __a
  2757. /// A 256-bit vector of [8 x float].
  2758. /// \param __b
  2759. /// A 256-bit vector of [8 x float].
  2760. /// \returns the CF flag.
  2761. static __inline int __DEFAULT_FN_ATTRS
  2762. _mm256_testc_ps(__m256 __a, __m256 __b)
  2763. {
  2764. return __builtin_ia32_vtestcps256((__v8sf)__a, (__v8sf)__b);
  2765. }
  2766. /// \brief Given two 256-bit floating-point vectors of [8 x float], perform an
  2767. /// element-by-element comparison of the single-precision elements in the
  2768. /// first source vector and the corresponding elements in the second source
  2769. /// vector.
  2770. ///
  2771. /// The EFLAGS register is updated as follows: \n
  2772. /// If there is at least one pair of single-precision elements where the
  2773. /// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the
  2774. /// ZF flag is set to 1. \n
  2775. /// If there is at least one pair of single-precision elements where the
  2776. /// sign-bit of the first element is 0 and the sign-bit of the second element
  2777. /// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n
  2778. /// This intrinsic returns 1 if both the ZF and CF flags are set to 0,
  2779. /// otherwise it returns 0.
  2780. ///
  2781. /// \headerfile <x86intrin.h>
  2782. ///
  2783. /// This intrinsic corresponds to the <c> VTESTPS </c> instruction.
  2784. ///
  2785. /// \param __a
  2786. /// A 256-bit vector of [8 x float].
  2787. /// \param __b
  2788. /// A 256-bit vector of [8 x float].
  2789. /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
  2790. static __inline int __DEFAULT_FN_ATTRS
  2791. _mm256_testnzc_ps(__m256 __a, __m256 __b)
  2792. {
  2793. return __builtin_ia32_vtestnzcps256((__v8sf)__a, (__v8sf)__b);
  2794. }
  2795. /// \brief Given two 256-bit integer vectors, perform a bit-by-bit comparison
  2796. /// of the two source vectors.
  2797. ///
  2798. /// The EFLAGS register is updated as follows: \n
  2799. /// If there is at least one pair of bits where both bits are 1, the ZF flag
  2800. /// is set to 0. Otherwise the ZF flag is set to 1. \n
  2801. /// If there is at least one pair of bits where the bit from the first source
  2802. /// vector is 0 and the bit from the second source vector is 1, the CF flag
  2803. /// is set to 0. Otherwise the CF flag is set to 1. \n
  2804. /// This intrinsic returns the value of the ZF flag.
  2805. ///
  2806. /// \headerfile <x86intrin.h>
  2807. ///
  2808. /// This intrinsic corresponds to the <c> VPTEST </c> instruction.
  2809. ///
  2810. /// \param __a
  2811. /// A 256-bit integer vector.
  2812. /// \param __b
  2813. /// A 256-bit integer vector.
  2814. /// \returns the ZF flag.
  2815. static __inline int __DEFAULT_FN_ATTRS
  2816. _mm256_testz_si256(__m256i __a, __m256i __b)
  2817. {
  2818. return __builtin_ia32_ptestz256((__v4di)__a, (__v4di)__b);
  2819. }
  2820. /// \brief Given two 256-bit integer vectors, perform a bit-by-bit comparison
  2821. /// of the two source vectors.
  2822. ///
  2823. /// The EFLAGS register is updated as follows: \n
  2824. /// If there is at least one pair of bits where both bits are 1, the ZF flag
  2825. /// is set to 0. Otherwise the ZF flag is set to 1. \n
  2826. /// If there is at least one pair of bits where the bit from the first source
  2827. /// vector is 0 and the bit from the second source vector is 1, the CF flag
  2828. /// is set to 0. Otherwise the CF flag is set to 1. \n
  2829. /// This intrinsic returns the value of the CF flag.
  2830. ///
  2831. /// \headerfile <x86intrin.h>
  2832. ///
  2833. /// This intrinsic corresponds to the <c> VPTEST </c> instruction.
  2834. ///
  2835. /// \param __a
  2836. /// A 256-bit integer vector.
  2837. /// \param __b
  2838. /// A 256-bit integer vector.
  2839. /// \returns the CF flag.
  2840. static __inline int __DEFAULT_FN_ATTRS
  2841. _mm256_testc_si256(__m256i __a, __m256i __b)
  2842. {
  2843. return __builtin_ia32_ptestc256((__v4di)__a, (__v4di)__b);
  2844. }
  2845. /// \brief Given two 256-bit integer vectors, perform a bit-by-bit comparison
  2846. /// of the two source vectors.
  2847. ///
  2848. /// The EFLAGS register is updated as follows: \n
  2849. /// If there is at least one pair of bits where both bits are 1, the ZF flag
  2850. /// is set to 0. Otherwise the ZF flag is set to 1. \n
  2851. /// If there is at least one pair of bits where the bit from the first source
  2852. /// vector is 0 and the bit from the second source vector is 1, the CF flag
  2853. /// is set to 0. Otherwise the CF flag is set to 1. \n
  2854. /// This intrinsic returns 1 if both the ZF and CF flags are set to 0,
  2855. /// otherwise it returns 0.
  2856. ///
  2857. /// \headerfile <x86intrin.h>
  2858. ///
  2859. /// This intrinsic corresponds to the <c> VPTEST </c> instruction.
  2860. ///
  2861. /// \param __a
  2862. /// A 256-bit integer vector.
  2863. /// \param __b
  2864. /// A 256-bit integer vector.
  2865. /// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0.
  2866. static __inline int __DEFAULT_FN_ATTRS
  2867. _mm256_testnzc_si256(__m256i __a, __m256i __b)
  2868. {
  2869. return __builtin_ia32_ptestnzc256((__v4di)__a, (__v4di)__b);
  2870. }
  2871. /* Vector extract sign mask */
  2872. /// \brief Extracts the sign bits of double-precision floating point elements
  2873. /// in a 256-bit vector of [4 x double] and writes them to the lower order
  2874. /// bits of the return value.
  2875. ///
  2876. /// \headerfile <x86intrin.h>
  2877. ///
  2878. /// This intrinsic corresponds to the <c> VMOVMSKPD </c> instruction.
  2879. ///
  2880. /// \param __a
  2881. /// A 256-bit vector of [4 x double] containing the double-precision
  2882. /// floating point values with sign bits to be extracted.
  2883. /// \returns The sign bits from the operand, written to bits [3:0].
  2884. static __inline int __DEFAULT_FN_ATTRS
  2885. _mm256_movemask_pd(__m256d __a)
  2886. {
  2887. return __builtin_ia32_movmskpd256((__v4df)__a);
  2888. }
  2889. /// \brief Extracts the sign bits of double-precision floating point elements
  2890. /// in a 256-bit vector of [8 x float] and writes them to the lower order
  2891. /// bits of the return value.
  2892. ///
  2893. /// \headerfile <x86intrin.h>
  2894. ///
  2895. /// This intrinsic corresponds to the <c> VMOVMSKPS </c> instruction.
  2896. ///
  2897. /// \param __a
  2898. /// A 256-bit vector of [8 x float] containing the double-precision floating
  2899. /// point values with sign bits to be extracted.
  2900. /// \returns The sign bits from the operand, written to bits [7:0].
  2901. static __inline int __DEFAULT_FN_ATTRS
  2902. _mm256_movemask_ps(__m256 __a)
  2903. {
  2904. return __builtin_ia32_movmskps256((__v8sf)__a);
  2905. }
  2906. /* Vector __zero */
  2907. /// \brief Zeroes the contents of all XMM or YMM registers.
  2908. ///
  2909. /// \headerfile <x86intrin.h>
  2910. ///
  2911. /// This intrinsic corresponds to the <c> VZEROALL </c> instruction.
  2912. static __inline void __DEFAULT_FN_ATTRS
  2913. _mm256_zeroall(void)
  2914. {
  2915. __builtin_ia32_vzeroall();
  2916. }
  2917. /// \brief Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
  2918. ///
  2919. /// \headerfile <x86intrin.h>
  2920. ///
  2921. /// This intrinsic corresponds to the <c> VZEROUPPER </c> instruction.
  2922. static __inline void __DEFAULT_FN_ATTRS
  2923. _mm256_zeroupper(void)
  2924. {
  2925. __builtin_ia32_vzeroupper();
  2926. }
  2927. /* Vector load with broadcast */
  2928. /// \brief Loads a scalar single-precision floating point value from the
  2929. /// specified address pointed to by \a __a and broadcasts it to the elements
  2930. /// of a [4 x float] vector.
  2931. ///
  2932. /// \headerfile <x86intrin.h>
  2933. ///
  2934. /// This intrinsic corresponds to the <c> VBROADCASTSS </c> instruction.
  2935. ///
  2936. /// \param __a
  2937. /// The single-precision floating point value to be broadcast.
  2938. /// \returns A 128-bit vector of [4 x float] whose 32-bit elements are set
  2939. /// equal to the broadcast value.
  2940. static __inline __m128 __DEFAULT_FN_ATTRS
  2941. _mm_broadcast_ss(float const *__a)
  2942. {
  2943. float __f = *__a;
  2944. return (__m128)(__v4sf){ __f, __f, __f, __f };
  2945. }
  2946. /// \brief Loads a scalar double-precision floating point value from the
  2947. /// specified address pointed to by \a __a and broadcasts it to the elements
  2948. /// of a [4 x double] vector.
  2949. ///
  2950. /// \headerfile <x86intrin.h>
  2951. ///
  2952. /// This intrinsic corresponds to the <c> VBROADCASTSD </c> instruction.
  2953. ///
  2954. /// \param __a
  2955. /// The double-precision floating point value to be broadcast.
  2956. /// \returns A 256-bit vector of [4 x double] whose 64-bit elements are set
  2957. /// equal to the broadcast value.
  2958. static __inline __m256d __DEFAULT_FN_ATTRS
  2959. _mm256_broadcast_sd(double const *__a)
  2960. {
  2961. double __d = *__a;
  2962. return (__m256d)(__v4df){ __d, __d, __d, __d };
  2963. }
  2964. /// \brief Loads a scalar single-precision floating point value from the
  2965. /// specified address pointed to by \a __a and broadcasts it to the elements
  2966. /// of a [8 x float] vector.
  2967. ///
  2968. /// \headerfile <x86intrin.h>
  2969. ///
  2970. /// This intrinsic corresponds to the <c> VBROADCASTSS </c> instruction.
  2971. ///
  2972. /// \param __a
  2973. /// The single-precision floating point value to be broadcast.
  2974. /// \returns A 256-bit vector of [8 x float] whose 32-bit elements are set
  2975. /// equal to the broadcast value.
  2976. static __inline __m256 __DEFAULT_FN_ATTRS
  2977. _mm256_broadcast_ss(float const *__a)
  2978. {
  2979. float __f = *__a;
  2980. return (__m256)(__v8sf){ __f, __f, __f, __f, __f, __f, __f, __f };
  2981. }
  2982. /// \brief Loads the data from a 128-bit vector of [2 x double] from the
  2983. /// specified address pointed to by \a __a and broadcasts it to 128-bit
  2984. /// elements in a 256-bit vector of [4 x double].
  2985. ///
  2986. /// \headerfile <x86intrin.h>
  2987. ///
  2988. /// This intrinsic corresponds to the <c> VBROADCASTF128 </c> instruction.
  2989. ///
  2990. /// \param __a
  2991. /// The 128-bit vector of [2 x double] to be broadcast.
  2992. /// \returns A 256-bit vector of [4 x double] whose 128-bit elements are set
  2993. /// equal to the broadcast value.
  2994. static __inline __m256d __DEFAULT_FN_ATTRS
  2995. _mm256_broadcast_pd(__m128d const *__a)
  2996. {
  2997. return (__m256d)__builtin_ia32_vbroadcastf128_pd256((__v2df const *)__a);
  2998. }
  2999. /// \brief Loads the data from a 128-bit vector of [4 x float] from the
  3000. /// specified address pointed to by \a __a and broadcasts it to 128-bit
  3001. /// elements in a 256-bit vector of [8 x float].
  3002. ///
  3003. /// \headerfile <x86intrin.h>
  3004. ///
  3005. /// This intrinsic corresponds to the <c> VBROADCASTF128 </c> instruction.
  3006. ///
  3007. /// \param __a
  3008. /// The 128-bit vector of [4 x float] to be broadcast.
  3009. /// \returns A 256-bit vector of [8 x float] whose 128-bit elements are set
  3010. /// equal to the broadcast value.
  3011. static __inline __m256 __DEFAULT_FN_ATTRS
  3012. _mm256_broadcast_ps(__m128 const *__a)
  3013. {
  3014. return (__m256)__builtin_ia32_vbroadcastf128_ps256((__v4sf const *)__a);
  3015. }
  3016. /* SIMD load ops */
  3017. /// \brief Loads 4 double-precision floating point values from a 32-byte aligned
  3018. /// memory location pointed to by \a __p into a vector of [4 x double].
  3019. ///
  3020. /// \headerfile <x86intrin.h>
  3021. ///
  3022. /// This intrinsic corresponds to the <c> VMOVAPD </c> instruction.
  3023. ///
  3024. /// \param __p
  3025. /// A 32-byte aligned pointer to a memory location containing
  3026. /// double-precision floating point values.
  3027. /// \returns A 256-bit vector of [4 x double] containing the moved values.
  3028. static __inline __m256d __DEFAULT_FN_ATTRS
  3029. _mm256_load_pd(double const *__p)
  3030. {
  3031. return *(__m256d *)__p;
  3032. }
  3033. /// \brief Loads 8 single-precision floating point values from a 32-byte aligned
  3034. /// memory location pointed to by \a __p into a vector of [8 x float].
  3035. ///
  3036. /// \headerfile <x86intrin.h>
  3037. ///
  3038. /// This intrinsic corresponds to the <c> VMOVAPS </c> instruction.
  3039. ///
  3040. /// \param __p
  3041. /// A 32-byte aligned pointer to a memory location containing float values.
  3042. /// \returns A 256-bit vector of [8 x float] containing the moved values.
  3043. static __inline __m256 __DEFAULT_FN_ATTRS
  3044. _mm256_load_ps(float const *__p)
  3045. {
  3046. return *(__m256 *)__p;
  3047. }
  3048. /// \brief Loads 4 double-precision floating point values from an unaligned
  3049. /// memory location pointed to by \a __p into a vector of [4 x double].
  3050. ///
  3051. /// \headerfile <x86intrin.h>
  3052. ///
  3053. /// This intrinsic corresponds to the <c> VMOVUPD </c> instruction.
  3054. ///
  3055. /// \param __p
  3056. /// A pointer to a memory location containing double-precision floating
  3057. /// point values.
  3058. /// \returns A 256-bit vector of [4 x double] containing the moved values.
  3059. static __inline __m256d __DEFAULT_FN_ATTRS
  3060. _mm256_loadu_pd(double const *__p)
  3061. {
  3062. struct __loadu_pd {
  3063. __m256d __v;
  3064. } __attribute__((__packed__, __may_alias__));
  3065. return ((struct __loadu_pd*)__p)->__v;
  3066. }
  3067. /// \brief Loads 8 single-precision floating point values from an unaligned
  3068. /// memory location pointed to by \a __p into a vector of [8 x float].
  3069. ///
  3070. /// \headerfile <x86intrin.h>
  3071. ///
  3072. /// This intrinsic corresponds to the <c> VMOVUPS </c> instruction.
  3073. ///
  3074. /// \param __p
  3075. /// A pointer to a memory location containing single-precision floating
  3076. /// point values.
  3077. /// \returns A 256-bit vector of [8 x float] containing the moved values.
  3078. static __inline __m256 __DEFAULT_FN_ATTRS
  3079. _mm256_loadu_ps(float const *__p)
  3080. {
  3081. struct __loadu_ps {
  3082. __m256 __v;
  3083. } __attribute__((__packed__, __may_alias__));
  3084. return ((struct __loadu_ps*)__p)->__v;
  3085. }
  3086. /// \brief Loads 256 bits of integer data from a 32-byte aligned memory
  3087. /// location pointed to by \a __p into elements of a 256-bit integer vector.
  3088. ///
  3089. /// \headerfile <x86intrin.h>
  3090. ///
  3091. /// This intrinsic corresponds to the <c> VMOVDQA </c> instruction.
  3092. ///
  3093. /// \param __p
  3094. /// A 32-byte aligned pointer to a 256-bit integer vector containing integer
  3095. /// values.
  3096. /// \returns A 256-bit integer vector containing the moved values.
  3097. static __inline __m256i __DEFAULT_FN_ATTRS
  3098. _mm256_load_si256(__m256i const *__p)
  3099. {
  3100. return *__p;
  3101. }
  3102. /// \brief Loads 256 bits of integer data from an unaligned memory location
  3103. /// pointed to by \a __p into a 256-bit integer vector.
  3104. ///
  3105. /// \headerfile <x86intrin.h>
  3106. ///
  3107. /// This intrinsic corresponds to the <c> VMOVDQU </c> instruction.
  3108. ///
  3109. /// \param __p
  3110. /// A pointer to a 256-bit integer vector containing integer values.
  3111. /// \returns A 256-bit integer vector containing the moved values.
  3112. static __inline __m256i __DEFAULT_FN_ATTRS
  3113. _mm256_loadu_si256(__m256i const *__p)
  3114. {
  3115. struct __loadu_si256 {
  3116. __m256i __v;
  3117. } __attribute__((__packed__, __may_alias__));
  3118. return ((struct __loadu_si256*)__p)->__v;
  3119. }
  3120. /// \brief Loads 256 bits of integer data from an unaligned memory location
  3121. /// pointed to by \a __p into a 256-bit integer vector. This intrinsic may
  3122. /// perform better than \c _mm256_loadu_si256 when the data crosses a cache
  3123. /// line boundary.
  3124. ///
  3125. /// \headerfile <x86intrin.h>
  3126. ///
  3127. /// This intrinsic corresponds to the <c> VLDDQU </c> instruction.
  3128. ///
  3129. /// \param __p
  3130. /// A pointer to a 256-bit integer vector containing integer values.
  3131. /// \returns A 256-bit integer vector containing the moved values.
  3132. static __inline __m256i __DEFAULT_FN_ATTRS
  3133. _mm256_lddqu_si256(__m256i const *__p)
  3134. {
  3135. return (__m256i)__builtin_ia32_lddqu256((char const *)__p);
  3136. }
  3137. /* SIMD store ops */
  3138. /// \brief Stores double-precision floating point values from a 256-bit vector
  3139. /// of [4 x double] to a 32-byte aligned memory location pointed to by
  3140. /// \a __p.
  3141. ///
  3142. /// \headerfile <x86intrin.h>
  3143. ///
  3144. /// This intrinsic corresponds to the <c> VMOVAPD </c> instruction.
  3145. ///
  3146. /// \param __p
  3147. /// A 32-byte aligned pointer to a memory location that will receive the
  3148. /// double-precision floaing point values.
  3149. /// \param __a
  3150. /// A 256-bit vector of [4 x double] containing the values to be moved.
  3151. static __inline void __DEFAULT_FN_ATTRS
  3152. _mm256_store_pd(double *__p, __m256d __a)
  3153. {
  3154. *(__m256d *)__p = __a;
  3155. }
  3156. /// \brief Stores single-precision floating point values from a 256-bit vector
  3157. /// of [8 x float] to a 32-byte aligned memory location pointed to by \a __p.
  3158. ///
  3159. /// \headerfile <x86intrin.h>
  3160. ///
  3161. /// This intrinsic corresponds to the <c> VMOVAPS </c> instruction.
  3162. ///
  3163. /// \param __p
  3164. /// A 32-byte aligned pointer to a memory location that will receive the
  3165. /// float values.
  3166. /// \param __a
  3167. /// A 256-bit vector of [8 x float] containing the values to be moved.
  3168. static __inline void __DEFAULT_FN_ATTRS
  3169. _mm256_store_ps(float *__p, __m256 __a)
  3170. {
  3171. *(__m256 *)__p = __a;
  3172. }
  3173. /// \brief Stores double-precision floating point values from a 256-bit vector
  3174. /// of [4 x double] to an unaligned memory location pointed to by \a __p.
  3175. ///
  3176. /// \headerfile <x86intrin.h>
  3177. ///
  3178. /// This intrinsic corresponds to the <c> VMOVUPD </c> instruction.
  3179. ///
  3180. /// \param __p
  3181. /// A pointer to a memory location that will receive the double-precision
  3182. /// floating point values.
  3183. /// \param __a
  3184. /// A 256-bit vector of [4 x double] containing the values to be moved.
  3185. static __inline void __DEFAULT_FN_ATTRS
  3186. _mm256_storeu_pd(double *__p, __m256d __a)
  3187. {
  3188. struct __storeu_pd {
  3189. __m256d __v;
  3190. } __attribute__((__packed__, __may_alias__));
  3191. ((struct __storeu_pd*)__p)->__v = __a;
  3192. }
  3193. /// \brief Stores single-precision floating point values from a 256-bit vector
  3194. /// of [8 x float] to an unaligned memory location pointed to by \a __p.
  3195. ///
  3196. /// \headerfile <x86intrin.h>
  3197. ///
  3198. /// This intrinsic corresponds to the <c> VMOVUPS </c> instruction.
  3199. ///
  3200. /// \param __p
  3201. /// A pointer to a memory location that will receive the float values.
  3202. /// \param __a
  3203. /// A 256-bit vector of [8 x float] containing the values to be moved.
  3204. static __inline void __DEFAULT_FN_ATTRS
  3205. _mm256_storeu_ps(float *__p, __m256 __a)
  3206. {
  3207. struct __storeu_ps {
  3208. __m256 __v;
  3209. } __attribute__((__packed__, __may_alias__));
  3210. ((struct __storeu_ps*)__p)->__v = __a;
  3211. }
  3212. /// \brief Stores integer values from a 256-bit integer vector to a 32-byte
  3213. /// aligned memory location pointed to by \a __p.
  3214. ///
  3215. /// \headerfile <x86intrin.h>
  3216. ///
  3217. /// This intrinsic corresponds to the <c> VMOVDQA </c> instruction.
  3218. ///
  3219. /// \param __p
  3220. /// A 32-byte aligned pointer to a memory location that will receive the
  3221. /// integer values.
  3222. /// \param __a
  3223. /// A 256-bit integer vector containing the values to be moved.
  3224. static __inline void __DEFAULT_FN_ATTRS
  3225. _mm256_store_si256(__m256i *__p, __m256i __a)
  3226. {
  3227. *__p = __a;
  3228. }
  3229. /// \brief Stores integer values from a 256-bit integer vector to an unaligned
  3230. /// memory location pointed to by \a __p.
  3231. ///
  3232. /// \headerfile <x86intrin.h>
  3233. ///
  3234. /// This intrinsic corresponds to the <c> VMOVDQU </c> instruction.
  3235. ///
  3236. /// \param __p
  3237. /// A pointer to a memory location that will receive the integer values.
  3238. /// \param __a
  3239. /// A 256-bit integer vector containing the values to be moved.
  3240. static __inline void __DEFAULT_FN_ATTRS
  3241. _mm256_storeu_si256(__m256i *__p, __m256i __a)
  3242. {
  3243. struct __storeu_si256 {
  3244. __m256i __v;
  3245. } __attribute__((__packed__, __may_alias__));
  3246. ((struct __storeu_si256*)__p)->__v = __a;
  3247. }
  3248. /* Conditional load ops */
  3249. /// \brief Conditionally loads double-precision floating point elements from a
  3250. /// memory location pointed to by \a __p into a 128-bit vector of
  3251. /// [2 x double], depending on the mask bits associated with each data
  3252. /// element.
  3253. ///
  3254. /// \headerfile <x86intrin.h>
  3255. ///
  3256. /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
  3257. ///
  3258. /// \param __p
  3259. /// A pointer to a memory location that contains the double-precision
  3260. /// floating point values.
  3261. /// \param __m
  3262. /// A 128-bit integer vector containing the mask. The most significant bit of
  3263. /// each data element represents the mask bits. If a mask bit is zero, the
  3264. /// corresponding value in the memory location is not loaded and the
  3265. /// corresponding field in the return value is set to zero.
  3266. /// \returns A 128-bit vector of [2 x double] containing the loaded values.
  3267. static __inline __m128d __DEFAULT_FN_ATTRS
  3268. _mm_maskload_pd(double const *__p, __m128i __m)
  3269. {
  3270. return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2di)__m);
  3271. }
  3272. /// \brief Conditionally loads double-precision floating point elements from a
  3273. /// memory location pointed to by \a __p into a 256-bit vector of
  3274. /// [4 x double], depending on the mask bits associated with each data
  3275. /// element.
  3276. ///
  3277. /// \headerfile <x86intrin.h>
  3278. ///
  3279. /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
  3280. ///
  3281. /// \param __p
  3282. /// A pointer to a memory location that contains the double-precision
  3283. /// floating point values.
  3284. /// \param __m
  3285. /// A 256-bit integer vector of [4 x quadword] containing the mask. The most
  3286. /// significant bit of each quadword element represents the mask bits. If a
  3287. /// mask bit is zero, the corresponding value in the memory location is not
  3288. /// loaded and the corresponding field in the return value is set to zero.
  3289. /// \returns A 256-bit vector of [4 x double] containing the loaded values.
  3290. static __inline __m256d __DEFAULT_FN_ATTRS
  3291. _mm256_maskload_pd(double const *__p, __m256i __m)
  3292. {
  3293. return (__m256d)__builtin_ia32_maskloadpd256((const __v4df *)__p,
  3294. (__v4di)__m);
  3295. }
  3296. /// \brief Conditionally loads single-precision floating point elements from a
  3297. /// memory location pointed to by \a __p into a 128-bit vector of
  3298. /// [4 x float], depending on the mask bits associated with each data
  3299. /// element.
  3300. ///
  3301. /// \headerfile <x86intrin.h>
  3302. ///
  3303. /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
  3304. ///
  3305. /// \param __p
  3306. /// A pointer to a memory location that contains the single-precision
  3307. /// floating point values.
  3308. /// \param __m
  3309. /// A 128-bit integer vector containing the mask. The most significant bit of
  3310. /// each data element represents the mask bits. If a mask bit is zero, the
  3311. /// corresponding value in the memory location is not loaded and the
  3312. /// corresponding field in the return value is set to zero.
  3313. /// \returns A 128-bit vector of [4 x float] containing the loaded values.
  3314. static __inline __m128 __DEFAULT_FN_ATTRS
  3315. _mm_maskload_ps(float const *__p, __m128i __m)
  3316. {
  3317. return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4si)__m);
  3318. }
  3319. /// \brief Conditionally loads single-precision floating point elements from a
  3320. /// memory location pointed to by \a __p into a 256-bit vector of
  3321. /// [8 x float], depending on the mask bits associated with each data
  3322. /// element.
  3323. ///
  3324. /// \headerfile <x86intrin.h>
  3325. ///
  3326. /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
  3327. ///
  3328. /// \param __p
  3329. /// A pointer to a memory location that contains the single-precision
  3330. /// floating point values.
  3331. /// \param __m
  3332. /// A 256-bit integer vector of [8 x dword] containing the mask. The most
  3333. /// significant bit of each dword element represents the mask bits. If a mask
  3334. /// bit is zero, the corresponding value in the memory location is not loaded
  3335. /// and the corresponding field in the return value is set to zero.
  3336. /// \returns A 256-bit vector of [8 x float] containing the loaded values.
  3337. static __inline __m256 __DEFAULT_FN_ATTRS
  3338. _mm256_maskload_ps(float const *__p, __m256i __m)
  3339. {
  3340. return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8si)__m);
  3341. }
  3342. /* Conditional store ops */
  3343. /// \brief Moves single-precision floating point values from a 256-bit vector
  3344. /// of [8 x float] to a memory location pointed to by \a __p, according to
  3345. /// the specified mask.
  3346. ///
  3347. /// \headerfile <x86intrin.h>
  3348. ///
  3349. /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
  3350. ///
  3351. /// \param __p
  3352. /// A pointer to a memory location that will receive the float values.
  3353. /// \param __m
  3354. /// A 256-bit integer vector of [8 x dword] containing the mask. The most
  3355. /// significant bit of each dword element in the mask vector represents the
  3356. /// mask bits. If a mask bit is zero, the corresponding value from vector
  3357. /// \a __a is not stored and the corresponding field in the memory location
  3358. /// pointed to by \a __p is not changed.
  3359. /// \param __a
  3360. /// A 256-bit vector of [8 x float] containing the values to be stored.
  3361. static __inline void __DEFAULT_FN_ATTRS
  3362. _mm256_maskstore_ps(float *__p, __m256i __m, __m256 __a)
  3363. {
  3364. __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8si)__m, (__v8sf)__a);
  3365. }
  3366. /// \brief Moves double-precision values from a 128-bit vector of [2 x double]
  3367. /// to a memory location pointed to by \a __p, according to the specified
  3368. /// mask.
  3369. ///
  3370. /// \headerfile <x86intrin.h>
  3371. ///
  3372. /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
  3373. ///
  3374. /// \param __p
  3375. /// A pointer to a memory location that will receive the float values.
  3376. /// \param __m
  3377. /// A 128-bit integer vector containing the mask. The most significant bit of
  3378. /// each field in the mask vector represents the mask bits. If a mask bit is
  3379. /// zero, the corresponding value from vector \a __a is not stored and the
  3380. /// corresponding field in the memory location pointed to by \a __p is not
  3381. /// changed.
  3382. /// \param __a
  3383. /// A 128-bit vector of [2 x double] containing the values to be stored.
  3384. static __inline void __DEFAULT_FN_ATTRS
  3385. _mm_maskstore_pd(double *__p, __m128i __m, __m128d __a)
  3386. {
  3387. __builtin_ia32_maskstorepd((__v2df *)__p, (__v2di)__m, (__v2df)__a);
  3388. }
  3389. /// \brief Moves double-precision values from a 256-bit vector of [4 x double]
  3390. /// to a memory location pointed to by \a __p, according to the specified
  3391. /// mask.
  3392. ///
  3393. /// \headerfile <x86intrin.h>
  3394. ///
  3395. /// This intrinsic corresponds to the <c> VMASKMOVPD </c> instruction.
  3396. ///
  3397. /// \param __p
  3398. /// A pointer to a memory location that will receive the float values.
  3399. /// \param __m
  3400. /// A 256-bit integer vector of [4 x quadword] containing the mask. The most
  3401. /// significant bit of each quadword element in the mask vector represents
  3402. /// the mask bits. If a mask bit is zero, the corresponding value from vector
  3403. /// __a is not stored and the corresponding field in the memory location
  3404. /// pointed to by \a __p is not changed.
  3405. /// \param __a
  3406. /// A 256-bit vector of [4 x double] containing the values to be stored.
  3407. static __inline void __DEFAULT_FN_ATTRS
  3408. _mm256_maskstore_pd(double *__p, __m256i __m, __m256d __a)
  3409. {
  3410. __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4di)__m, (__v4df)__a);
  3411. }
  3412. /// \brief Moves single-precision floating point values from a 128-bit vector
  3413. /// of [4 x float] to a memory location pointed to by \a __p, according to
  3414. /// the specified mask.
  3415. ///
  3416. /// \headerfile <x86intrin.h>
  3417. ///
  3418. /// This intrinsic corresponds to the <c> VMASKMOVPS </c> instruction.
  3419. ///
  3420. /// \param __p
  3421. /// A pointer to a memory location that will receive the float values.
  3422. /// \param __m
  3423. /// A 128-bit integer vector containing the mask. The most significant bit of
  3424. /// each field in the mask vector represents the mask bits. If a mask bit is
  3425. /// zero, the corresponding value from vector __a is not stored and the
  3426. /// corresponding field in the memory location pointed to by \a __p is not
  3427. /// changed.
  3428. /// \param __a
  3429. /// A 128-bit vector of [4 x float] containing the values to be stored.
  3430. static __inline void __DEFAULT_FN_ATTRS
  3431. _mm_maskstore_ps(float *__p, __m128i __m, __m128 __a)
  3432. {
  3433. __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4si)__m, (__v4sf)__a);
  3434. }
  3435. /* Cacheability support ops */
  3436. /// \brief Moves integer data from a 256-bit integer vector to a 32-byte
  3437. /// aligned memory location. To minimize caching, the data is flagged as
  3438. /// non-temporal (unlikely to be used again soon).
  3439. ///
  3440. /// \headerfile <x86intrin.h>
  3441. ///
  3442. /// This intrinsic corresponds to the <c> VMOVNTDQ </c> instruction.
  3443. ///
  3444. /// \param __a
  3445. /// A pointer to a 32-byte aligned memory location that will receive the
  3446. /// integer values.
  3447. /// \param __b
  3448. /// A 256-bit integer vector containing the values to be moved.
  3449. static __inline void __DEFAULT_FN_ATTRS
  3450. _mm256_stream_si256(__m256i *__a, __m256i __b)
  3451. {
  3452. typedef __v4di __v4di_aligned __attribute__((aligned(32)));
  3453. __builtin_nontemporal_store((__v4di_aligned)__b, (__v4di_aligned*)__a);
  3454. }
  3455. /// \brief Moves double-precision values from a 256-bit vector of [4 x double]
  3456. /// to a 32-byte aligned memory location. To minimize caching, the data is
  3457. /// flagged as non-temporal (unlikely to be used again soon).
  3458. ///
  3459. /// \headerfile <x86intrin.h>
  3460. ///
  3461. /// This intrinsic corresponds to the <c> VMOVNTPD </c> instruction.
  3462. ///
  3463. /// \param __a
  3464. /// A pointer to a 32-byte aligned memory location that will receive the
  3465. /// double-precision floating-point values.
  3466. /// \param __b
  3467. /// A 256-bit vector of [4 x double] containing the values to be moved.
  3468. static __inline void __DEFAULT_FN_ATTRS
  3469. _mm256_stream_pd(double *__a, __m256d __b)
  3470. {
  3471. typedef __v4df __v4df_aligned __attribute__((aligned(32)));
  3472. __builtin_nontemporal_store((__v4df_aligned)__b, (__v4df_aligned*)__a);
  3473. }
  3474. /// \brief Moves single-precision floating point values from a 256-bit vector
  3475. /// of [8 x float] to a 32-byte aligned memory location. To minimize
  3476. /// caching, the data is flagged as non-temporal (unlikely to be used again
  3477. /// soon).
  3478. ///
  3479. /// \headerfile <x86intrin.h>
  3480. ///
  3481. /// This intrinsic corresponds to the <c> VMOVNTPS </c> instruction.
  3482. ///
  3483. /// \param __p
  3484. /// A pointer to a 32-byte aligned memory location that will receive the
  3485. /// single-precision floating point values.
  3486. /// \param __a
  3487. /// A 256-bit vector of [8 x float] containing the values to be moved.
  3488. static __inline void __DEFAULT_FN_ATTRS
  3489. _mm256_stream_ps(float *__p, __m256 __a)
  3490. {
  3491. typedef __v8sf __v8sf_aligned __attribute__((aligned(32)));
  3492. __builtin_nontemporal_store((__v8sf_aligned)__a, (__v8sf_aligned*)__p);
  3493. }
  3494. /* Create vectors */
  3495. /// \brief Create a 256-bit vector of [4 x double] with undefined values.
  3496. ///
  3497. /// \headerfile <x86intrin.h>
  3498. ///
  3499. /// This intrinsic has no corresponding instruction.
  3500. ///
  3501. /// \returns A 256-bit vector of [4 x double] containing undefined values.
  3502. static __inline__ __m256d __DEFAULT_FN_ATTRS
  3503. _mm256_undefined_pd(void)
  3504. {
  3505. return (__m256d)__builtin_ia32_undef256();
  3506. }
  3507. /// \brief Create a 256-bit vector of [8 x float] with undefined values.
  3508. ///
  3509. /// \headerfile <x86intrin.h>
  3510. ///
  3511. /// This intrinsic has no corresponding instruction.
  3512. ///
  3513. /// \returns A 256-bit vector of [8 x float] containing undefined values.
  3514. static __inline__ __m256 __DEFAULT_FN_ATTRS
  3515. _mm256_undefined_ps(void)
  3516. {
  3517. return (__m256)__builtin_ia32_undef256();
  3518. }
  3519. /// \brief Create a 256-bit integer vector with undefined values.
  3520. ///
  3521. /// \headerfile <x86intrin.h>
  3522. ///
  3523. /// This intrinsic has no corresponding instruction.
  3524. ///
  3525. /// \returns A 256-bit integer vector containing undefined values.
  3526. static __inline__ __m256i __DEFAULT_FN_ATTRS
  3527. _mm256_undefined_si256(void)
  3528. {
  3529. return (__m256i)__builtin_ia32_undef256();
  3530. }
  3531. /// \brief Constructs a 256-bit floating-point vector of [4 x double]
  3532. /// initialized with the specified double-precision floating-point values.
  3533. ///
  3534. /// \headerfile <x86intrin.h>
  3535. ///
  3536. /// This intrinsic corresponds to the <c> VUNPCKLPD+VINSERTF128 </c>
  3537. /// instruction.
  3538. ///
  3539. /// \param __a
  3540. /// A double-precision floating-point value used to initialize bits [255:192]
  3541. /// of the result.
  3542. /// \param __b
  3543. /// A double-precision floating-point value used to initialize bits [191:128]
  3544. /// of the result.
  3545. /// \param __c
  3546. /// A double-precision floating-point value used to initialize bits [127:64]
  3547. /// of the result.
  3548. /// \param __d
  3549. /// A double-precision floating-point value used to initialize bits [63:0]
  3550. /// of the result.
  3551. /// \returns An initialized 256-bit floating-point vector of [4 x double].
  3552. static __inline __m256d __DEFAULT_FN_ATTRS
  3553. _mm256_set_pd(double __a, double __b, double __c, double __d)
  3554. {
  3555. return (__m256d){ __d, __c, __b, __a };
  3556. }
  3557. /// \brief Constructs a 256-bit floating-point vector of [8 x float] initialized
  3558. /// with the specified single-precision floating-point values.
  3559. ///
  3560. /// \headerfile <x86intrin.h>
  3561. ///
  3562. /// This intrinsic is a utility function and does not correspond to a specific
  3563. /// instruction.
  3564. ///
  3565. /// \param __a
  3566. /// A single-precision floating-point value used to initialize bits [255:224]
  3567. /// of the result.
  3568. /// \param __b
  3569. /// A single-precision floating-point value used to initialize bits [223:192]
  3570. /// of the result.
  3571. /// \param __c
  3572. /// A single-precision floating-point value used to initialize bits [191:160]
  3573. /// of the result.
  3574. /// \param __d
  3575. /// A single-precision floating-point value used to initialize bits [159:128]
  3576. /// of the result.
  3577. /// \param __e
  3578. /// A single-precision floating-point value used to initialize bits [127:96]
  3579. /// of the result.
  3580. /// \param __f
  3581. /// A single-precision floating-point value used to initialize bits [95:64]
  3582. /// of the result.
  3583. /// \param __g
  3584. /// A single-precision floating-point value used to initialize bits [63:32]
  3585. /// of the result.
  3586. /// \param __h
  3587. /// A single-precision floating-point value used to initialize bits [31:0]
  3588. /// of the result.
  3589. /// \returns An initialized 256-bit floating-point vector of [8 x float].
  3590. static __inline __m256 __DEFAULT_FN_ATTRS
  3591. _mm256_set_ps(float __a, float __b, float __c, float __d,
  3592. float __e, float __f, float __g, float __h)
  3593. {
  3594. return (__m256){ __h, __g, __f, __e, __d, __c, __b, __a };
  3595. }
  3596. /// \brief Constructs a 256-bit integer vector initialized with the specified
  3597. /// 32-bit integral values.
  3598. ///
  3599. /// \headerfile <x86intrin.h>
  3600. ///
  3601. /// This intrinsic is a utility function and does not correspond to a specific
  3602. /// instruction.
  3603. ///
  3604. /// \param __i0
  3605. /// A 32-bit integral value used to initialize bits [255:224] of the result.
  3606. /// \param __i1
  3607. /// A 32-bit integral value used to initialize bits [223:192] of the result.
  3608. /// \param __i2
  3609. /// A 32-bit integral value used to initialize bits [191:160] of the result.
  3610. /// \param __i3
  3611. /// A 32-bit integral value used to initialize bits [159:128] of the result.
  3612. /// \param __i4
  3613. /// A 32-bit integral value used to initialize bits [127:96] of the result.
  3614. /// \param __i5
  3615. /// A 32-bit integral value used to initialize bits [95:64] of the result.
  3616. /// \param __i6
  3617. /// A 32-bit integral value used to initialize bits [63:32] of the result.
  3618. /// \param __i7
  3619. /// A 32-bit integral value used to initialize bits [31:0] of the result.
  3620. /// \returns An initialized 256-bit integer vector.
  3621. static __inline __m256i __DEFAULT_FN_ATTRS
  3622. _mm256_set_epi32(int __i0, int __i1, int __i2, int __i3,
  3623. int __i4, int __i5, int __i6, int __i7)
  3624. {
  3625. return (__m256i)(__v8si){ __i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0 };
  3626. }
  3627. /// \brief Constructs a 256-bit integer vector initialized with the specified
  3628. /// 16-bit integral values.
  3629. ///
  3630. /// \headerfile <x86intrin.h>
  3631. ///
  3632. /// This intrinsic is a utility function and does not correspond to a specific
  3633. /// instruction.
  3634. ///
  3635. /// \param __w15
  3636. /// A 16-bit integral value used to initialize bits [255:240] of the result.
  3637. /// \param __w14
  3638. /// A 16-bit integral value used to initialize bits [239:224] of the result.
  3639. /// \param __w13
  3640. /// A 16-bit integral value used to initialize bits [223:208] of the result.
  3641. /// \param __w12
  3642. /// A 16-bit integral value used to initialize bits [207:192] of the result.
  3643. /// \param __w11
  3644. /// A 16-bit integral value used to initialize bits [191:176] of the result.
  3645. /// \param __w10
  3646. /// A 16-bit integral value used to initialize bits [175:160] of the result.
  3647. /// \param __w09
  3648. /// A 16-bit integral value used to initialize bits [159:144] of the result.
  3649. /// \param __w08
  3650. /// A 16-bit integral value used to initialize bits [143:128] of the result.
  3651. /// \param __w07
  3652. /// A 16-bit integral value used to initialize bits [127:112] of the result.
  3653. /// \param __w06
  3654. /// A 16-bit integral value used to initialize bits [111:96] of the result.
  3655. /// \param __w05
  3656. /// A 16-bit integral value used to initialize bits [95:80] of the result.
  3657. /// \param __w04
  3658. /// A 16-bit integral value used to initialize bits [79:64] of the result.
  3659. /// \param __w03
  3660. /// A 16-bit integral value used to initialize bits [63:48] of the result.
  3661. /// \param __w02
  3662. /// A 16-bit integral value used to initialize bits [47:32] of the result.
  3663. /// \param __w01
  3664. /// A 16-bit integral value used to initialize bits [31:16] of the result.
  3665. /// \param __w00
  3666. /// A 16-bit integral value used to initialize bits [15:0] of the result.
  3667. /// \returns An initialized 256-bit integer vector.
  3668. static __inline __m256i __DEFAULT_FN_ATTRS
  3669. _mm256_set_epi16(short __w15, short __w14, short __w13, short __w12,
  3670. short __w11, short __w10, short __w09, short __w08,
  3671. short __w07, short __w06, short __w05, short __w04,
  3672. short __w03, short __w02, short __w01, short __w00)
  3673. {
  3674. return (__m256i)(__v16hi){ __w00, __w01, __w02, __w03, __w04, __w05, __w06,
  3675. __w07, __w08, __w09, __w10, __w11, __w12, __w13, __w14, __w15 };
  3676. }
  3677. /// \brief Constructs a 256-bit integer vector initialized with the specified
  3678. /// 8-bit integral values.
  3679. ///
  3680. /// \headerfile <x86intrin.h>
  3681. ///
  3682. /// This intrinsic is a utility function and does not correspond to a specific
  3683. /// instruction.
  3684. ///
  3685. /// \param __b31
  3686. /// An 8-bit integral value used to initialize bits [255:248] of the result.
  3687. /// \param __b30
  3688. /// An 8-bit integral value used to initialize bits [247:240] of the result.
  3689. /// \param __b29
  3690. /// An 8-bit integral value used to initialize bits [239:232] of the result.
  3691. /// \param __b28
  3692. /// An 8-bit integral value used to initialize bits [231:224] of the result.
  3693. /// \param __b27
  3694. /// An 8-bit integral value used to initialize bits [223:216] of the result.
  3695. /// \param __b26
  3696. /// An 8-bit integral value used to initialize bits [215:208] of the result.
  3697. /// \param __b25
  3698. /// An 8-bit integral value used to initialize bits [207:200] of the result.
  3699. /// \param __b24
  3700. /// An 8-bit integral value used to initialize bits [199:192] of the result.
  3701. /// \param __b23
  3702. /// An 8-bit integral value used to initialize bits [191:184] of the result.
  3703. /// \param __b22
  3704. /// An 8-bit integral value used to initialize bits [183:176] of the result.
  3705. /// \param __b21
  3706. /// An 8-bit integral value used to initialize bits [175:168] of the result.
  3707. /// \param __b20
  3708. /// An 8-bit integral value used to initialize bits [167:160] of the result.
  3709. /// \param __b19
  3710. /// An 8-bit integral value used to initialize bits [159:152] of the result.
  3711. /// \param __b18
  3712. /// An 8-bit integral value used to initialize bits [151:144] of the result.
  3713. /// \param __b17
  3714. /// An 8-bit integral value used to initialize bits [143:136] of the result.
  3715. /// \param __b16
  3716. /// An 8-bit integral value used to initialize bits [135:128] of the result.
  3717. /// \param __b15
  3718. /// An 8-bit integral value used to initialize bits [127:120] of the result.
  3719. /// \param __b14
  3720. /// An 8-bit integral value used to initialize bits [119:112] of the result.
  3721. /// \param __b13
  3722. /// An 8-bit integral value used to initialize bits [111:104] of the result.
  3723. /// \param __b12
  3724. /// An 8-bit integral value used to initialize bits [103:96] of the result.
  3725. /// \param __b11
  3726. /// An 8-bit integral value used to initialize bits [95:88] of the result.
  3727. /// \param __b10
  3728. /// An 8-bit integral value used to initialize bits [87:80] of the result.
  3729. /// \param __b09
  3730. /// An 8-bit integral value used to initialize bits [79:72] of the result.
  3731. /// \param __b08
  3732. /// An 8-bit integral value used to initialize bits [71:64] of the result.
  3733. /// \param __b07
  3734. /// An 8-bit integral value used to initialize bits [63:56] of the result.
  3735. /// \param __b06
  3736. /// An 8-bit integral value used to initialize bits [55:48] of the result.
  3737. /// \param __b05
  3738. /// An 8-bit integral value used to initialize bits [47:40] of the result.
  3739. /// \param __b04
  3740. /// An 8-bit integral value used to initialize bits [39:32] of the result.
  3741. /// \param __b03
  3742. /// An 8-bit integral value used to initialize bits [31:24] of the result.
  3743. /// \param __b02
  3744. /// An 8-bit integral value used to initialize bits [23:16] of the result.
  3745. /// \param __b01
  3746. /// An 8-bit integral value used to initialize bits [15:8] of the result.
  3747. /// \param __b00
  3748. /// An 8-bit integral value used to initialize bits [7:0] of the result.
  3749. /// \returns An initialized 256-bit integer vector.
  3750. static __inline __m256i __DEFAULT_FN_ATTRS
  3751. _mm256_set_epi8(char __b31, char __b30, char __b29, char __b28,
  3752. char __b27, char __b26, char __b25, char __b24,
  3753. char __b23, char __b22, char __b21, char __b20,
  3754. char __b19, char __b18, char __b17, char __b16,
  3755. char __b15, char __b14, char __b13, char __b12,
  3756. char __b11, char __b10, char __b09, char __b08,
  3757. char __b07, char __b06, char __b05, char __b04,
  3758. char __b03, char __b02, char __b01, char __b00)
  3759. {
  3760. return (__m256i)(__v32qi){
  3761. __b00, __b01, __b02, __b03, __b04, __b05, __b06, __b07,
  3762. __b08, __b09, __b10, __b11, __b12, __b13, __b14, __b15,
  3763. __b16, __b17, __b18, __b19, __b20, __b21, __b22, __b23,
  3764. __b24, __b25, __b26, __b27, __b28, __b29, __b30, __b31
  3765. };
  3766. }
  3767. /// \brief Constructs a 256-bit integer vector initialized with the specified
  3768. /// 64-bit integral values.
  3769. ///
  3770. /// \headerfile <x86intrin.h>
  3771. ///
  3772. /// This intrinsic corresponds to the <c> VPUNPCKLQDQ+VINSERTF128 </c>
  3773. /// instruction.
  3774. ///
  3775. /// \param __a
  3776. /// A 64-bit integral value used to initialize bits [255:192] of the result.
  3777. /// \param __b
  3778. /// A 64-bit integral value used to initialize bits [191:128] of the result.
  3779. /// \param __c
  3780. /// A 64-bit integral value used to initialize bits [127:64] of the result.
  3781. /// \param __d
  3782. /// A 64-bit integral value used to initialize bits [63:0] of the result.
  3783. /// \returns An initialized 256-bit integer vector.
  3784. static __inline __m256i __DEFAULT_FN_ATTRS
  3785. _mm256_set_epi64x(long long __a, long long __b, long long __c, long long __d)
  3786. {
  3787. return (__m256i)(__v4di){ __d, __c, __b, __a };
  3788. }
  3789. /* Create vectors with elements in reverse order */
  3790. /// \brief Constructs a 256-bit floating-point vector of [4 x double],
  3791. /// initialized in reverse order with the specified double-precision
  3792. /// floating-point values.
  3793. ///
  3794. /// \headerfile <x86intrin.h>
  3795. ///
  3796. /// This intrinsic corresponds to the <c> VUNPCKLPD+VINSERTF128 </c>
  3797. /// instruction.
  3798. ///
  3799. /// \param __a
  3800. /// A double-precision floating-point value used to initialize bits [63:0]
  3801. /// of the result.
  3802. /// \param __b
  3803. /// A double-precision floating-point value used to initialize bits [127:64]
  3804. /// of the result.
  3805. /// \param __c
  3806. /// A double-precision floating-point value used to initialize bits [191:128]
  3807. /// of the result.
  3808. /// \param __d
  3809. /// A double-precision floating-point value used to initialize bits [255:192]
  3810. /// of the result.
  3811. /// \returns An initialized 256-bit floating-point vector of [4 x double].
  3812. static __inline __m256d __DEFAULT_FN_ATTRS
  3813. _mm256_setr_pd(double __a, double __b, double __c, double __d)
  3814. {
  3815. return (__m256d){ __a, __b, __c, __d };
  3816. }
  3817. /// \brief Constructs a 256-bit floating-point vector of [8 x float],
  3818. /// initialized in reverse order with the specified single-precision
  3819. /// float-point values.
  3820. ///
  3821. /// \headerfile <x86intrin.h>
  3822. ///
  3823. /// This intrinsic is a utility function and does not correspond to a specific
  3824. /// instruction.
  3825. ///
  3826. /// \param __a
  3827. /// A single-precision floating-point value used to initialize bits [31:0]
  3828. /// of the result.
  3829. /// \param __b
  3830. /// A single-precision floating-point value used to initialize bits [63:32]
  3831. /// of the result.
  3832. /// \param __c
  3833. /// A single-precision floating-point value used to initialize bits [95:64]
  3834. /// of the result.
  3835. /// \param __d
  3836. /// A single-precision floating-point value used to initialize bits [127:96]
  3837. /// of the result.
  3838. /// \param __e
  3839. /// A single-precision floating-point value used to initialize bits [159:128]
  3840. /// of the result.
  3841. /// \param __f
  3842. /// A single-precision floating-point value used to initialize bits [191:160]
  3843. /// of the result.
  3844. /// \param __g
  3845. /// A single-precision floating-point value used to initialize bits [223:192]
  3846. /// of the result.
  3847. /// \param __h
  3848. /// A single-precision floating-point value used to initialize bits [255:224]
  3849. /// of the result.
  3850. /// \returns An initialized 256-bit floating-point vector of [8 x float].
  3851. static __inline __m256 __DEFAULT_FN_ATTRS
  3852. _mm256_setr_ps(float __a, float __b, float __c, float __d,
  3853. float __e, float __f, float __g, float __h)
  3854. {
  3855. return (__m256){ __a, __b, __c, __d, __e, __f, __g, __h };
  3856. }
  3857. /// \brief Constructs a 256-bit integer vector, initialized in reverse order
  3858. /// with the specified 32-bit integral values.
  3859. ///
  3860. /// \headerfile <x86intrin.h>
  3861. ///
  3862. /// This intrinsic is a utility function and does not correspond to a specific
  3863. /// instruction.
  3864. ///
  3865. /// \param __i0
  3866. /// A 32-bit integral value used to initialize bits [31:0] of the result.
  3867. /// \param __i1
  3868. /// A 32-bit integral value used to initialize bits [63:32] of the result.
  3869. /// \param __i2
  3870. /// A 32-bit integral value used to initialize bits [95:64] of the result.
  3871. /// \param __i3
  3872. /// A 32-bit integral value used to initialize bits [127:96] of the result.
  3873. /// \param __i4
  3874. /// A 32-bit integral value used to initialize bits [159:128] of the result.
  3875. /// \param __i5
  3876. /// A 32-bit integral value used to initialize bits [191:160] of the result.
  3877. /// \param __i6
  3878. /// A 32-bit integral value used to initialize bits [223:192] of the result.
  3879. /// \param __i7
  3880. /// A 32-bit integral value used to initialize bits [255:224] of the result.
  3881. /// \returns An initialized 256-bit integer vector.
  3882. static __inline __m256i __DEFAULT_FN_ATTRS
  3883. _mm256_setr_epi32(int __i0, int __i1, int __i2, int __i3,
  3884. int __i4, int __i5, int __i6, int __i7)
  3885. {
  3886. return (__m256i)(__v8si){ __i0, __i1, __i2, __i3, __i4, __i5, __i6, __i7 };
  3887. }
  3888. /// \brief Constructs a 256-bit integer vector, initialized in reverse order
  3889. /// with the specified 16-bit integral values.
  3890. ///
  3891. /// \headerfile <x86intrin.h>
  3892. ///
  3893. /// This intrinsic is a utility function and does not correspond to a specific
  3894. /// instruction.
  3895. ///
  3896. /// \param __w15
  3897. /// A 16-bit integral value used to initialize bits [15:0] of the result.
  3898. /// \param __w14
  3899. /// A 16-bit integral value used to initialize bits [31:16] of the result.
  3900. /// \param __w13
  3901. /// A 16-bit integral value used to initialize bits [47:32] of the result.
  3902. /// \param __w12
  3903. /// A 16-bit integral value used to initialize bits [63:48] of the result.
  3904. /// \param __w11
  3905. /// A 16-bit integral value used to initialize bits [79:64] of the result.
  3906. /// \param __w10
  3907. /// A 16-bit integral value used to initialize bits [95:80] of the result.
  3908. /// \param __w09
  3909. /// A 16-bit integral value used to initialize bits [111:96] of the result.
  3910. /// \param __w08
  3911. /// A 16-bit integral value used to initialize bits [127:112] of the result.
  3912. /// \param __w07
  3913. /// A 16-bit integral value used to initialize bits [143:128] of the result.
  3914. /// \param __w06
  3915. /// A 16-bit integral value used to initialize bits [159:144] of the result.
  3916. /// \param __w05
  3917. /// A 16-bit integral value used to initialize bits [175:160] of the result.
  3918. /// \param __w04
  3919. /// A 16-bit integral value used to initialize bits [191:176] of the result.
  3920. /// \param __w03
  3921. /// A 16-bit integral value used to initialize bits [207:192] of the result.
  3922. /// \param __w02
  3923. /// A 16-bit integral value used to initialize bits [223:208] of the result.
  3924. /// \param __w01
  3925. /// A 16-bit integral value used to initialize bits [239:224] of the result.
  3926. /// \param __w00
  3927. /// A 16-bit integral value used to initialize bits [255:240] of the result.
  3928. /// \returns An initialized 256-bit integer vector.
  3929. static __inline __m256i __DEFAULT_FN_ATTRS
  3930. _mm256_setr_epi16(short __w15, short __w14, short __w13, short __w12,
  3931. short __w11, short __w10, short __w09, short __w08,
  3932. short __w07, short __w06, short __w05, short __w04,
  3933. short __w03, short __w02, short __w01, short __w00)
  3934. {
  3935. return (__m256i)(__v16hi){ __w15, __w14, __w13, __w12, __w11, __w10, __w09,
  3936. __w08, __w07, __w06, __w05, __w04, __w03, __w02, __w01, __w00 };
  3937. }
  3938. /// \brief Constructs a 256-bit integer vector, initialized in reverse order
  3939. /// with the specified 8-bit integral values.
  3940. ///
  3941. /// \headerfile <x86intrin.h>
  3942. ///
  3943. /// This intrinsic is a utility function and does not correspond to a specific
  3944. /// instruction.
  3945. ///
  3946. /// \param __b31
  3947. /// An 8-bit integral value used to initialize bits [7:0] of the result.
  3948. /// \param __b30
  3949. /// An 8-bit integral value used to initialize bits [15:8] of the result.
  3950. /// \param __b29
  3951. /// An 8-bit integral value used to initialize bits [23:16] of the result.
  3952. /// \param __b28
  3953. /// An 8-bit integral value used to initialize bits [31:24] of the result.
  3954. /// \param __b27
  3955. /// An 8-bit integral value used to initialize bits [39:32] of the result.
  3956. /// \param __b26
  3957. /// An 8-bit integral value used to initialize bits [47:40] of the result.
  3958. /// \param __b25
  3959. /// An 8-bit integral value used to initialize bits [55:48] of the result.
  3960. /// \param __b24
  3961. /// An 8-bit integral value used to initialize bits [63:56] of the result.
  3962. /// \param __b23
  3963. /// An 8-bit integral value used to initialize bits [71:64] of the result.
  3964. /// \param __b22
  3965. /// An 8-bit integral value used to initialize bits [79:72] of the result.
  3966. /// \param __b21
  3967. /// An 8-bit integral value used to initialize bits [87:80] of the result.
  3968. /// \param __b20
  3969. /// An 8-bit integral value used to initialize bits [95:88] of the result.
  3970. /// \param __b19
  3971. /// An 8-bit integral value used to initialize bits [103:96] of the result.
  3972. /// \param __b18
  3973. /// An 8-bit integral value used to initialize bits [111:104] of the result.
  3974. /// \param __b17
  3975. /// An 8-bit integral value used to initialize bits [119:112] of the result.
  3976. /// \param __b16
  3977. /// An 8-bit integral value used to initialize bits [127:120] of the result.
  3978. /// \param __b15
  3979. /// An 8-bit integral value used to initialize bits [135:128] of the result.
  3980. /// \param __b14
  3981. /// An 8-bit integral value used to initialize bits [143:136] of the result.
  3982. /// \param __b13
  3983. /// An 8-bit integral value used to initialize bits [151:144] of the result.
  3984. /// \param __b12
  3985. /// An 8-bit integral value used to initialize bits [159:152] of the result.
  3986. /// \param __b11
  3987. /// An 8-bit integral value used to initialize bits [167:160] of the result.
  3988. /// \param __b10
  3989. /// An 8-bit integral value used to initialize bits [175:168] of the result.
  3990. /// \param __b09
  3991. /// An 8-bit integral value used to initialize bits [183:176] of the result.
  3992. /// \param __b08
  3993. /// An 8-bit integral value used to initialize bits [191:184] of the result.
  3994. /// \param __b07
  3995. /// An 8-bit integral value used to initialize bits [199:192] of the result.
  3996. /// \param __b06
  3997. /// An 8-bit integral value used to initialize bits [207:200] of the result.
  3998. /// \param __b05
  3999. /// An 8-bit integral value used to initialize bits [215:208] of the result.
  4000. /// \param __b04
  4001. /// An 8-bit integral value used to initialize bits [223:216] of the result.
  4002. /// \param __b03
  4003. /// An 8-bit integral value used to initialize bits [231:224] of the result.
  4004. /// \param __b02
  4005. /// An 8-bit integral value used to initialize bits [239:232] of the result.
  4006. /// \param __b01
  4007. /// An 8-bit integral value used to initialize bits [247:240] of the result.
  4008. /// \param __b00
  4009. /// An 8-bit integral value used to initialize bits [255:248] of the result.
  4010. /// \returns An initialized 256-bit integer vector.
  4011. static __inline __m256i __DEFAULT_FN_ATTRS
  4012. _mm256_setr_epi8(char __b31, char __b30, char __b29, char __b28,
  4013. char __b27, char __b26, char __b25, char __b24,
  4014. char __b23, char __b22, char __b21, char __b20,
  4015. char __b19, char __b18, char __b17, char __b16,
  4016. char __b15, char __b14, char __b13, char __b12,
  4017. char __b11, char __b10, char __b09, char __b08,
  4018. char __b07, char __b06, char __b05, char __b04,
  4019. char __b03, char __b02, char __b01, char __b00)
  4020. {
  4021. return (__m256i)(__v32qi){
  4022. __b31, __b30, __b29, __b28, __b27, __b26, __b25, __b24,
  4023. __b23, __b22, __b21, __b20, __b19, __b18, __b17, __b16,
  4024. __b15, __b14, __b13, __b12, __b11, __b10, __b09, __b08,
  4025. __b07, __b06, __b05, __b04, __b03, __b02, __b01, __b00 };
  4026. }
  4027. /// \brief Constructs a 256-bit integer vector, initialized in reverse order
  4028. /// with the specified 64-bit integral values.
  4029. ///
  4030. /// \headerfile <x86intrin.h>
  4031. ///
  4032. /// This intrinsic corresponds to the <c> VPUNPCKLQDQ+VINSERTF128 </c>
  4033. /// instruction.
  4034. ///
  4035. /// \param __a
  4036. /// A 64-bit integral value used to initialize bits [63:0] of the result.
  4037. /// \param __b
  4038. /// A 64-bit integral value used to initialize bits [127:64] of the result.
  4039. /// \param __c
  4040. /// A 64-bit integral value used to initialize bits [191:128] of the result.
  4041. /// \param __d
  4042. /// A 64-bit integral value used to initialize bits [255:192] of the result.
  4043. /// \returns An initialized 256-bit integer vector.
  4044. static __inline __m256i __DEFAULT_FN_ATTRS
  4045. _mm256_setr_epi64x(long long __a, long long __b, long long __c, long long __d)
  4046. {
  4047. return (__m256i)(__v4di){ __a, __b, __c, __d };
  4048. }
  4049. /* Create vectors with repeated elements */
  4050. /// \brief Constructs a 256-bit floating-point vector of [4 x double], with each
  4051. /// of the four double-precision floating-point vector elements set to the
  4052. /// specified double-precision floating-point value.
  4053. ///
  4054. /// \headerfile <x86intrin.h>
  4055. ///
  4056. /// This intrinsic corresponds to the <c> VMOVDDUP+VINSERTF128 </c> instruction.
  4057. ///
  4058. /// \param __w
  4059. /// A double-precision floating-point value used to initialize each vector
  4060. /// element of the result.
  4061. /// \returns An initialized 256-bit floating-point vector of [4 x double].
  4062. static __inline __m256d __DEFAULT_FN_ATTRS
  4063. _mm256_set1_pd(double __w)
  4064. {
  4065. return (__m256d){ __w, __w, __w, __w };
  4066. }
  4067. /// \brief Constructs a 256-bit floating-point vector of [8 x float], with each
  4068. /// of the eight single-precision floating-point vector elements set to the
  4069. /// specified single-precision floating-point value.
  4070. ///
  4071. /// \headerfile <x86intrin.h>
  4072. ///
  4073. /// This intrinsic corresponds to the <c> VPERMILPS+VINSERTF128 </c>
  4074. /// instruction.
  4075. ///
  4076. /// \param __w
  4077. /// A single-precision floating-point value used to initialize each vector
  4078. /// element of the result.
  4079. /// \returns An initialized 256-bit floating-point vector of [8 x float].
  4080. static __inline __m256 __DEFAULT_FN_ATTRS
  4081. _mm256_set1_ps(float __w)
  4082. {
  4083. return (__m256){ __w, __w, __w, __w, __w, __w, __w, __w };
  4084. }
  4085. /// \brief Constructs a 256-bit integer vector of [8 x i32], with each of the
  4086. /// 32-bit integral vector elements set to the specified 32-bit integral
  4087. /// value.
  4088. ///
  4089. /// \headerfile <x86intrin.h>
  4090. ///
  4091. /// This intrinsic corresponds to the <c> VPERMILPS+VINSERTF128 </c>
  4092. /// instruction.
  4093. ///
  4094. /// \param __i
  4095. /// A 32-bit integral value used to initialize each vector element of the
  4096. /// result.
  4097. /// \returns An initialized 256-bit integer vector of [8 x i32].
  4098. static __inline __m256i __DEFAULT_FN_ATTRS
  4099. _mm256_set1_epi32(int __i)
  4100. {
  4101. return (__m256i)(__v8si){ __i, __i, __i, __i, __i, __i, __i, __i };
  4102. }
  4103. /// \brief Constructs a 256-bit integer vector of [16 x i16], with each of the
  4104. /// 16-bit integral vector elements set to the specified 16-bit integral
  4105. /// value.
  4106. ///
  4107. /// \headerfile <x86intrin.h>
  4108. ///
  4109. /// This intrinsic corresponds to the <c> VPSHUFB+VINSERTF128 </c> instruction.
  4110. ///
  4111. /// \param __w
  4112. /// A 16-bit integral value used to initialize each vector element of the
  4113. /// result.
  4114. /// \returns An initialized 256-bit integer vector of [16 x i16].
  4115. static __inline __m256i __DEFAULT_FN_ATTRS
  4116. _mm256_set1_epi16(short __w)
  4117. {
  4118. return (__m256i)(__v16hi){ __w, __w, __w, __w, __w, __w, __w, __w, __w, __w,
  4119. __w, __w, __w, __w, __w, __w };
  4120. }
  4121. /// \brief Constructs a 256-bit integer vector of [32 x i8], with each of the
  4122. /// 8-bit integral vector elements set to the specified 8-bit integral value.
  4123. ///
  4124. /// \headerfile <x86intrin.h>
  4125. ///
  4126. /// This intrinsic corresponds to the <c> VPSHUFB+VINSERTF128 </c> instruction.
  4127. ///
  4128. /// \param __b
  4129. /// An 8-bit integral value used to initialize each vector element of the
  4130. /// result.
  4131. /// \returns An initialized 256-bit integer vector of [32 x i8].
  4132. static __inline __m256i __DEFAULT_FN_ATTRS
  4133. _mm256_set1_epi8(char __b)
  4134. {
  4135. return (__m256i)(__v32qi){ __b, __b, __b, __b, __b, __b, __b, __b, __b, __b,
  4136. __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b,
  4137. __b, __b, __b, __b, __b, __b, __b };
  4138. }
  4139. /// \brief Constructs a 256-bit integer vector of [4 x i64], with each of the
  4140. /// 64-bit integral vector elements set to the specified 64-bit integral
  4141. /// value.
  4142. ///
  4143. /// \headerfile <x86intrin.h>
  4144. ///
  4145. /// This intrinsic corresponds to the <c> VMOVDDUP+VINSERTF128 </c> instruction.
  4146. ///
  4147. /// \param __q
  4148. /// A 64-bit integral value used to initialize each vector element of the
  4149. /// result.
  4150. /// \returns An initialized 256-bit integer vector of [4 x i64].
  4151. static __inline __m256i __DEFAULT_FN_ATTRS
  4152. _mm256_set1_epi64x(long long __q)
  4153. {
  4154. return (__m256i)(__v4di){ __q, __q, __q, __q };
  4155. }
  4156. /* Create __zeroed vectors */
  4157. /// \brief Constructs a 256-bit floating-point vector of [4 x double] with all
  4158. /// vector elements initialized to zero.
  4159. ///
  4160. /// \headerfile <x86intrin.h>
  4161. ///
  4162. /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
  4163. ///
  4164. /// \returns A 256-bit vector of [4 x double] with all elements set to zero.
  4165. static __inline __m256d __DEFAULT_FN_ATTRS
  4166. _mm256_setzero_pd(void)
  4167. {
  4168. return (__m256d){ 0, 0, 0, 0 };
  4169. }
  4170. /// \brief Constructs a 256-bit floating-point vector of [8 x float] with all
  4171. /// vector elements initialized to zero.
  4172. ///
  4173. /// \headerfile <x86intrin.h>
  4174. ///
  4175. /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
  4176. ///
  4177. /// \returns A 256-bit vector of [8 x float] with all elements set to zero.
  4178. static __inline __m256 __DEFAULT_FN_ATTRS
  4179. _mm256_setzero_ps(void)
  4180. {
  4181. return (__m256){ 0, 0, 0, 0, 0, 0, 0, 0 };
  4182. }
  4183. /// \brief Constructs a 256-bit integer vector initialized to zero.
  4184. ///
  4185. /// \headerfile <x86intrin.h>
  4186. ///
  4187. /// This intrinsic corresponds to the <c> VXORPS </c> instruction.
  4188. ///
  4189. /// \returns A 256-bit integer vector initialized to zero.
  4190. static __inline __m256i __DEFAULT_FN_ATTRS
  4191. _mm256_setzero_si256(void)
  4192. {
  4193. return (__m256i){ 0LL, 0LL, 0LL, 0LL };
  4194. }
  4195. /* Cast between vector types */
  4196. /// \brief Casts a 256-bit floating-point vector of [4 x double] into a 256-bit
  4197. /// floating-point vector of [8 x float].
  4198. ///
  4199. /// \headerfile <x86intrin.h>
  4200. ///
  4201. /// This intrinsic has no corresponding instruction.
  4202. ///
  4203. /// \param __a
  4204. /// A 256-bit floating-point vector of [4 x double].
  4205. /// \returns A 256-bit floating-point vector of [8 x float] containing the same
  4206. /// bitwise pattern as the parameter.
  4207. static __inline __m256 __DEFAULT_FN_ATTRS
  4208. _mm256_castpd_ps(__m256d __a)
  4209. {
  4210. return (__m256)__a;
  4211. }
  4212. /// \brief Casts a 256-bit floating-point vector of [4 x double] into a 256-bit
  4213. /// integer vector.
  4214. ///
  4215. /// \headerfile <x86intrin.h>
  4216. ///
  4217. /// This intrinsic has no corresponding instruction.
  4218. ///
  4219. /// \param __a
  4220. /// A 256-bit floating-point vector of [4 x double].
  4221. /// \returns A 256-bit integer vector containing the same bitwise pattern as the
  4222. /// parameter.
  4223. static __inline __m256i __DEFAULT_FN_ATTRS
  4224. _mm256_castpd_si256(__m256d __a)
  4225. {
  4226. return (__m256i)__a;
  4227. }
  4228. /// \brief Casts a 256-bit floating-point vector of [8 x float] into a 256-bit
  4229. /// floating-point vector of [4 x double].
  4230. ///
  4231. /// \headerfile <x86intrin.h>
  4232. ///
  4233. /// This intrinsic has no corresponding instruction.
  4234. ///
  4235. /// \param __a
  4236. /// A 256-bit floating-point vector of [8 x float].
  4237. /// \returns A 256-bit floating-point vector of [4 x double] containing the same
  4238. /// bitwise pattern as the parameter.
  4239. static __inline __m256d __DEFAULT_FN_ATTRS
  4240. _mm256_castps_pd(__m256 __a)
  4241. {
  4242. return (__m256d)__a;
  4243. }
  4244. /// \brief Casts a 256-bit floating-point vector of [8 x float] into a 256-bit
  4245. /// integer vector.
  4246. ///
  4247. /// \headerfile <x86intrin.h>
  4248. ///
  4249. /// This intrinsic has no corresponding instruction.
  4250. ///
  4251. /// \param __a
  4252. /// A 256-bit floating-point vector of [8 x float].
  4253. /// \returns A 256-bit integer vector containing the same bitwise pattern as the
  4254. /// parameter.
  4255. static __inline __m256i __DEFAULT_FN_ATTRS
  4256. _mm256_castps_si256(__m256 __a)
  4257. {
  4258. return (__m256i)__a;
  4259. }
  4260. /// \brief Casts a 256-bit integer vector into a 256-bit floating-point vector
  4261. /// of [8 x float].
  4262. ///
  4263. /// \headerfile <x86intrin.h>
  4264. ///
  4265. /// This intrinsic has no corresponding instruction.
  4266. ///
  4267. /// \param __a
  4268. /// A 256-bit integer vector.
  4269. /// \returns A 256-bit floating-point vector of [8 x float] containing the same
  4270. /// bitwise pattern as the parameter.
  4271. static __inline __m256 __DEFAULT_FN_ATTRS
  4272. _mm256_castsi256_ps(__m256i __a)
  4273. {
  4274. return (__m256)__a;
  4275. }
  4276. /// \brief Casts a 256-bit integer vector into a 256-bit floating-point vector
  4277. /// of [4 x double].
  4278. ///
  4279. /// \headerfile <x86intrin.h>
  4280. ///
  4281. /// This intrinsic has no corresponding instruction.
  4282. ///
  4283. /// \param __a
  4284. /// A 256-bit integer vector.
  4285. /// \returns A 256-bit floating-point vector of [4 x double] containing the same
  4286. /// bitwise pattern as the parameter.
  4287. static __inline __m256d __DEFAULT_FN_ATTRS
  4288. _mm256_castsi256_pd(__m256i __a)
  4289. {
  4290. return (__m256d)__a;
  4291. }
  4292. /// \brief Returns the lower 128 bits of a 256-bit floating-point vector of
  4293. /// [4 x double] as a 128-bit floating-point vector of [2 x double].
  4294. ///
  4295. /// \headerfile <x86intrin.h>
  4296. ///
  4297. /// This intrinsic has no corresponding instruction.
  4298. ///
  4299. /// \param __a
  4300. /// A 256-bit floating-point vector of [4 x double].
  4301. /// \returns A 128-bit floating-point vector of [2 x double] containing the
  4302. /// lower 128 bits of the parameter.
  4303. static __inline __m128d __DEFAULT_FN_ATTRS
  4304. _mm256_castpd256_pd128(__m256d __a)
  4305. {
  4306. return __builtin_shufflevector((__v4df)__a, (__v4df)__a, 0, 1);
  4307. }
  4308. /// \brief Returns the lower 128 bits of a 256-bit floating-point vector of
  4309. /// [8 x float] as a 128-bit floating-point vector of [4 x float].
  4310. ///
  4311. /// \headerfile <x86intrin.h>
  4312. ///
  4313. /// This intrinsic has no corresponding instruction.
  4314. ///
  4315. /// \param __a
  4316. /// A 256-bit floating-point vector of [8 x float].
  4317. /// \returns A 128-bit floating-point vector of [4 x float] containing the
  4318. /// lower 128 bits of the parameter.
  4319. static __inline __m128 __DEFAULT_FN_ATTRS
  4320. _mm256_castps256_ps128(__m256 __a)
  4321. {
  4322. return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 0, 1, 2, 3);
  4323. }
  4324. /// \brief Truncates a 256-bit integer vector into a 128-bit integer vector.
  4325. ///
  4326. /// \headerfile <x86intrin.h>
  4327. ///
  4328. /// This intrinsic has no corresponding instruction.
  4329. ///
  4330. /// \param __a
  4331. /// A 256-bit integer vector.
  4332. /// \returns A 128-bit integer vector containing the lower 128 bits of the
  4333. /// parameter.
  4334. static __inline __m128i __DEFAULT_FN_ATTRS
  4335. _mm256_castsi256_si128(__m256i __a)
  4336. {
  4337. return __builtin_shufflevector((__v4di)__a, (__v4di)__a, 0, 1);
  4338. }
  4339. /// \brief Constructs a 256-bit floating-point vector of [4 x double] from a
  4340. /// 128-bit floating-point vector of [2 x double].
  4341. ///
  4342. /// The lower 128 bits contain the value of the source vector. The contents
  4343. /// of the upper 128 bits are undefined.
  4344. ///
  4345. /// \headerfile <x86intrin.h>
  4346. ///
  4347. /// This intrinsic has no corresponding instruction.
  4348. ///
  4349. /// \param __a
  4350. /// A 128-bit vector of [2 x double].
  4351. /// \returns A 256-bit floating-point vector of [4 x double]. The lower 128 bits
  4352. /// contain the value of the parameter. The contents of the upper 128 bits
  4353. /// are undefined.
  4354. static __inline __m256d __DEFAULT_FN_ATTRS
  4355. _mm256_castpd128_pd256(__m128d __a)
  4356. {
  4357. return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 1, -1, -1);
  4358. }
  4359. /// \brief Constructs a 256-bit floating-point vector of [8 x float] from a
  4360. /// 128-bit floating-point vector of [4 x float].
  4361. ///
  4362. /// The lower 128 bits contain the value of the source vector. The contents
  4363. /// of the upper 128 bits are undefined.
  4364. ///
  4365. /// \headerfile <x86intrin.h>
  4366. ///
  4367. /// This intrinsic has no corresponding instruction.
  4368. ///
  4369. /// \param __a
  4370. /// A 128-bit vector of [4 x float].
  4371. /// \returns A 256-bit floating-point vector of [8 x float]. The lower 128 bits
  4372. /// contain the value of the parameter. The contents of the upper 128 bits
  4373. /// are undefined.
  4374. static __inline __m256 __DEFAULT_FN_ATTRS
  4375. _mm256_castps128_ps256(__m128 __a)
  4376. {
  4377. return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1, 2, 3, -1, -1, -1, -1);
  4378. }
  4379. /// \brief Constructs a 256-bit integer vector from a 128-bit integer vector.
  4380. ///
  4381. /// The lower 128 bits contain the value of the source vector. The contents
  4382. /// of the upper 128 bits are undefined.
  4383. ///
  4384. /// \headerfile <x86intrin.h>
  4385. ///
  4386. /// This intrinsic has no corresponding instruction.
  4387. ///
  4388. /// \param __a
  4389. /// A 128-bit integer vector.
  4390. /// \returns A 256-bit integer vector. The lower 128 bits contain the value of
  4391. /// the parameter. The contents of the upper 128 bits are undefined.
  4392. static __inline __m256i __DEFAULT_FN_ATTRS
  4393. _mm256_castsi128_si256(__m128i __a)
  4394. {
  4395. return __builtin_shufflevector((__v2di)__a, (__v2di)__a, 0, 1, -1, -1);
  4396. }
  4397. /// \brief Constructs a 256-bit floating-point vector of [4 x double] from a
  4398. /// 128-bit floating-point vector of [2 x double]. The lower 128 bits
  4399. /// contain the value of the source vector. The upper 128 bits are set
  4400. /// to zero.
  4401. ///
  4402. /// \headerfile <x86intrin.h>
  4403. ///
  4404. /// This intrinsic has no corresponding instruction.
  4405. ///
  4406. /// \param __a
  4407. /// A 128-bit vector of [2 x double].
  4408. /// \returns A 256-bit floating-point vector of [4 x double]. The lower 128 bits
  4409. /// contain the value of the parameter. The upper 128 bits are set to zero.
  4410. static __inline __m256d __DEFAULT_FN_ATTRS
  4411. _mm256_zextpd128_pd256(__m128d __a)
  4412. {
  4413. return __builtin_shufflevector((__v2df)__a, (__v2df)_mm_setzero_pd(), 0, 1, 2, 3);
  4414. }
  4415. /// \brief Constructs a 256-bit floating-point vector of [8 x float] from a
  4416. /// 128-bit floating-point vector of [4 x float]. The lower 128 bits contain
  4417. /// the value of the source vector. The upper 128 bits are set to zero.
  4418. ///
  4419. /// \headerfile <x86intrin.h>
  4420. ///
  4421. /// This intrinsic has no corresponding instruction.
  4422. ///
  4423. /// \param __a
  4424. /// A 128-bit vector of [4 x float].
  4425. /// \returns A 256-bit floating-point vector of [8 x float]. The lower 128 bits
  4426. /// contain the value of the parameter. The upper 128 bits are set to zero.
  4427. static __inline __m256 __DEFAULT_FN_ATTRS
  4428. _mm256_zextps128_ps256(__m128 __a)
  4429. {
  4430. return __builtin_shufflevector((__v4sf)__a, (__v4sf)_mm_setzero_ps(), 0, 1, 2, 3, 4, 5, 6, 7);
  4431. }
  4432. /// \brief Constructs a 256-bit integer vector from a 128-bit integer vector.
  4433. /// The lower 128 bits contain the value of the source vector. The upper
  4434. /// 128 bits are set to zero.
  4435. ///
  4436. /// \headerfile <x86intrin.h>
  4437. ///
  4438. /// This intrinsic has no corresponding instruction.
  4439. ///
  4440. /// \param __a
  4441. /// A 128-bit integer vector.
  4442. /// \returns A 256-bit integer vector. The lower 128 bits contain the value of
  4443. /// the parameter. The upper 128 bits are set to zero.
  4444. static __inline __m256i __DEFAULT_FN_ATTRS
  4445. _mm256_zextsi128_si256(__m128i __a)
  4446. {
  4447. return __builtin_shufflevector((__v2di)__a, (__v2di)_mm_setzero_si128(), 0, 1, 2, 3);
  4448. }
  4449. /*
  4450. Vector insert.
  4451. We use macros rather than inlines because we only want to accept
  4452. invocations where the immediate M is a constant expression.
  4453. */
  4454. /// \brief Constructs a new 256-bit vector of [8 x float] by first duplicating
  4455. /// a 256-bit vector of [8 x float] given in the first parameter, and then
  4456. /// replacing either the upper or the lower 128 bits with the contents of a
  4457. /// 128-bit vector of [4 x float] in the second parameter.
  4458. ///
  4459. /// The immediate integer parameter determines between the upper or the lower
  4460. /// 128 bits.
  4461. ///
  4462. /// \headerfile <x86intrin.h>
  4463. ///
  4464. /// \code
  4465. /// __m256 _mm256_insertf128_ps(__m256 V1, __m128 V2, const int M);
  4466. /// \endcode
  4467. ///
  4468. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4469. ///
  4470. /// \param V1
  4471. /// A 256-bit vector of [8 x float]. This vector is copied to the result
  4472. /// first, and then either the upper or the lower 128 bits of the result will
  4473. /// be replaced by the contents of \a V2.
  4474. /// \param V2
  4475. /// A 128-bit vector of [4 x float]. The contents of this parameter are
  4476. /// written to either the upper or the lower 128 bits of the result depending
  4477. /// on the value of parameter \a M.
  4478. /// \param M
  4479. /// An immediate integer. The least significant bit determines how the values
  4480. /// from the two parameters are interleaved: \n
  4481. /// If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result,
  4482. /// and bits [255:128] of \a V1 are copied to bits [255:128] of the
  4483. /// result. \n
  4484. /// If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the
  4485. /// result, and bits [127:0] of \a V1 are copied to bits [127:0] of the
  4486. /// result.
  4487. /// \returns A 256-bit vector of [8 x float] containing the interleaved values.
  4488. #define _mm256_insertf128_ps(V1, V2, M) __extension__ ({ \
  4489. (__m256)__builtin_shufflevector( \
  4490. (__v8sf)(__m256)(V1), \
  4491. (__v8sf)_mm256_castps128_ps256((__m128)(V2)), \
  4492. (((M) & 1) ? 0 : 8), \
  4493. (((M) & 1) ? 1 : 9), \
  4494. (((M) & 1) ? 2 : 10), \
  4495. (((M) & 1) ? 3 : 11), \
  4496. (((M) & 1) ? 8 : 4), \
  4497. (((M) & 1) ? 9 : 5), \
  4498. (((M) & 1) ? 10 : 6), \
  4499. (((M) & 1) ? 11 : 7) );})
  4500. /// \brief Constructs a new 256-bit vector of [4 x double] by first duplicating
  4501. /// a 256-bit vector of [4 x double] given in the first parameter, and then
  4502. /// replacing either the upper or the lower 128 bits with the contents of a
  4503. /// 128-bit vector of [2 x double] in the second parameter.
  4504. ///
  4505. /// The immediate integer parameter determines between the upper or the lower
  4506. /// 128 bits.
  4507. ///
  4508. /// \headerfile <x86intrin.h>
  4509. ///
  4510. /// \code
  4511. /// __m256d _mm256_insertf128_pd(__m256d V1, __m128d V2, const int M);
  4512. /// \endcode
  4513. ///
  4514. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4515. ///
  4516. /// \param V1
  4517. /// A 256-bit vector of [4 x double]. This vector is copied to the result
  4518. /// first, and then either the upper or the lower 128 bits of the result will
  4519. /// be replaced by the contents of \a V2.
  4520. /// \param V2
  4521. /// A 128-bit vector of [2 x double]. The contents of this parameter are
  4522. /// written to either the upper or the lower 128 bits of the result depending
  4523. /// on the value of parameter \a M.
  4524. /// \param M
  4525. /// An immediate integer. The least significant bit determines how the values
  4526. /// from the two parameters are interleaved: \n
  4527. /// If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result,
  4528. /// and bits [255:128] of \a V1 are copied to bits [255:128] of the
  4529. /// result. \n
  4530. /// If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the
  4531. /// result, and bits [127:0] of \a V1 are copied to bits [127:0] of the
  4532. /// result.
  4533. /// \returns A 256-bit vector of [4 x double] containing the interleaved values.
  4534. #define _mm256_insertf128_pd(V1, V2, M) __extension__ ({ \
  4535. (__m256d)__builtin_shufflevector( \
  4536. (__v4df)(__m256d)(V1), \
  4537. (__v4df)_mm256_castpd128_pd256((__m128d)(V2)), \
  4538. (((M) & 1) ? 0 : 4), \
  4539. (((M) & 1) ? 1 : 5), \
  4540. (((M) & 1) ? 4 : 2), \
  4541. (((M) & 1) ? 5 : 3) );})
  4542. /// \brief Constructs a new 256-bit integer vector by first duplicating a
  4543. /// 256-bit integer vector given in the first parameter, and then replacing
  4544. /// either the upper or the lower 128 bits with the contents of a 128-bit
  4545. /// integer vector in the second parameter.
  4546. ///
  4547. /// The immediate integer parameter determines between the upper or the lower
  4548. /// 128 bits.
  4549. ///
  4550. /// \headerfile <x86intrin.h>
  4551. ///
  4552. /// \code
  4553. /// __m256i _mm256_insertf128_si256(__m256i V1, __m128i V2, const int M);
  4554. /// \endcode
  4555. ///
  4556. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4557. ///
  4558. /// \param V1
  4559. /// A 256-bit integer vector. This vector is copied to the result first, and
  4560. /// then either the upper or the lower 128 bits of the result will be
  4561. /// replaced by the contents of \a V2.
  4562. /// \param V2
  4563. /// A 128-bit integer vector. The contents of this parameter are written to
  4564. /// either the upper or the lower 128 bits of the result depending on the
  4565. /// value of parameter \a M.
  4566. /// \param M
  4567. /// An immediate integer. The least significant bit determines how the values
  4568. /// from the two parameters are interleaved: \n
  4569. /// If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result,
  4570. /// and bits [255:128] of \a V1 are copied to bits [255:128] of the
  4571. /// result. \n
  4572. /// If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the
  4573. /// result, and bits [127:0] of \a V1 are copied to bits [127:0] of the
  4574. /// result.
  4575. /// \returns A 256-bit integer vector containing the interleaved values.
  4576. #define _mm256_insertf128_si256(V1, V2, M) __extension__ ({ \
  4577. (__m256i)__builtin_shufflevector( \
  4578. (__v4di)(__m256i)(V1), \
  4579. (__v4di)_mm256_castsi128_si256((__m128i)(V2)), \
  4580. (((M) & 1) ? 0 : 4), \
  4581. (((M) & 1) ? 1 : 5), \
  4582. (((M) & 1) ? 4 : 2), \
  4583. (((M) & 1) ? 5 : 3) );})
  4584. /*
  4585. Vector extract.
  4586. We use macros rather than inlines because we only want to accept
  4587. invocations where the immediate M is a constant expression.
  4588. */
  4589. /// \brief Extracts either the upper or the lower 128 bits from a 256-bit vector
  4590. /// of [8 x float], as determined by the immediate integer parameter, and
  4591. /// returns the extracted bits as a 128-bit vector of [4 x float].
  4592. ///
  4593. /// \headerfile <x86intrin.h>
  4594. ///
  4595. /// \code
  4596. /// __m128 _mm256_extractf128_ps(__m256 V, const int M);
  4597. /// \endcode
  4598. ///
  4599. /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction.
  4600. ///
  4601. /// \param V
  4602. /// A 256-bit vector of [8 x float].
  4603. /// \param M
  4604. /// An immediate integer. The least significant bit determines which bits are
  4605. /// extracted from the first parameter: \n
  4606. /// If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the
  4607. /// result. \n
  4608. /// If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result.
  4609. /// \returns A 128-bit vector of [4 x float] containing the extracted bits.
  4610. #define _mm256_extractf128_ps(V, M) __extension__ ({ \
  4611. (__m128)__builtin_shufflevector( \
  4612. (__v8sf)(__m256)(V), \
  4613. (__v8sf)(_mm256_undefined_ps()), \
  4614. (((M) & 1) ? 4 : 0), \
  4615. (((M) & 1) ? 5 : 1), \
  4616. (((M) & 1) ? 6 : 2), \
  4617. (((M) & 1) ? 7 : 3) );})
  4618. /// \brief Extracts either the upper or the lower 128 bits from a 256-bit vector
  4619. /// of [4 x double], as determined by the immediate integer parameter, and
  4620. /// returns the extracted bits as a 128-bit vector of [2 x double].
  4621. ///
  4622. /// \headerfile <x86intrin.h>
  4623. ///
  4624. /// \code
  4625. /// __m128d _mm256_extractf128_pd(__m256d V, const int M);
  4626. /// \endcode
  4627. ///
  4628. /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction.
  4629. ///
  4630. /// \param V
  4631. /// A 256-bit vector of [4 x double].
  4632. /// \param M
  4633. /// An immediate integer. The least significant bit determines which bits are
  4634. /// extracted from the first parameter: \n
  4635. /// If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the
  4636. /// result. \n
  4637. /// If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result.
  4638. /// \returns A 128-bit vector of [2 x double] containing the extracted bits.
  4639. #define _mm256_extractf128_pd(V, M) __extension__ ({ \
  4640. (__m128d)__builtin_shufflevector( \
  4641. (__v4df)(__m256d)(V), \
  4642. (__v4df)(_mm256_undefined_pd()), \
  4643. (((M) & 1) ? 2 : 0), \
  4644. (((M) & 1) ? 3 : 1) );})
  4645. /// \brief Extracts either the upper or the lower 128 bits from a 256-bit
  4646. /// integer vector, as determined by the immediate integer parameter, and
  4647. /// returns the extracted bits as a 128-bit integer vector.
  4648. ///
  4649. /// \headerfile <x86intrin.h>
  4650. ///
  4651. /// \code
  4652. /// __m128i _mm256_extractf128_si256(__m256i V, const int M);
  4653. /// \endcode
  4654. ///
  4655. /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction.
  4656. ///
  4657. /// \param V
  4658. /// A 256-bit integer vector.
  4659. /// \param M
  4660. /// An immediate integer. The least significant bit determines which bits are
  4661. /// extracted from the first parameter: \n
  4662. /// If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the
  4663. /// result. \n
  4664. /// If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result.
  4665. /// \returns A 128-bit integer vector containing the extracted bits.
  4666. #define _mm256_extractf128_si256(V, M) __extension__ ({ \
  4667. (__m128i)__builtin_shufflevector( \
  4668. (__v4di)(__m256i)(V), \
  4669. (__v4di)(_mm256_undefined_si256()), \
  4670. (((M) & 1) ? 2 : 0), \
  4671. (((M) & 1) ? 3 : 1) );})
  4672. /* SIMD load ops (unaligned) */
  4673. /// \brief Loads two 128-bit floating-point vectors of [4 x float] from
  4674. /// unaligned memory locations and constructs a 256-bit floating-point vector
  4675. /// of [8 x float] by concatenating the two 128-bit vectors.
  4676. ///
  4677. /// \headerfile <x86intrin.h>
  4678. ///
  4679. /// This intrinsic corresponds to load instructions followed by the
  4680. /// <c> VINSERTF128 </c> instruction.
  4681. ///
  4682. /// \param __addr_hi
  4683. /// A pointer to a 128-bit memory location containing 4 consecutive
  4684. /// single-precision floating-point values. These values are to be copied to
  4685. /// bits[255:128] of the result. The address of the memory location does not
  4686. /// have to be aligned.
  4687. /// \param __addr_lo
  4688. /// A pointer to a 128-bit memory location containing 4 consecutive
  4689. /// single-precision floating-point values. These values are to be copied to
  4690. /// bits[127:0] of the result. The address of the memory location does not
  4691. /// have to be aligned.
  4692. /// \returns A 256-bit floating-point vector of [8 x float] containing the
  4693. /// concatenated result.
  4694. static __inline __m256 __DEFAULT_FN_ATTRS
  4695. _mm256_loadu2_m128(float const *__addr_hi, float const *__addr_lo)
  4696. {
  4697. __m256 __v256 = _mm256_castps128_ps256(_mm_loadu_ps(__addr_lo));
  4698. return _mm256_insertf128_ps(__v256, _mm_loadu_ps(__addr_hi), 1);
  4699. }
  4700. /// \brief Loads two 128-bit floating-point vectors of [2 x double] from
  4701. /// unaligned memory locations and constructs a 256-bit floating-point vector
  4702. /// of [4 x double] by concatenating the two 128-bit vectors.
  4703. ///
  4704. /// \headerfile <x86intrin.h>
  4705. ///
  4706. /// This intrinsic corresponds to load instructions followed by the
  4707. /// <c> VINSERTF128 </c> instruction.
  4708. ///
  4709. /// \param __addr_hi
  4710. /// A pointer to a 128-bit memory location containing two consecutive
  4711. /// double-precision floating-point values. These values are to be copied to
  4712. /// bits[255:128] of the result. The address of the memory location does not
  4713. /// have to be aligned.
  4714. /// \param __addr_lo
  4715. /// A pointer to a 128-bit memory location containing two consecutive
  4716. /// double-precision floating-point values. These values are to be copied to
  4717. /// bits[127:0] of the result. The address of the memory location does not
  4718. /// have to be aligned.
  4719. /// \returns A 256-bit floating-point vector of [4 x double] containing the
  4720. /// concatenated result.
  4721. static __inline __m256d __DEFAULT_FN_ATTRS
  4722. _mm256_loadu2_m128d(double const *__addr_hi, double const *__addr_lo)
  4723. {
  4724. __m256d __v256 = _mm256_castpd128_pd256(_mm_loadu_pd(__addr_lo));
  4725. return _mm256_insertf128_pd(__v256, _mm_loadu_pd(__addr_hi), 1);
  4726. }
  4727. /// \brief Loads two 128-bit integer vectors from unaligned memory locations and
  4728. /// constructs a 256-bit integer vector by concatenating the two 128-bit
  4729. /// vectors.
  4730. ///
  4731. /// \headerfile <x86intrin.h>
  4732. ///
  4733. /// This intrinsic corresponds to load instructions followed by the
  4734. /// <c> VINSERTF128 </c> instruction.
  4735. ///
  4736. /// \param __addr_hi
  4737. /// A pointer to a 128-bit memory location containing a 128-bit integer
  4738. /// vector. This vector is to be copied to bits[255:128] of the result. The
  4739. /// address of the memory location does not have to be aligned.
  4740. /// \param __addr_lo
  4741. /// A pointer to a 128-bit memory location containing a 128-bit integer
  4742. /// vector. This vector is to be copied to bits[127:0] of the result. The
  4743. /// address of the memory location does not have to be aligned.
  4744. /// \returns A 256-bit integer vector containing the concatenated result.
  4745. static __inline __m256i __DEFAULT_FN_ATTRS
  4746. _mm256_loadu2_m128i(__m128i const *__addr_hi, __m128i const *__addr_lo)
  4747. {
  4748. __m256i __v256 = _mm256_castsi128_si256(_mm_loadu_si128(__addr_lo));
  4749. return _mm256_insertf128_si256(__v256, _mm_loadu_si128(__addr_hi), 1);
  4750. }
  4751. /* SIMD store ops (unaligned) */
  4752. /// \brief Stores the upper and lower 128 bits of a 256-bit floating-point
  4753. /// vector of [8 x float] into two different unaligned memory locations.
  4754. ///
  4755. /// \headerfile <x86intrin.h>
  4756. ///
  4757. /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction and the
  4758. /// store instructions.
  4759. ///
  4760. /// \param __addr_hi
  4761. /// A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be
  4762. /// copied to this memory location. The address of this memory location does
  4763. /// not have to be aligned.
  4764. /// \param __addr_lo
  4765. /// A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be
  4766. /// copied to this memory location. The address of this memory location does
  4767. /// not have to be aligned.
  4768. /// \param __a
  4769. /// A 256-bit floating-point vector of [8 x float].
  4770. static __inline void __DEFAULT_FN_ATTRS
  4771. _mm256_storeu2_m128(float *__addr_hi, float *__addr_lo, __m256 __a)
  4772. {
  4773. __m128 __v128;
  4774. __v128 = _mm256_castps256_ps128(__a);
  4775. _mm_storeu_ps(__addr_lo, __v128);
  4776. __v128 = _mm256_extractf128_ps(__a, 1);
  4777. _mm_storeu_ps(__addr_hi, __v128);
  4778. }
  4779. /// \brief Stores the upper and lower 128 bits of a 256-bit floating-point
  4780. /// vector of [4 x double] into two different unaligned memory locations.
  4781. ///
  4782. /// \headerfile <x86intrin.h>
  4783. ///
  4784. /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction and the
  4785. /// store instructions.
  4786. ///
  4787. /// \param __addr_hi
  4788. /// A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be
  4789. /// copied to this memory location. The address of this memory location does
  4790. /// not have to be aligned.
  4791. /// \param __addr_lo
  4792. /// A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be
  4793. /// copied to this memory location. The address of this memory location does
  4794. /// not have to be aligned.
  4795. /// \param __a
  4796. /// A 256-bit floating-point vector of [4 x double].
  4797. static __inline void __DEFAULT_FN_ATTRS
  4798. _mm256_storeu2_m128d(double *__addr_hi, double *__addr_lo, __m256d __a)
  4799. {
  4800. __m128d __v128;
  4801. __v128 = _mm256_castpd256_pd128(__a);
  4802. _mm_storeu_pd(__addr_lo, __v128);
  4803. __v128 = _mm256_extractf128_pd(__a, 1);
  4804. _mm_storeu_pd(__addr_hi, __v128);
  4805. }
  4806. /// \brief Stores the upper and lower 128 bits of a 256-bit integer vector into
  4807. /// two different unaligned memory locations.
  4808. ///
  4809. /// \headerfile <x86intrin.h>
  4810. ///
  4811. /// This intrinsic corresponds to the <c> VEXTRACTF128 </c> instruction and the
  4812. /// store instructions.
  4813. ///
  4814. /// \param __addr_hi
  4815. /// A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be
  4816. /// copied to this memory location. The address of this memory location does
  4817. /// not have to be aligned.
  4818. /// \param __addr_lo
  4819. /// A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be
  4820. /// copied to this memory location. The address of this memory location does
  4821. /// not have to be aligned.
  4822. /// \param __a
  4823. /// A 256-bit integer vector.
  4824. static __inline void __DEFAULT_FN_ATTRS
  4825. _mm256_storeu2_m128i(__m128i *__addr_hi, __m128i *__addr_lo, __m256i __a)
  4826. {
  4827. __m128i __v128;
  4828. __v128 = _mm256_castsi256_si128(__a);
  4829. _mm_storeu_si128(__addr_lo, __v128);
  4830. __v128 = _mm256_extractf128_si256(__a, 1);
  4831. _mm_storeu_si128(__addr_hi, __v128);
  4832. }
  4833. /// \brief Constructs a 256-bit floating-point vector of [8 x float] by
  4834. /// concatenating two 128-bit floating-point vectors of [4 x float].
  4835. ///
  4836. /// \headerfile <x86intrin.h>
  4837. ///
  4838. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4839. ///
  4840. /// \param __hi
  4841. /// A 128-bit floating-point vector of [4 x float] to be copied to the upper
  4842. /// 128 bits of the result.
  4843. /// \param __lo
  4844. /// A 128-bit floating-point vector of [4 x float] to be copied to the lower
  4845. /// 128 bits of the result.
  4846. /// \returns A 256-bit floating-point vector of [8 x float] containing the
  4847. /// concatenated result.
  4848. static __inline __m256 __DEFAULT_FN_ATTRS
  4849. _mm256_set_m128 (__m128 __hi, __m128 __lo)
  4850. {
  4851. return (__m256) __builtin_shufflevector((__v4sf)__lo, (__v4sf)__hi, 0, 1, 2, 3, 4, 5, 6, 7);
  4852. }
  4853. /// \brief Constructs a 256-bit floating-point vector of [4 x double] by
  4854. /// concatenating two 128-bit floating-point vectors of [2 x double].
  4855. ///
  4856. /// \headerfile <x86intrin.h>
  4857. ///
  4858. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4859. ///
  4860. /// \param __hi
  4861. /// A 128-bit floating-point vector of [2 x double] to be copied to the upper
  4862. /// 128 bits of the result.
  4863. /// \param __lo
  4864. /// A 128-bit floating-point vector of [2 x double] to be copied to the lower
  4865. /// 128 bits of the result.
  4866. /// \returns A 256-bit floating-point vector of [4 x double] containing the
  4867. /// concatenated result.
  4868. static __inline __m256d __DEFAULT_FN_ATTRS
  4869. _mm256_set_m128d (__m128d __hi, __m128d __lo)
  4870. {
  4871. return (__m256d)_mm256_set_m128((__m128)__hi, (__m128)__lo);
  4872. }
  4873. /// \brief Constructs a 256-bit integer vector by concatenating two 128-bit
  4874. /// integer vectors.
  4875. ///
  4876. /// \headerfile <x86intrin.h>
  4877. ///
  4878. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4879. ///
  4880. /// \param __hi
  4881. /// A 128-bit integer vector to be copied to the upper 128 bits of the
  4882. /// result.
  4883. /// \param __lo
  4884. /// A 128-bit integer vector to be copied to the lower 128 bits of the
  4885. /// result.
  4886. /// \returns A 256-bit integer vector containing the concatenated result.
  4887. static __inline __m256i __DEFAULT_FN_ATTRS
  4888. _mm256_set_m128i (__m128i __hi, __m128i __lo)
  4889. {
  4890. return (__m256i)_mm256_set_m128((__m128)__hi, (__m128)__lo);
  4891. }
  4892. /// \brief Constructs a 256-bit floating-point vector of [8 x float] by
  4893. /// concatenating two 128-bit floating-point vectors of [4 x float]. This is
  4894. /// similar to _mm256_set_m128, but the order of the input parameters is
  4895. /// swapped.
  4896. ///
  4897. /// \headerfile <x86intrin.h>
  4898. ///
  4899. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4900. ///
  4901. /// \param __lo
  4902. /// A 128-bit floating-point vector of [4 x float] to be copied to the lower
  4903. /// 128 bits of the result.
  4904. /// \param __hi
  4905. /// A 128-bit floating-point vector of [4 x float] to be copied to the upper
  4906. /// 128 bits of the result.
  4907. /// \returns A 256-bit floating-point vector of [8 x float] containing the
  4908. /// concatenated result.
  4909. static __inline __m256 __DEFAULT_FN_ATTRS
  4910. _mm256_setr_m128 (__m128 __lo, __m128 __hi)
  4911. {
  4912. return _mm256_set_m128(__hi, __lo);
  4913. }
  4914. /// \brief Constructs a 256-bit floating-point vector of [4 x double] by
  4915. /// concatenating two 128-bit floating-point vectors of [2 x double]. This is
  4916. /// similar to _mm256_set_m128d, but the order of the input parameters is
  4917. /// swapped.
  4918. ///
  4919. /// \headerfile <x86intrin.h>
  4920. ///
  4921. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4922. ///
  4923. /// \param __lo
  4924. /// A 128-bit floating-point vector of [2 x double] to be copied to the lower
  4925. /// 128 bits of the result.
  4926. /// \param __hi
  4927. /// A 128-bit floating-point vector of [2 x double] to be copied to the upper
  4928. /// 128 bits of the result.
  4929. /// \returns A 256-bit floating-point vector of [4 x double] containing the
  4930. /// concatenated result.
  4931. static __inline __m256d __DEFAULT_FN_ATTRS
  4932. _mm256_setr_m128d (__m128d __lo, __m128d __hi)
  4933. {
  4934. return (__m256d)_mm256_set_m128((__m128)__hi, (__m128)__lo);
  4935. }
  4936. /// \brief Constructs a 256-bit integer vector by concatenating two 128-bit
  4937. /// integer vectors. This is similar to _mm256_set_m128i, but the order of
  4938. /// the input parameters is swapped.
  4939. ///
  4940. /// \headerfile <x86intrin.h>
  4941. ///
  4942. /// This intrinsic corresponds to the <c> VINSERTF128 </c> instruction.
  4943. ///
  4944. /// \param __lo
  4945. /// A 128-bit integer vector to be copied to the lower 128 bits of the
  4946. /// result.
  4947. /// \param __hi
  4948. /// A 128-bit integer vector to be copied to the upper 128 bits of the
  4949. /// result.
  4950. /// \returns A 256-bit integer vector containing the concatenated result.
  4951. static __inline __m256i __DEFAULT_FN_ATTRS
  4952. _mm256_setr_m128i (__m128i __lo, __m128i __hi)
  4953. {
  4954. return (__m256i)_mm256_set_m128((__m128)__hi, (__m128)__lo);
  4955. }
  4956. #undef __DEFAULT_FN_ATTRS
  4957. #endif /* __AVXINTRIN_H */