No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Avx2.cs 125KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054
  1. using System;
  2. using System.Diagnostics;
  3. namespace Unity.Burst.Intrinsics
  4. {
  5. public unsafe static partial class X86
  6. {
  7. /// <summary>
  8. /// AVX2 intrinsics
  9. /// </summary>
  10. public static class Avx2
  11. {
  12. /// <summary>
  13. /// Evaluates to true at compile time if AVX2 intrinsics are supported.
  14. /// </summary>
  15. public static bool IsAvx2Supported { get { return false; } }
  16. /// <summary>
  17. /// Create mask from the most significant bit of each 8-bit element in a, and store the result in dst.
  18. /// </summary>
  19. /// <remarks>
  20. /// **** vpmovmskb r32, ymm
  21. /// </remarks>
  22. /// <param name="a">Vector a</param>
  23. /// <returns>Integer</returns>
  24. [DebuggerStepThrough]
  25. public static int mm256_movemask_epi8(v256 a)
  26. {
  27. uint result = 0;
  28. byte* ptr = &a.Byte0;
  29. uint bit = 1;
  30. for (int i = 0; i < 32; ++i, bit <<= 1)
  31. {
  32. result |= (((uint)ptr[i]) >> 7) * bit;
  33. }
  34. return (int)result;
  35. }
  36. /// <summary>
  37. /// Extract an 8-bit integer from a, selected with index (which must be constant), and store the result in dst.
  38. /// </summary>
  39. /// <param name="a">Vector a</param>
  40. /// <param name="index">Index in the vector</param>
  41. /// <returns>Integer</returns>
  42. [DebuggerStepThrough]
  43. public static int mm256_extract_epi8(v256 a, int index)
  44. {
  45. return (&a.Byte0)[index & 31];
  46. }
  47. /// <summary>
  48. /// Extract a 16-bit integer from a, selected with index (which must be constant), and store the result in dst.
  49. /// </summary>
  50. /// <param name="a">Vector a</param>
  51. /// <param name="index">Index in the vector</param>
  52. /// <returns>Integer</returns>
  53. [DebuggerStepThrough]
  54. public static int mm256_extract_epi16(v256 a, int index)
  55. {
  56. return (&a.UShort0)[index & 15];
  57. }
  58. /// <summary>
  59. /// Copy the lower double-precision (64-bit) floating-point element of a to dst.
  60. /// </summary>
  61. /// <param name="a">Vector a</param>
  62. /// <returns>Double</returns>
  63. [DebuggerStepThrough]
  64. public static double mm256_cvtsd_f64(v256 a)
  65. {
  66. // Burst IR is fine here.
  67. return a.Double0;
  68. }
  69. /// <summary>
  70. /// Copy the lower 32-bit integer in a to dst.
  71. /// </summary>
  72. /// <param name="a">Vector a</param>
  73. /// <returns>Integer</returns>
  74. [DebuggerStepThrough]
  75. public static int mm256_cvtsi256_si32(v256 a)
  76. {
  77. // Burst IR is fine here.
  78. return a.SInt0;
  79. }
  80. /// <summary>
  81. /// Copy the lower 64-bit integer in a to dst.
  82. /// </summary>
  83. /// <param name="a">Vector a</param>
  84. /// <returns>64-bit integer</returns>
  85. [DebuggerStepThrough]
  86. public static long mm256_cvtsi256_si64(v256 a)
  87. {
  88. // Burst IR is fine here.
  89. return a.SLong0;
  90. }
  91. /// <summary>
  92. /// Compare packed 8-bit integers in a and b for equality, and store the results in dst.
  93. /// </summary>
  94. /// <param name="a">Vector a</param>
  95. /// <param name="b">Vector b</param>
  96. /// <returns>Vector</returns>
  97. [DebuggerStepThrough]
  98. public static v256 mm256_cmpeq_epi8(v256 a, v256 b)
  99. {
  100. return new v256(Sse2.cmpeq_epi8(a.Lo128, b.Lo128), Sse2.cmpeq_epi8(a.Hi128, b.Hi128));
  101. }
  102. /// <summary>
  103. /// Compare packed 16-bit integers in a and b for equality, and store the results in dst.
  104. /// </summary>
  105. /// <param name="a">Vector a</param>
  106. /// <param name="b">Vector b</param>
  107. /// <returns>Vector</returns>
  108. [DebuggerStepThrough]
  109. public static v256 mm256_cmpeq_epi16(v256 a, v256 b)
  110. {
  111. return new v256(Sse2.cmpeq_epi16(a.Lo128, b.Lo128), Sse2.cmpeq_epi16(a.Hi128, b.Hi128));
  112. }
  113. /// <summary>
  114. /// Compare packed 32-bit integers in a and b for equality, and store the results in dst.
  115. /// </summary>
  116. /// <param name="a">Vector a</param>
  117. /// <param name="b">Vector b</param>
  118. /// <returns>Vector</returns>
  119. [DebuggerStepThrough]
  120. public static v256 mm256_cmpeq_epi32(v256 a, v256 b)
  121. {
  122. return new v256(Sse2.cmpeq_epi32(a.Lo128, b.Lo128), Sse2.cmpeq_epi32(a.Hi128, b.Hi128));
  123. }
  124. /// <summary>
  125. /// Compare packed 64-bit integers in a and b for equality, and store the results in dst.
  126. /// </summary>
  127. /// <param name="a">Vector a</param>
  128. /// <param name="b">Vector b</param>
  129. /// <returns>Vector</returns>
  130. [DebuggerStepThrough]
  131. public static v256 mm256_cmpeq_epi64(v256 a, v256 b)
  132. {
  133. return new v256(Sse4_1.cmpeq_epi64(a.Lo128, b.Lo128), Sse4_1.cmpeq_epi64(a.Hi128, b.Hi128));
  134. }
  135. /// <summary>
  136. /// Compare packed 8-bit integers in a and b for greater-than, and store the results in dst.
  137. /// </summary>
  138. /// <param name="a">Vector a</param>
  139. /// <param name="b">Vector b</param>
  140. /// <returns>Vector</returns>
  141. [DebuggerStepThrough]
  142. public static v256 mm256_cmpgt_epi8(v256 a, v256 b)
  143. {
  144. return new v256(Sse2.cmpgt_epi8(a.Lo128, b.Lo128), Sse2.cmpgt_epi8(a.Hi128, b.Hi128));
  145. }
  146. /// <summary>
  147. /// Compare packed 16-bit integers in a and b for greater-than, and store the results in dst.
  148. /// </summary>
  149. /// <param name="a">Vector a</param>
  150. /// <param name="b">Vector b</param>
  151. /// <returns>Vector</returns>
  152. [DebuggerStepThrough]
  153. public static v256 mm256_cmpgt_epi16(v256 a, v256 b)
  154. {
  155. return new v256(Sse2.cmpgt_epi16(a.Lo128, b.Lo128), Sse2.cmpgt_epi16(a.Hi128, b.Hi128));
  156. }
  157. /// <summary>
  158. /// Compare packed 32-bit integers in a and b for greater-than, and store the results in dst.
  159. /// </summary>
  160. /// <param name="a">Vector a</param>
  161. /// <param name="b">Vector b</param>
  162. /// <returns>Vector</returns>
  163. [DebuggerStepThrough]
  164. public static v256 mm256_cmpgt_epi32(v256 a, v256 b)
  165. {
  166. return new v256(Sse2.cmpgt_epi32(a.Lo128, b.Lo128), Sse2.cmpgt_epi32(a.Hi128, b.Hi128));
  167. }
  168. /// <summary>
  169. /// Compare packed 64-bit integers in a and b for equality, and store the results in dst.
  170. /// </summary>
  171. /// <param name="a">Vector a</param>
  172. /// <param name="b">Vector b</param>
  173. /// <returns>Vector</returns>
  174. [DebuggerStepThrough]
  175. public static v256 mm256_cmpgt_epi64(v256 a, v256 b)
  176. {
  177. return new v256(Sse4_2.cmpgt_epi64(a.Lo128, b.Lo128), Sse4_2.cmpgt_epi64(a.Hi128, b.Hi128));
  178. }
  179. /// <summary>
  180. /// Compare packed 8-bit integers in a and b, and store packed maximum values in dst.
  181. /// </summary>
  182. /// <param name="a">Vector a</param>
  183. /// <param name="b">Vector b</param>
  184. /// <returns>Vector</returns>
  185. [DebuggerStepThrough]
  186. public static v256 mm256_max_epi8(v256 a, v256 b)
  187. {
  188. return new v256(Sse4_1.max_epi8(a.Lo128, b.Lo128), Sse4_1.max_epi8(a.Hi128, b.Hi128));
  189. }
  190. /// <summary>
  191. /// Compare packed 16-bit integers in a and b, and store packed maximum values in dst.
  192. /// </summary>
  193. /// <param name="a">Vector a</param>
  194. /// <param name="b">Vector b</param>
  195. /// <returns>Vector</returns>
  196. [DebuggerStepThrough]
  197. public static v256 mm256_max_epi16(v256 a, v256 b)
  198. {
  199. return new v256(Sse2.max_epi16(a.Lo128, b.Lo128), Sse2.max_epi16(a.Hi128, b.Hi128));
  200. }
  201. /// <summary>
  202. /// Compare packed 32-bit integers in a and b, and store packed maximum values in dst.
  203. /// </summary>
  204. /// <param name="a">Vector a</param>
  205. /// <param name="b">Vector b</param>
  206. /// <returns>Vector</returns>
  207. [DebuggerStepThrough]
  208. public static v256 mm256_max_epi32(v256 a, v256 b)
  209. {
  210. return new v256(Sse4_1.max_epi32(a.Lo128, b.Lo128), Sse4_1.max_epi32(a.Hi128, b.Hi128));
  211. }
  212. /// <summary>
  213. /// Compare packed unsigned 8-bit integers in a and b, and store packed maximum values in dst.
  214. /// </summary>
  215. /// <param name="a">Vector a</param>
  216. /// <param name="b">Vector b</param>
  217. /// <returns>Vector</returns>
  218. [DebuggerStepThrough]
  219. public static v256 mm256_max_epu8(v256 a, v256 b)
  220. {
  221. return new v256(Sse2.max_epu8(a.Lo128, b.Lo128), Sse2.max_epu8(a.Hi128, b.Hi128));
  222. }
  223. /// <summary>
  224. /// Compare packed unsigned 16-bit integers in a and b, and store packed maximum values in dst.
  225. /// </summary>
  226. /// <param name="a">Vector a</param>
  227. /// <param name="b">Vector b</param>
  228. /// <returns>Vector</returns>
  229. [DebuggerStepThrough]
  230. public static v256 mm256_max_epu16(v256 a, v256 b)
  231. {
  232. return new v256(Sse4_1.max_epu16(a.Lo128, b.Lo128), Sse4_1.max_epu16(a.Hi128, b.Hi128));
  233. }
  234. /// <summary>
  235. /// Compare packed unsigned 32-bit integers in a and b, and store packed maximum values in dst.
  236. /// </summary>
  237. /// <param name="a">Vector a</param>
  238. /// <param name="b">Vector b</param>
  239. /// <returns>Vector</returns>
  240. [DebuggerStepThrough]
  241. public static v256 mm256_max_epu32(v256 a, v256 b)
  242. {
  243. return new v256(Sse4_1.max_epu32(a.Lo128, b.Lo128), Sse4_1.max_epu32(a.Hi128, b.Hi128));
  244. }
  245. /// <summary>
  246. /// Compare packed 8-bit integers in a and b, and store packed minimum values in dst.
  247. /// </summary>
  248. /// <param name="a">Vector a</param>
  249. /// <param name="b">Vector b</param>
  250. /// <returns>Vector</returns>
  251. [DebuggerStepThrough]
  252. public static v256 mm256_min_epi8(v256 a, v256 b)
  253. {
  254. return new v256(Sse4_1.min_epi8(a.Lo128, b.Lo128), Sse4_1.min_epi8(a.Hi128, b.Hi128));
  255. }
  256. /// <summary>
  257. /// Compare packed 16-bit integers in a and b, and store packed minimum values in dst.
  258. /// </summary>
  259. /// <param name="a">Vector a</param>
  260. /// <param name="b">Vector b</param>
  261. /// <returns>Vector</returns>
  262. [DebuggerStepThrough]
  263. public static v256 mm256_min_epi16(v256 a, v256 b)
  264. {
  265. return new v256(Sse2.min_epi16(a.Lo128, b.Lo128), Sse2.min_epi16(a.Hi128, b.Hi128));
  266. }
  267. /// <summary>
  268. /// Compare packed 32-bit integers in a and b, and store packed minimum values in dst.
  269. /// </summary>
  270. /// <param name="a">Vector a</param>
  271. /// <param name="b">Vector b</param>
  272. /// <returns>Vector</returns>
  273. [DebuggerStepThrough]
  274. public static v256 mm256_min_epi32(v256 a, v256 b)
  275. {
  276. return new v256(Sse4_1.min_epi32(a.Lo128, b.Lo128), Sse4_1.min_epi32(a.Hi128, b.Hi128));
  277. }
  278. /// <summary>
  279. /// Compare packed unsigned 8-bit integers in a and b, and store packed minimum values in dst.
  280. /// </summary>
  281. /// <param name="a">Vector a</param>
  282. /// <param name="b">Vector b</param>
  283. /// <returns>Vector</returns>
  284. [DebuggerStepThrough]
  285. public static v256 mm256_min_epu8(v256 a, v256 b)
  286. {
  287. return new v256(Sse2.min_epu8(a.Lo128, b.Lo128), Sse2.min_epu8(a.Hi128, b.Hi128));
  288. }
  289. /// <summary>
  290. /// Compare packed unsigned 16-bit integers in a and b, and store packed minimum values in dst.
  291. /// </summary>
  292. /// <param name="a">Vector a</param>
  293. /// <param name="b">Vector b</param>
  294. /// <returns>Vector</returns>
  295. [DebuggerStepThrough]
  296. public static v256 mm256_min_epu16(v256 a, v256 b)
  297. {
  298. return new v256(Sse4_1.min_epu16(a.Lo128, b.Lo128), Sse4_1.min_epu16(a.Hi128, b.Hi128));
  299. }
  300. /// <summary>
  301. /// Compare packed unsigned 32-bit integers in a and b, and store packed minimum values in dst.
  302. /// </summary>
  303. /// <param name="a">Vector a</param>
  304. /// <param name="b">Vector b</param>
  305. /// <returns>Vector</returns>
  306. [DebuggerStepThrough]
  307. public static v256 mm256_min_epu32(v256 a, v256 b)
  308. {
  309. return new v256(Sse4_1.min_epu32(a.Lo128, b.Lo128), Sse4_1.min_epu32(a.Hi128, b.Hi128));
  310. }
  311. /// <summary>
  312. /// Compute the bitwise AND of 256 bits (representing integer data) in a and b, and store the result in dst.
  313. /// </summary>
  314. /// <param name="a">Vector a</param>
  315. /// <param name="b">Vector b</param>
  316. /// <returns>Vector</returns>
  317. [DebuggerStepThrough]
  318. public static v256 mm256_and_si256(v256 a, v256 b)
  319. {
  320. return new v256(Sse2.and_si128(a.Lo128, b.Lo128), Sse2.and_si128(a.Hi128, b.Hi128));
  321. }
  322. /// <summary>
  323. /// Compute the bitwise NOT of 256 bits (representing integer data) in a and then AND with b, and store the result in dst.
  324. /// </summary>
  325. /// <param name="a">Vector a</param>
  326. /// <param name="b">Vector b</param>
  327. /// <returns>Vector</returns>
  328. [DebuggerStepThrough]
  329. public static v256 mm256_andnot_si256(v256 a, v256 b)
  330. {
  331. return new v256(Sse2.andnot_si128(a.Lo128, b.Lo128), Sse2.andnot_si128(a.Hi128, b.Hi128));
  332. }
  333. /// <summary>
  334. /// Compute the bitwise OR of 256 bits (representing integer data) in a and b, and store the result in dst.
  335. /// </summary>
  336. /// <param name="a">Vector a</param>
  337. /// <param name="b">Vector b</param>
  338. /// <returns>Vector</returns>
  339. [DebuggerStepThrough]
  340. public static v256 mm256_or_si256(v256 a, v256 b)
  341. {
  342. return new v256(Sse2.or_si128(a.Lo128, b.Lo128), Sse2.or_si128(a.Hi128, b.Hi128));
  343. }
  344. /// <summary>
  345. /// Compute the bitwise XOR of 256 bits (representing integer data) in a and b, and store the result in dst.
  346. /// </summary>
  347. /// <param name="a">Vector a</param>
  348. /// <param name="b">Vector b</param>
  349. /// <returns>Vector</returns>
  350. [DebuggerStepThrough]
  351. public static v256 mm256_xor_si256(v256 a, v256 b)
  352. {
  353. return new v256(Sse2.xor_si128(a.Lo128, b.Lo128), Sse2.xor_si128(a.Hi128, b.Hi128));
  354. }
  355. /// <summary>
  356. /// Compute the absolute value of packed 8-bit integers in a, and store the unsigned results in dst.
  357. /// </summary>
  358. /// <param name="a">Vector a</param>
  359. /// <returns>Vector</returns>
  360. [DebuggerStepThrough]
  361. public static v256 mm256_abs_epi8(v256 a)
  362. {
  363. return new v256(Ssse3.abs_epi8(a.Lo128), Ssse3.abs_epi8(a.Hi128));
  364. }
  365. /// <summary>
  366. /// Compute the absolute value of packed 16-bit integers in a, and store the unsigned results in dst.
  367. /// </summary>
  368. /// <param name="a">Vector a</param>
  369. /// <returns>Vector</returns>
  370. [DebuggerStepThrough]
  371. public static v256 mm256_abs_epi16(v256 a)
  372. {
  373. return new v256(Ssse3.abs_epi16(a.Lo128), Ssse3.abs_epi16(a.Hi128));
  374. }
  375. /// <summary>
  376. /// Compute the absolute value of packed 32-bit integers in a, and store the unsigned results in dst.
  377. /// </summary>
  378. /// <param name="a">Vector a</param>
  379. /// <returns>Vector</returns>
  380. [DebuggerStepThrough]
  381. public static v256 mm256_abs_epi32(v256 a)
  382. {
  383. return new v256(Ssse3.abs_epi32(a.Lo128), Ssse3.abs_epi32(a.Hi128));
  384. }
  385. /// <summary>
  386. /// Add packed 8-bit integers in a and b, and store the results in dst.
  387. /// </summary>
  388. /// <param name="a">Vector a</param>
  389. /// <param name="b">Vector b</param>
  390. /// <returns>Vector</returns>
  391. [DebuggerStepThrough]
  392. public static v256 mm256_add_epi8(v256 a, v256 b)
  393. {
  394. return new v256(Sse2.add_epi8(a.Lo128, b.Lo128), Sse2.add_epi8(a.Hi128, b.Hi128));
  395. }
  396. /// <summary>
  397. /// Add packed 16-bit integers in a and b, and store the results in dst.
  398. /// </summary>
  399. /// <param name="a">Vector a</param>
  400. /// <param name="b">Vector b</param>
  401. /// <returns>Vector</returns>
  402. [DebuggerStepThrough]
  403. public static v256 mm256_add_epi16(v256 a, v256 b)
  404. {
  405. return new v256(Sse2.add_epi16(a.Lo128, b.Lo128), Sse2.add_epi16(a.Hi128, b.Hi128));
  406. }
  407. /// <summary>
  408. /// Add packed 32-bit integers in a and b, and store the results in dst.
  409. /// </summary>
  410. /// <param name="a">Vector a</param>
  411. /// <param name="b">Vector b</param>
  412. /// <returns>Vector</returns>
  413. [DebuggerStepThrough]
  414. public static v256 mm256_add_epi32(v256 a, v256 b)
  415. {
  416. return new v256(Sse2.add_epi32(a.Lo128, b.Lo128), Sse2.add_epi32(a.Hi128, b.Hi128));
  417. }
  418. /// <summary>
  419. /// Add packed 64-bit integers in a and b, and store the results in dst.
  420. /// </summary>
  421. /// <param name="a">Vector a</param>
  422. /// <param name="b">Vector b</param>
  423. /// <returns>Vector</returns>
  424. [DebuggerStepThrough]
  425. public static v256 mm256_add_epi64(v256 a, v256 b)
  426. {
  427. return new v256(Sse2.add_epi64(a.Lo128, b.Lo128), Sse2.add_epi64(a.Hi128, b.Hi128));
  428. }
  429. /// <summary>
  430. /// Add packed 8-bit integers in a and b using saturation, and store the results in dst.
  431. /// </summary>
  432. /// <param name="a">Vector a</param>
  433. /// <param name="b">Vector b</param>
  434. /// <returns>Vector</returns>
  435. [DebuggerStepThrough]
  436. public static v256 mm256_adds_epi8(v256 a, v256 b)
  437. {
  438. return new v256(Sse2.adds_epi8(a.Lo128, b.Lo128), Sse2.adds_epi8(a.Hi128, b.Hi128));
  439. }
  440. /// <summary>
  441. /// Add packed 16-bit integers in a and b using saturation, and store the results in dst.
  442. /// </summary>
  443. /// <param name="a">Vector a</param>
  444. /// <param name="b">Vector b</param>
  445. /// <returns>Vector</returns>
  446. [DebuggerStepThrough]
  447. public static v256 mm256_adds_epi16(v256 a, v256 b)
  448. {
  449. return new v256(Sse2.adds_epi16(a.Lo128, b.Lo128), Sse2.adds_epi16(a.Hi128, b.Hi128));
  450. }
  451. /// <summary>
  452. /// Add packed unsigned 8-bit integers in a and b using saturation, and store the results in dst.
  453. /// </summary>
  454. /// <param name="a">Vector a</param>
  455. /// <param name="b">Vector b</param>
  456. /// <returns>Vector</returns>
  457. [DebuggerStepThrough]
  458. public static v256 mm256_adds_epu8(v256 a, v256 b)
  459. {
  460. return new v256(Sse2.adds_epu8(a.Lo128, b.Lo128), Sse2.adds_epu8(a.Hi128, b.Hi128));
  461. }
  462. /// <summary>
  463. /// Add packed unsigned 16-bit integers in a and b using saturation, and store the results in dst.
  464. /// </summary>
  465. /// <param name="a">Vector a</param>
  466. /// <param name="b">Vector b</param>
  467. /// <returns>Vector</returns>
  468. [DebuggerStepThrough]
  469. public static v256 mm256_adds_epu16(v256 a, v256 b)
  470. {
  471. return new v256(Sse2.adds_epu16(a.Lo128, b.Lo128), Sse2.adds_epu16(a.Hi128, b.Hi128));
  472. }
  473. /// <summary>
  474. /// Subtract packed 8-bit integers in a and b, and store the results in dst.
  475. /// </summary>
  476. /// <param name="a">Vector a</param>
  477. /// <param name="b">Vector b</param>
  478. /// <returns>Vector</returns>
  479. [DebuggerStepThrough]
  480. public static v256 mm256_sub_epi8(v256 a, v256 b)
  481. {
  482. return new v256(Sse2.sub_epi8(a.Lo128, b.Lo128), Sse2.sub_epi8(a.Hi128, b.Hi128));
  483. }
  484. /// <summary>
  485. /// Subtract packed 16-bit integers in a and b, and store the results in dst.
  486. /// </summary>
  487. /// <param name="a">Vector a</param>
  488. /// <param name="b">Vector b</param>
  489. /// <returns>Vector</returns>
  490. [DebuggerStepThrough]
  491. public static v256 mm256_sub_epi16(v256 a, v256 b)
  492. {
  493. return new v256(Sse2.sub_epi16(a.Lo128, b.Lo128), Sse2.sub_epi16(a.Hi128, b.Hi128));
  494. }
  495. /// <summary>
  496. /// Subtract packed 32-bit integers in a and b, and store the results in dst.
  497. /// </summary>
  498. /// <param name="a">Vector a</param>
  499. /// <param name="b">Vector b</param>
  500. /// <returns>Vector</returns>
  501. [DebuggerStepThrough]
  502. public static v256 mm256_sub_epi32(v256 a, v256 b)
  503. {
  504. return new v256(Sse2.sub_epi32(a.Lo128, b.Lo128), Sse2.sub_epi32(a.Hi128, b.Hi128));
  505. }
  506. /// <summary>
  507. /// Subtract packed 64-bit integers in a and b, and store the results in dst.
  508. /// </summary>
  509. /// <param name="a">Vector a</param>
  510. /// <param name="b">Vector b</param>
  511. /// <returns>Vector</returns>
  512. [DebuggerStepThrough]
  513. public static v256 mm256_sub_epi64(v256 a, v256 b)
  514. {
  515. return new v256(Sse2.sub_epi64(a.Lo128, b.Lo128), Sse2.sub_epi64(a.Hi128, b.Hi128));
  516. }
  517. /// <summary>
  518. /// Subtract packed 8-bit integers in a and b using saturation, and store the results in dst.
  519. /// </summary>
  520. /// <param name="a">Vector a</param>
  521. /// <param name="b">Vector b</param>
  522. /// <returns>Vector</returns>
  523. [DebuggerStepThrough]
  524. public static v256 mm256_subs_epi8(v256 a, v256 b)
  525. {
  526. return new v256(Sse2.subs_epi8(a.Lo128, b.Lo128), Sse2.subs_epi8(a.Hi128, b.Hi128));
  527. }
  528. /// <summary>
  529. /// Subtract packed 16-bit integers in a and b using saturation, and store the results in dst.
  530. /// </summary>
  531. /// <param name="a">Vector a</param>
  532. /// <param name="b">Vector b</param>
  533. /// <returns>Vector</returns>
  534. [DebuggerStepThrough]
  535. public static v256 mm256_subs_epi16(v256 a, v256 b)
  536. {
  537. return new v256(Sse2.subs_epi16(a.Lo128, b.Lo128), Sse2.subs_epi16(a.Hi128, b.Hi128));
  538. }
  539. /// <summary>
  540. /// Subtract packed unsigned 8-bit integers in a and b using saturation, and store the results in dst.
  541. /// </summary>
  542. /// <param name="a">Vector a</param>
  543. /// <param name="b">Vector b</param>
  544. /// <returns>Vector</returns>
  545. [DebuggerStepThrough]
  546. public static v256 mm256_subs_epu8(v256 a, v256 b)
  547. {
  548. return new v256(Sse2.subs_epu8(a.Lo128, b.Lo128), Sse2.subs_epu8(a.Hi128, b.Hi128));
  549. }
  550. /// <summary>
  551. /// Subtract packed unsigned 16-bit integers in a and b using saturation, and store the results in dst.
  552. /// </summary>
  553. /// <param name="a">Vector a</param>
  554. /// <param name="b">Vector b</param>
  555. /// <returns>Vector</returns>
  556. [DebuggerStepThrough]
  557. public static v256 mm256_subs_epu16(v256 a, v256 b)
  558. {
  559. return new v256(Sse2.subs_epu16(a.Lo128, b.Lo128), Sse2.subs_epu16(a.Hi128, b.Hi128));
  560. }
  561. /// <summary>
  562. /// Average packed unsigned 8-bit integers in a and b, and store the results in dst.
  563. /// </summary>
  564. /// <param name="a">Vector a</param>
  565. /// <param name="b">Vector b</param>
  566. /// <returns>Vector</returns>
  567. [DebuggerStepThrough]
  568. public static v256 mm256_avg_epu8(v256 a, v256 b)
  569. {
  570. return new v256(Sse2.avg_epu8(a.Lo128, b.Lo128), Sse2.avg_epu8(a.Hi128, b.Hi128));
  571. }
  572. /// <summary>
  573. /// Average packed unsigned 16-bit integers in a and b, and store the results in dst.
  574. /// </summary>
  575. /// <param name="a">Vector a</param>
  576. /// <param name="b">Vector b</param>
  577. /// <returns>Vector</returns>
  578. [DebuggerStepThrough]
  579. public static v256 mm256_avg_epu16(v256 a, v256 b)
  580. {
  581. return new v256(Sse2.avg_epu16(a.Lo128, b.Lo128), Sse2.avg_epu16(a.Hi128, b.Hi128));
  582. }
  583. /// <summary>
  584. /// Horizontally add adjacent pairs of 16-bit integers in a and b, and pack the signed 16-bit results in dst.
  585. /// </summary>
  586. /// <param name="a">Vector a</param>
  587. /// <param name="b">Vector b</param>
  588. /// <returns>Vector</returns>
  589. [DebuggerStepThrough]
  590. public static v256 mm256_hadd_epi16(v256 a, v256 b)
  591. {
  592. return new v256(Ssse3.hadd_epi16(a.Lo128, b.Lo128), Ssse3.hadd_epi16(a.Hi128, b.Hi128));
  593. }
  594. /// <summary>
  595. /// Horizontally add adjacent pairs of 32-bit integers in a and b, and pack the signed 16-bit results in dst.
  596. /// </summary>
  597. /// <param name="a">Vector a</param>
  598. /// <param name="b">Vector b</param>
  599. /// <returns>Vector</returns>
  600. [DebuggerStepThrough]
  601. public static v256 mm256_hadd_epi32(v256 a, v256 b)
  602. {
  603. return new v256(Ssse3.hadd_epi32(a.Lo128, b.Lo128), Ssse3.hadd_epi32(a.Hi128, b.Hi128));
  604. }
  605. /// <summary>
  606. /// Horizontally add adjacent pairs of 16-bit integers in a and b using saturation, and pack the signed 16-bit results in dst.
  607. /// </summary>
  608. /// <param name="a">Vector a</param>
  609. /// <param name="b">Vector b</param>
  610. /// <returns>Vector</returns>
  611. [DebuggerStepThrough]
  612. public static v256 mm256_hadds_epi16(v256 a, v256 b)
  613. {
  614. return new v256(Ssse3.hadds_epi16(a.Lo128, b.Lo128), Ssse3.hadds_epi16(a.Hi128, b.Hi128));
  615. }
  616. /// <summary>
  617. /// Horizontally subtract adjacent pairs of 16-bit integers in a and b, and pack the signed 16-bit results in dst.
  618. /// </summary>
  619. /// <param name="a">Vector a</param>
  620. /// <param name="b">Vector b</param>
  621. /// <returns>Vector</returns>
  622. [DebuggerStepThrough]
  623. public static v256 mm256_hsub_epi16(v256 a, v256 b)
  624. {
  625. return new v256(Ssse3.hsub_epi16(a.Lo128, b.Lo128), Ssse3.hsub_epi16(a.Hi128, b.Hi128));
  626. }
  627. /// <summary>
  628. /// Horizontally subtract adjacent pairs of 32-bit integers in a and b, and pack the signed 16-bit results in dst.
  629. /// </summary>
  630. /// <param name="a">Vector a</param>
  631. /// <param name="b">Vector b</param>
  632. /// <returns>Vector</returns>
  633. [DebuggerStepThrough]
  634. public static v256 mm256_hsub_epi32(v256 a, v256 b)
  635. {
  636. return new v256(Ssse3.hsub_epi32(a.Lo128, b.Lo128), Ssse3.hsub_epi32(a.Hi128, b.Hi128));
  637. }
  638. /// <summary>
  639. /// Horizontally subtract adjacent pairs of 16-bit integers in a and b using saturation, and pack the signed 16-bit results in dst.
  640. /// </summary>
  641. /// <param name="a">Vector a</param>
  642. /// <param name="b">Vector b</param>
  643. /// <returns>Vector</returns>
  644. [DebuggerStepThrough]
  645. public static v256 mm256_hsubs_epi16(v256 a, v256 b)
  646. {
  647. return new v256(Ssse3.hsubs_epi16(a.Lo128, b.Lo128), Ssse3.hsubs_epi16(a.Hi128, b.Hi128));
  648. }
  649. /// <summary>
  650. /// Multiply packed signed 16-bit integers in a and b, producing
  651. /// intermediate signed 32-bit integers. Horizontally add adjacent
  652. /// pairs of intermediate 32-bit integers, and pack the results in dst.
  653. /// </summary>
  654. /// <param name="a">Vector a</param>
  655. /// <param name="b">Vector b</param>
  656. /// <returns>Vector</returns>
  657. [DebuggerStepThrough]
  658. public static v256 mm256_madd_epi16(v256 a, v256 b)
  659. {
  660. return new v256(Sse2.madd_epi16(a.Lo128, b.Lo128), Sse2.madd_epi16(a.Hi128, b.Hi128));
  661. }
  662. /// <summary>
  663. /// Vertically multiply each unsigned 8-bit integer from a with the
  664. /// corresponding signed 8-bit integer from b, producing
  665. /// intermediate signed 16-bit integers. Horizontally add adjacent
  666. /// pairs of intermediate signed 16-bit integers, and pack the
  667. /// saturated results in dst.
  668. /// </summary>
  669. /// <param name="a">Vector a</param>
  670. /// <param name="b">Vector b</param>
  671. /// <returns>Vector</returns>
  672. [DebuggerStepThrough]
  673. public static v256 mm256_maddubs_epi16(v256 a, v256 b)
  674. {
  675. return new v256(Ssse3.maddubs_epi16(a.Lo128, b.Lo128), Ssse3.maddubs_epi16(a.Hi128, b.Hi128));
  676. }
  677. /// <summary>
  678. /// Multiply the packed 16-bit integers in a and b, producing intermediate 32-bit integers, and store the high 16 bits of the intermediate integers in dst.
  679. /// </summary>
  680. /// <param name="a">Vector a</param>
  681. /// <param name="b">Vector b</param>
  682. /// <returns>Vector</returns>
  683. [DebuggerStepThrough]
  684. public static v256 mm256_mulhi_epi16(v256 a, v256 b)
  685. {
  686. return new v256(Sse2.mulhi_epi16(a.Lo128, b.Lo128), Sse2.mulhi_epi16(a.Hi128, b.Hi128));
  687. }
  688. /// <summary>
  689. /// Multiply the packed unsigned 16-bit integers in a and b,
  690. /// producing intermediate 32-bit integers, and store the high 16
  691. /// bits of the intermediate integers in dst.
  692. /// </summary>
  693. /// <param name="a">Vector a</param>
  694. /// <param name="b">Vector b</param>
  695. /// <returns>Vector</returns>
  696. [DebuggerStepThrough]
  697. public static v256 mm256_mulhi_epu16(v256 a, v256 b)
  698. {
  699. return new v256(Sse2.mulhi_epu16(a.Lo128, b.Lo128), Sse2.mulhi_epu16(a.Hi128, b.Hi128));
  700. }
  701. /// <summary>
  702. /// Multiply the packed 16-bit integers in a and b, producing
  703. /// intermediate 32-bit integers, and store the low 16 bits of the
  704. /// intermediate integers in dst.
  705. /// </summary>
  706. /// <param name="a">Vector a</param>
  707. /// <param name="b">Vector b</param>
  708. /// <returns>Vector</returns>
  709. [DebuggerStepThrough]
  710. public static v256 mm256_mullo_epi16(v256 a, v256 b)
  711. {
  712. return new v256(Sse2.mullo_epi16(a.Lo128, b.Lo128), Sse2.mullo_epi16(a.Hi128, b.Hi128));
  713. }
  714. /// <summary>
  715. /// Multiply the packed 32-bit integers in a and b, producing
  716. /// intermediate 64-bit integers, and store the low 32 bits of the
  717. /// intermediate integers in dst.
  718. /// </summary>
  719. /// <param name="a">Vector a</param>
  720. /// <param name="b">Vector b</param>
  721. /// <returns>Vector</returns>
  722. [DebuggerStepThrough]
  723. public static v256 mm256_mullo_epi32(v256 a, v256 b)
  724. {
  725. return new v256(Sse4_1.mullo_epi32(a.Lo128, b.Lo128), Sse4_1.mullo_epi32(a.Hi128, b.Hi128));
  726. }
  727. /// <summary>
  728. /// Multiply the low unsigned 32-bit integers from each packed 64-bit element in a and b, and store the unsigned 64-bit results in dst.
  729. /// </summary>
  730. /// <param name="a">Vector a</param>
  731. /// <param name="b">Vector b</param>
  732. /// <returns>Vector</returns>
  733. [DebuggerStepThrough]
  734. public static v256 mm256_mul_epu32(v256 a, v256 b)
  735. {
  736. return new v256(Sse2.mul_epu32(a.Lo128, b.Lo128), Sse2.mul_epu32(a.Hi128, b.Hi128));
  737. }
  738. /// <summary>
  739. /// Multiply the low 32-bit integers from each packed 64-bit element in a and b, and store the signed 64-bit results in dst.
  740. /// </summary>
  741. /// <param name="a">Vector a</param>
  742. /// <param name="b">Vector b</param>
  743. /// <returns>Vector</returns>
  744. [DebuggerStepThrough]
  745. public static v256 mm256_mul_epi32(v256 a, v256 b)
  746. {
  747. return new v256(Sse4_1.mul_epi32(a.Lo128, b.Lo128), Sse4_1.mul_epi32(a.Hi128, b.Hi128));
  748. }
  749. /// <summary>
  750. /// Negate packed 8-bit integers in a when the corresponding signed
  751. /// 8-bit integer in b is negative, and store the results in dst.
  752. /// Element in dst are zeroed out when the corresponding element in
  753. /// b is zero.
  754. /// </summary>
  755. /// <param name="a">Vector a</param>
  756. /// <param name="b">Vector b</param>
  757. /// <returns>Vector</returns>
  758. [DebuggerStepThrough]
  759. public static v256 mm256_sign_epi8(v256 a, v256 b)
  760. {
  761. return new v256(Ssse3.sign_epi8(a.Lo128, b.Lo128), Ssse3.sign_epi8(a.Hi128, b.Hi128));
  762. }
  763. /// <summary>
  764. /// Negate packed 16-bit integers in a when the corresponding signed
  765. /// 16-bit integer in b is negative, and store the results in dst.
  766. /// Element in dst are zeroed out when the corresponding element in
  767. /// b is zero.
  768. /// </summary>
  769. /// <param name="a">Vector a</param>
  770. /// <param name="b">Vector b</param>
  771. /// <returns>Vector</returns>
  772. [DebuggerStepThrough]
  773. public static v256 mm256_sign_epi16(v256 a, v256 b)
  774. {
  775. return new v256(Ssse3.sign_epi16(a.Lo128, b.Lo128), Ssse3.sign_epi16(a.Hi128, b.Hi128));
  776. }
  777. /// <summary>
  778. /// Negate packed 32-bit integers in a when the corresponding signed
  779. /// 32-bit integer in b is negative, and store the results in dst.
  780. /// Element in dst are zeroed out when the corresponding element in
  781. /// b is zero.
  782. /// </summary>
  783. /// <param name="a">Vector a</param>
  784. /// <param name="b">Vector b</param>
  785. /// <returns>Vector</returns>
  786. [DebuggerStepThrough]
  787. public static v256 mm256_sign_epi32(v256 a, v256 b)
  788. {
  789. return new v256(Ssse3.sign_epi32(a.Lo128, b.Lo128), Ssse3.sign_epi32(a.Hi128, b.Hi128));
  790. }
  791. /// <summary>
  792. /// Multiply packed 16-bit integers in a and b, producing
  793. /// intermediate signed 32-bit integers. Truncate each intermediate
  794. /// integer to the 18 most significant bits, round by adding 1, and
  795. /// store bits [16:1] to dst.
  796. /// </summary>
  797. /// <param name="a">Vector a</param>
  798. /// <param name="b">Vector b</param>
  799. /// <returns>Vector</returns>
  800. [DebuggerStepThrough]
  801. public static v256 mm256_mulhrs_epi16(v256 a, v256 b)
  802. {
  803. return new v256(Ssse3.mulhrs_epi16(a.Lo128, b.Lo128), Ssse3.mulhrs_epi16(a.Hi128, b.Hi128));
  804. }
  805. /// <summary>
  806. /// Compute the absolute differences of packed unsigned 8-bit
  807. /// integers in a and b, then horizontally sum each consecutive 8
  808. /// differences to produce four unsigned 16-bit integers, and pack
  809. /// these unsigned 16-bit integers in the low 16 bits of 64-bit
  810. /// elements in dst.
  811. /// </summary>
  812. /// <param name="a">Vector a</param>
  813. /// <param name="b">Vector b</param>
  814. /// <returns>Vector</returns>
  815. [DebuggerStepThrough]
  816. public static v256 mm256_sad_epu8(v256 a, v256 b)
  817. {
  818. return new v256(Sse2.sad_epu8(a.Lo128, b.Lo128), Sse2.sad_epu8(a.Hi128, b.Hi128));
  819. }
  820. /// <summary>
  821. /// Compute the sum of absolute differences (SADs) of quadruplets of
  822. /// unsigned 8-bit integers in a compared to those in b, and store
  823. /// the 16-bit results in dst. Eight SADs are performed for each
  824. /// 128-bit lane using one quadruplet from b and eight quadruplets
  825. /// from a. One quadruplet is selected from b starting at on the
  826. /// offset specified in imm8. Eight quadruplets are formed from
  827. /// sequential 8-bit integers selected from a starting at the offset
  828. /// specified in imm8.
  829. /// </summary>
  830. /// <param name="a">Vector a</param>
  831. /// <param name="b">Vector b</param>
  832. /// <param name="imm8">Offset</param>
  833. /// <returns>Vector</returns>
  834. [DebuggerStepThrough]
  835. public static v256 mm256_mpsadbw_epu8(v256 a, v256 b, int imm8)
  836. {
  837. return new v256(Sse4_1.mpsadbw_epu8(a.Lo128, b.Lo128, imm8 & 7), Sse4_1.mpsadbw_epu8(a.Hi128, b.Hi128, (imm8 >> 3) & 7));
  838. }
  839. /// <summary>
  840. /// Shift 128-bit lanes in a left by imm8 bytes while shifting in zeros, and store the results in dst.
  841. /// </summary>
  842. /// <param name="a">Vector a</param>
  843. /// <param name="imm8">Offset</param>
  844. /// <returns>Vector</returns>
  845. [DebuggerStepThrough]
  846. public static v256 mm256_slli_si256(v256 a, int imm8)
  847. {
  848. return new v256(Sse2.slli_si128(a.Lo128, imm8), Sse2.slli_si128(a.Hi128, imm8));
  849. }
  850. // This is just a #define alias
  851. /// <summary>
  852. /// Shift 128-bit lanes in a left by imm8 bytes while shifting in zeros, and store the results in dst.
  853. /// </summary>
  854. /// <param name="a">Vector a</param>
  855. /// <param name="imm8">Offset</param>
  856. /// <returns>Vector</returns>
  857. [DebuggerStepThrough]
  858. public static v256 mm256_bslli_epi128(v256 a, int imm8)
  859. {
  860. return mm256_slli_si256(a, imm8);
  861. }
  862. /// <summary>
  863. /// Shift 128-bit lanes in a right by imm8 bytes while shifting in zeros, and store the results in dst.
  864. /// </summary>
  865. /// <param name="a">Vector a</param>
  866. /// <param name="imm8">Offset</param>
  867. /// <returns>Vector</returns>
  868. [DebuggerStepThrough]
  869. public static v256 mm256_srli_si256(v256 a, int imm8)
  870. {
  871. return new v256(Sse2.srli_si128(a.Lo128, imm8), Sse2.srli_si128(a.Hi128, imm8));
  872. }
  873. // This is just a #define alias
  874. /// <summary>
  875. /// Shift 128-bit lanes in a right by imm8 bytes while shifting in zeros, and store the results in dst.
  876. /// </summary>
  877. /// <param name="a">Vector a</param>
  878. /// <param name="imm8">Offset</param>
  879. /// <returns>Vector</returns>
  880. [DebuggerStepThrough]
  881. public static v256 mm256_bsrli_epi128(v256 a, int imm8)
  882. {
  883. return mm256_srli_si256(a, imm8);
  884. }
  885. /// <summary>
  886. /// Shift packed 16-bit integers in a left by count while shifting
  887. /// in zeros, and store the results in dst.
  888. /// </summary>
  889. /// <param name="a">Vector a</param>
  890. /// <param name="count">Shift amount</param>
  891. /// <returns>Vector</returns>
  892. [DebuggerStepThrough]
  893. public static v256 mm256_sll_epi16(v256 a, v128 count)
  894. {
  895. return new v256(Sse2.sll_epi16(a.Lo128, count), Sse2.sll_epi16(a.Hi128, count));
  896. }
  897. /// <summary>
  898. /// Shift packed 32-bit integers in a left by count while shifting
  899. /// in zeros, and store the results in dst.
  900. /// </summary>
  901. /// <param name="a">Vector a</param>
  902. /// <param name="count">Offset</param>
  903. /// <returns>Vector</returns>
  904. [DebuggerStepThrough]
  905. public static v256 mm256_sll_epi32(v256 a, v128 count)
  906. {
  907. return new v256(Sse2.sll_epi32(a.Lo128, count), Sse2.sll_epi32(a.Hi128, count));
  908. }
  909. /// <summary>
  910. /// Shift packed 64-bit integers in a left by count while shifting
  911. /// in zeros, and store the results in dst.
  912. /// </summary>
  913. /// <param name="a">Vector a</param>
  914. /// <param name="count">Offset</param>
  915. /// <returns>Vector</returns>
  916. [DebuggerStepThrough]
  917. public static v256 mm256_sll_epi64(v256 a, v128 count)
  918. {
  919. return new v256(Sse2.sll_epi64(a.Lo128, count), Sse2.sll_epi64(a.Hi128, count));
  920. }
  921. /// <summary>
  922. /// Shift packed 16-bit integers in a left by imm8 while shifting in zeros, and store the results in dst.
  923. /// </summary>
  924. /// <param name="a">Vector a</param>
  925. /// <param name="imm8">Offset</param>
  926. /// <returns>Vector</returns>
  927. [DebuggerStepThrough]
  928. public static v256 mm256_slli_epi16(v256 a, int imm8)
  929. {
  930. return new v256(Sse2.slli_epi16(a.Lo128, imm8), Sse2.slli_epi16(a.Hi128, imm8));
  931. }
  932. /// <summary>
  933. /// Shift packed 32-bit integers in a left by imm8 while shifting in zeros, and store the results in dst.
  934. /// </summary>
  935. /// <param name="a">Vector a</param>
  936. /// <param name="imm8">Offset</param>
  937. /// <returns>Vector</returns>
  938. [DebuggerStepThrough]
  939. public static v256 mm256_slli_epi32(v256 a, int imm8)
  940. {
  941. return new v256(Sse2.slli_epi32(a.Lo128, imm8), Sse2.slli_epi32(a.Hi128, imm8));
  942. }
  943. /// <summary>
  944. /// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst.
  945. /// </summary>
  946. /// <param name="a">Vector a</param>
  947. /// <param name="imm8">Offset</param>
  948. /// <returns>Vector</returns>
  949. [DebuggerStepThrough]
  950. public static v256 mm256_slli_epi64(v256 a, int imm8)
  951. {
  952. return new v256(Sse2.slli_epi64(a.Lo128, imm8), Sse2.slli_epi64(a.Hi128, imm8));
  953. }
  954. /// <summary>
  955. /// Shift packed 32-bit integers in a left by the amount specified
  956. /// by the corresponding element in count while shifting in zeros,
  957. /// and store the results in dst.
  958. /// </summary>
  959. /// <param name="a">Vector a</param>
  960. /// <param name="count">Corresponding element</param>
  961. /// <returns>Vector</returns>
  962. [DebuggerStepThrough]
  963. public static v256 mm256_sllv_epi32(v256 a, v256 count)
  964. {
  965. return new v256(sllv_epi32(a.Lo128, count.Lo128), sllv_epi32(a.Hi128, count.Hi128));
  966. }
  967. /// <summary>
  968. /// Shift packed 64-bit integers in a left by the amount specified
  969. /// by the corresponding element in count while shifting in zeros,
  970. /// and store the results in dst.
  971. /// </summary>
  972. /// <param name="a">Vector a</param>
  973. /// <param name="count">Corresponding element</param>
  974. /// <returns>Vector</returns>
  975. [DebuggerStepThrough]
  976. public static v256 mm256_sllv_epi64(v256 a, v256 count)
  977. {
  978. return new v256(sllv_epi64(a.Lo128, count.Lo128), sllv_epi64(a.Hi128, count.Hi128));
  979. }
  980. /// <summary>
  981. /// Shift packed 32-bit integers in a left by the amount specified
  982. /// by the corresponding element in count while shifting in zeros,
  983. /// and store the results in dst.
  984. /// </summary>
  985. /// <param name="a">Vector a</param>
  986. /// <param name="count">Corresponding element</param>
  987. /// <returns>Vector</returns>
  988. [DebuggerStepThrough]
  989. public static v128 sllv_epi32(v128 a, v128 count)
  990. {
  991. v128 dst = default;
  992. uint* aptr = &a.UInt0;
  993. uint* dptr = &dst.UInt0;
  994. int* sptr = &count.SInt0;
  995. for (int i = 0; i < 4; ++i)
  996. {
  997. int shift = sptr[i];
  998. if (shift >= 0 && shift <= 31)
  999. {
  1000. dptr[i] = aptr[i] << shift;
  1001. }
  1002. else
  1003. {
  1004. dptr[i] = 0;
  1005. }
  1006. }
  1007. return dst;
  1008. }
  1009. /// <summary>
  1010. /// Shift packed 64-bit integers in a left by the amount specified
  1011. /// by the corresponding element in count while shifting in zeros,
  1012. /// and store the results in dst.
  1013. /// </summary>
  1014. /// <param name="a">Vector a</param>
  1015. /// <param name="count">Corresponding element</param>
  1016. /// <returns>Vector</returns>
  1017. [DebuggerStepThrough]
  1018. public static v128 sllv_epi64(v128 a, v128 count)
  1019. {
  1020. v128 dst = default;
  1021. ulong* aptr = &a.ULong0;
  1022. ulong* dptr = &dst.ULong0;
  1023. long* sptr = &count.SLong0;
  1024. for (int i = 0; i < 2; ++i)
  1025. {
  1026. int shift = (int)sptr[i];
  1027. if (shift >= 0 && shift <= 63)
  1028. {
  1029. dptr[i] = aptr[i] << shift;
  1030. }
  1031. else
  1032. {
  1033. dptr[i] = 0;
  1034. }
  1035. }
  1036. return dst;
  1037. }
  1038. /// <summary>
  1039. /// Shift packed 16-bit integers in a right by count while shifting in sign bits, and store the results in dst.
  1040. /// </summary>
  1041. /// <param name="a">Vector a</param>
  1042. /// <param name="count">Offset</param>
  1043. /// <returns>Vector</returns>
  1044. [DebuggerStepThrough]
  1045. public static v256 mm256_sra_epi16(v256 a, v128 count)
  1046. {
  1047. return new v256(Sse2.sra_epi16(a.Lo128, count), Sse2.sra_epi16(a.Hi128, count));
  1048. }
  1049. /// <summary>
  1050. /// Shift packed 32-bit integers in a right by count while shifting in sign bits, and store the results in dst.
  1051. /// </summary>
  1052. /// <param name="a">Vector a</param>
  1053. /// <param name="count">Offset</param>
  1054. /// <returns>Vector</returns>
  1055. [DebuggerStepThrough]
  1056. public static v256 mm256_sra_epi32(v256 a, v128 count)
  1057. {
  1058. return new v256(Sse2.sra_epi32(a.Lo128, count), Sse2.sra_epi32(a.Hi128, count));
  1059. }
  1060. /// <summary>
  1061. /// Shift packed 16-bit integers in a right by imm8 while shifting in sign bits, and store the results in dst.
  1062. /// </summary>
  1063. /// <param name="a">Vector a</param>
  1064. /// <param name="imm8">Offset</param>
  1065. /// <returns>Vector</returns>
  1066. [DebuggerStepThrough]
  1067. public static v256 mm256_srai_epi16(v256 a, int imm8)
  1068. {
  1069. return new v256(Sse2.srai_epi16(a.Lo128, imm8), Sse2.srai_epi16(a.Hi128, imm8));
  1070. }
  1071. /// <summary>
  1072. /// Shift packed 32-bit integers in a right by imm8 while shifting in sign bits, and store the results in dst.
  1073. /// </summary>
  1074. /// <param name="a">Vector a</param>
  1075. /// <param name="imm8">Offset</param>
  1076. /// <returns>Vector</returns>
  1077. [DebuggerStepThrough]
  1078. public static v256 mm256_srai_epi32(v256 a, int imm8)
  1079. {
  1080. return new v256(Sse2.srai_epi32(a.Lo128, imm8), Sse2.srai_epi32(a.Hi128, imm8));
  1081. }
  1082. /// <summary>
  1083. /// Shift packed 32-bit integers in a right by the amount specified
  1084. /// by the corresponding element in count while shifting in sign
  1085. /// bits, and store the results in dst.
  1086. /// </summary>
  1087. /// <param name="a">Vector a</param>
  1088. /// <param name="count">Corresponding element</param>
  1089. /// <returns>Vector</returns>
  1090. [DebuggerStepThrough]
  1091. public static v256 mm256_srav_epi32(v256 a, v256 count)
  1092. {
  1093. return new v256(srav_epi32(a.Lo128, count.Lo128), srav_epi32(a.Hi128, count.Hi128));
  1094. }
  1095. /// <summary>
  1096. /// Shift packed 32-bit integers in a right by the amount specified
  1097. /// by the corresponding element in count while shifting in sign
  1098. /// bits, and store the results in dst.
  1099. /// </summary>
  1100. /// <param name="a">Vector a</param>
  1101. /// <param name="count">Corresponding element</param>
  1102. /// <returns>Vector</returns>
  1103. [DebuggerStepThrough]
  1104. public static v128 srav_epi32(v128 a, v128 count)
  1105. {
  1106. v128 dst = default;
  1107. int* aptr = &a.SInt0;
  1108. int* dptr = &dst.SInt0;
  1109. int* sptr = &count.SInt0;
  1110. for (int i = 0; i < 4; ++i)
  1111. {
  1112. // Work around modulo 32 shifts on the general register file
  1113. int shift1 = Math.Min(sptr[i] & 0xff, 32);
  1114. int shift2 = 0;
  1115. if (shift1 >= 16)
  1116. {
  1117. shift1 -= 16;
  1118. shift2 += 16;
  1119. }
  1120. dptr[i] = (aptr[i] >> shift1) >> shift2;
  1121. }
  1122. return dst;
  1123. }
  1124. /// <summary>
  1125. /// Shift packed 16-bit integers in a right by count while shifting
  1126. /// in zeros, and store the results in dst.
  1127. /// </summary>
  1128. /// <param name="a">Vector a</param>
  1129. /// <param name="count">Offset</param>
  1130. /// <returns>Vector</returns>
  1131. [DebuggerStepThrough]
  1132. public static v256 mm256_srl_epi16(v256 a, v128 count)
  1133. {
  1134. return new v256(Sse2.srl_epi16(a.Lo128, count), Sse2.srl_epi16(a.Hi128, count));
  1135. }
  1136. /// <summary>
  1137. /// Shift packed 32-bit integers in a right by count while shifting
  1138. /// in zeros, and store the results in dst.
  1139. /// </summary>
  1140. /// <param name="a">Vector a</param>
  1141. /// <param name="count">Offset</param>
  1142. /// <returns>Vector</returns>
  1143. [DebuggerStepThrough]
  1144. public static v256 mm256_srl_epi32(v256 a, v128 count)
  1145. {
  1146. return new v256(Sse2.srl_epi32(a.Lo128, count), Sse2.srl_epi32(a.Hi128, count));
  1147. }
  1148. /// <summary>
  1149. /// Shift packed 64-bit integers in a right by count while shifting
  1150. /// in zeros, and store the results in dst.
  1151. /// </summary>
  1152. /// <param name="a">Vector a</param>
  1153. /// <param name="count">Offset</param>
  1154. /// <returns>Vector</returns>
  1155. [DebuggerStepThrough]
  1156. public static v256 mm256_srl_epi64(v256 a, v128 count)
  1157. {
  1158. return new v256(Sse2.srl_epi64(a.Lo128, count), Sse2.srl_epi64(a.Hi128, count));
  1159. }
  1160. /// <summary>
  1161. /// Shift packed 16-bit integers in a right by imm8 while shifting in zeros, and store the results in dst.
  1162. /// </summary>
  1163. /// <param name="a">Vector a</param>
  1164. /// <param name="imm8">Offset</param>
  1165. /// <returns>Vector</returns>
  1166. [DebuggerStepThrough]
  1167. public static v256 mm256_srli_epi16(v256 a, int imm8)
  1168. {
  1169. return new v256(Sse2.srli_epi16(a.Lo128, imm8), Sse2.srli_epi16(a.Hi128, imm8));
  1170. }
  1171. /// <summary>
  1172. /// Shift packed 32-bit integers in a right by imm8 while shifting in zeros, and store the results in dst.
  1173. /// </summary>
  1174. /// <param name="a">Vector a</param>
  1175. /// <param name="imm8">Offset</param>
  1176. /// <returns>Vector</returns>
  1177. [DebuggerStepThrough]
  1178. public static v256 mm256_srli_epi32(v256 a, int imm8)
  1179. {
  1180. return new v256(Sse2.srli_epi32(a.Lo128, imm8), Sse2.srli_epi32(a.Hi128, imm8));
  1181. }
  1182. /// <summary>
  1183. /// Shift packed 64-bit integers in a right by imm8 while shifting in zeros, and store the results in dst.
  1184. /// </summary>
  1185. /// <param name="a">Vector a</param>
  1186. /// <param name="imm8">Offset</param>
  1187. /// <returns>Vector</returns>
  1188. [DebuggerStepThrough]
  1189. public static v256 mm256_srli_epi64(v256 a, int imm8)
  1190. {
  1191. return new v256(Sse2.srli_epi64(a.Lo128, imm8), Sse2.srli_epi64(a.Hi128, imm8));
  1192. }
  1193. /// <summary>
  1194. /// Shift packed 32-bit integers in a right by the amount specified
  1195. /// by the corresponding element in count while shifting in zeros,
  1196. /// and store the results in dst.
  1197. /// </summary>
  1198. /// <param name="a">Vector a</param>
  1199. /// <param name="count">Corresponding element</param>
  1200. /// <returns>Vector</returns>
  1201. [DebuggerStepThrough]
  1202. public static v256 mm256_srlv_epi32(v256 a, v256 count)
  1203. {
  1204. return new v256(srlv_epi32(a.Lo128, count.Lo128), srlv_epi32(a.Hi128, count.Hi128));
  1205. }
  1206. /// <summary>
  1207. /// Shift packed 64-bit integers in a right by the amount specified
  1208. /// by the corresponding element in count while shifting in zeros,
  1209. /// and store the results in dst.
  1210. /// </summary>
  1211. /// <param name="a">Vector a</param>
  1212. /// <param name="count">Corresponding element</param>
  1213. /// <returns>Vector</returns>
  1214. [DebuggerStepThrough]
  1215. public static v256 mm256_srlv_epi64(v256 a, v256 count)
  1216. {
  1217. return new v256(srlv_epi64(a.Lo128, count.Lo128), srlv_epi64(a.Hi128, count.Hi128));
  1218. }
  1219. /// <summary>
  1220. /// Shift packed 32-bit integers in a right by the amount specified
  1221. /// by the corresponding element in count while shifting in zeros,
  1222. /// and store the results in dst.
  1223. /// </summary>
  1224. /// <param name="a">Vector a</param>
  1225. /// <param name="count">Corresponding element</param>
  1226. /// <returns>Vector</returns>
  1227. [DebuggerStepThrough]
  1228. public static v128 srlv_epi32(v128 a, v128 count)
  1229. {
  1230. v128 dst = default;
  1231. uint* aptr = &a.UInt0;
  1232. uint* dptr = &dst.UInt0;
  1233. int* sptr = &count.SInt0;
  1234. for (int i = 0; i < 4; ++i)
  1235. {
  1236. int shift = sptr[i];
  1237. if (shift >= 0 && shift <= 31)
  1238. {
  1239. dptr[i] = aptr[i] >> shift;
  1240. }
  1241. else
  1242. {
  1243. dptr[i] = 0;
  1244. }
  1245. }
  1246. return dst;
  1247. }
  1248. /// <summary>
  1249. /// Shift packed 64-bit integers in a right by the amount specified
  1250. /// by the corresponding element in count while shifting in zeros,
  1251. /// and store the results in dst.
  1252. /// </summary>
  1253. /// <param name="a">Vector a</param>
  1254. /// <param name="count">Corresponding element</param>
  1255. /// <returns>Vector</returns>
  1256. [DebuggerStepThrough]
  1257. public static v128 srlv_epi64(v128 a, v128 count)
  1258. {
  1259. v128 dst = default;
  1260. ulong* aptr = &a.ULong0;
  1261. ulong* dptr = &dst.ULong0;
  1262. long* sptr = &count.SLong0;
  1263. for (int i = 0; i < 2; ++i)
  1264. {
  1265. int shift = (int)sptr[i];
  1266. if (shift >= 0 && shift <= 63)
  1267. {
  1268. dptr[i] = aptr[i] >> shift;
  1269. }
  1270. else
  1271. {
  1272. dptr[i] = 0;
  1273. }
  1274. }
  1275. return dst;
  1276. }
  1277. /// <summary>
  1278. /// Blend packed 32-bit integers from a and b using control mask imm8, and store the results in dst.
  1279. /// </summary>
  1280. /// <param name="a">Vector a</param>
  1281. /// <param name="b">Vector b</param>
  1282. /// <param name="imm8">Control mask</param>
  1283. /// <returns>Vector</returns>
  1284. [DebuggerStepThrough]
  1285. public static v128 blend_epi32(v128 a, v128 b, int imm8)
  1286. {
  1287. return Sse4_1.blend_ps(a, b, imm8);
  1288. }
  1289. /// <summary>
  1290. /// Blend packed 32-bit integers from a and b using control mask imm8, and store the results in dst.
  1291. /// </summary>
  1292. /// <param name="a">Vector a</param>
  1293. /// <param name="b">Vector b</param>
  1294. /// <param name="imm8">Control mask</param>
  1295. /// <returns>Vector</returns>
  1296. [DebuggerStepThrough]
  1297. public static v256 mm256_blend_epi32(v256 a, v256 b, int imm8)
  1298. {
  1299. return Avx.mm256_blend_ps(a, b, imm8);
  1300. }
  1301. /// <summary>
  1302. /// Concatenate pairs of 16-byte blocks in a and b into a 32-byte temporary result, shift the result right by imm8 bytes, and store the low 16 bytes in dst.
  1303. /// </summary>
  1304. /// <param name="a">Vector a</param>
  1305. /// <param name="b">Vector b</param>
  1306. /// <param name="imm8">Offset</param>
  1307. /// <returns>Vector</returns>
  1308. [DebuggerStepThrough]
  1309. public static v256 mm256_alignr_epi8(v256 a, v256 b, int imm8)
  1310. {
  1311. return new v256(Ssse3.alignr_epi8(a.Lo128, b.Lo128, imm8), Ssse3.alignr_epi8(a.Hi128, b.Hi128, imm8));
  1312. }
  1313. /// <summary>
  1314. /// Blend packed 8-bit integers from a and b using mask, and store the results in dst.
  1315. /// </summary>
  1316. /// <param name="a">Vector a</param>
  1317. /// <param name="b">Vector b</param>
  1318. /// <param name="mask">Mask</param>
  1319. /// <returns>Vector</returns>
  1320. [DebuggerStepThrough]
  1321. public static v256 mm256_blendv_epi8(v256 a, v256 b, v256 mask)
  1322. {
  1323. return new v256(Sse4_1.blendv_epi8(a.Lo128, b.Lo128, mask.Lo128), Sse4_1.blendv_epi8(a.Hi128, b.Hi128, mask.Hi128));
  1324. }
  1325. /// <summary>
  1326. /// Blend packed 16-bit integers from a and b within 128-bit lanes using control mask imm8, and store the results in dst.
  1327. /// </summary>
  1328. /// <param name="a">Vector a</param>
  1329. /// <param name="b">Vector b</param>
  1330. /// <param name="imm8">Control mask</param>
  1331. /// <returns>Vector</returns>
  1332. [DebuggerStepThrough]
  1333. public static v256 mm256_blend_epi16(v256 a, v256 b, int imm8)
  1334. {
  1335. return new v256(Sse4_1.blend_epi16(a.Lo128, b.Lo128, imm8), Sse4_1.blend_epi16(a.Hi128, b.Hi128, imm8));
  1336. }
  1337. /// <summary>
  1338. /// Convert packed 16-bit integers from a and b to packed 8-bit integers using signed saturation, and store the results in dst.
  1339. /// </summary>
  1340. /// <param name="a">Vector a</param>
  1341. /// <param name="b">Vector b</param>
  1342. /// <returns>Vector</returns>
  1343. [DebuggerStepThrough]
  1344. public static v256 mm256_packs_epi16(v256 a, v256 b)
  1345. {
  1346. return new v256(Sse2.packs_epi16(a.Lo128, b.Lo128), Sse2.packs_epi16(a.Hi128, b.Hi128));
  1347. }
  1348. /// <summary>
  1349. /// Convert packed 32-bit integers from a and b to packed 16-bit integers using signed saturation, and store the results in dst.
  1350. /// </summary>
  1351. /// <param name="a">Vector a</param>
  1352. /// <param name="b">Vector b</param>
  1353. /// <returns>Vector</returns>
  1354. [DebuggerStepThrough]
  1355. public static v256 mm256_packs_epi32(v256 a, v256 b)
  1356. {
  1357. return new v256(Sse2.packs_epi32(a.Lo128, b.Lo128), Sse2.packs_epi32(a.Hi128, b.Hi128));
  1358. }
  1359. /// <summary>
  1360. /// Convert packed 16-bit integers from a and b to packed 8-bit integers using unsigned saturation, and store the results in dst.
  1361. /// </summary>
  1362. /// <param name="a">Vector a</param>
  1363. /// <param name="b">Vector b</param>
  1364. /// <returns>Vector</returns>
  1365. [DebuggerStepThrough]
  1366. public static v256 mm256_packus_epi16(v256 a, v256 b)
  1367. {
  1368. return new v256(Sse2.packus_epi16(a.Lo128, b.Lo128), Sse2.packus_epi16(a.Hi128, b.Hi128));
  1369. }
  1370. /// <summary>
  1371. /// Convert packed 32-bit integers from a and b to packed 16-bit integers using unsigned saturation, and store the results in dst.
  1372. /// </summary>
  1373. /// <param name="a">Vector a</param>
  1374. /// <param name="b">Vector b</param>
  1375. /// <returns>Vector</returns>
  1376. [DebuggerStepThrough]
  1377. public static v256 mm256_packus_epi32(v256 a, v256 b)
  1378. {
  1379. return new v256(Sse4_1.packus_epi32(a.Lo128, b.Lo128), Sse4_1.packus_epi32(a.Hi128, b.Hi128));
  1380. }
  1381. /// <summary>
  1382. /// Unpack and interleave 8-bit integers from the high half of each 128-bit lane in a and b, and store the results in dst.
  1383. /// </summary>
  1384. /// <param name="a">Vector a</param>
  1385. /// <param name="b">Vector b</param>
  1386. /// <returns>Vector</returns>
  1387. [DebuggerStepThrough]
  1388. public static v256 mm256_unpackhi_epi8(v256 a, v256 b)
  1389. {
  1390. return new v256(Sse2.unpackhi_epi8(a.Lo128, b.Lo128), Sse2.unpackhi_epi8(a.Hi128, b.Hi128));
  1391. }
  1392. /// <summary>
  1393. /// Unpack and interleave 16-bit integers from the high half of each 128-bit lane in a and b, and store the results in dst.
  1394. /// </summary>
  1395. /// <param name="a">Vector a</param>
  1396. /// <param name="b">Vector b</param>
  1397. /// <returns>Vector</returns>
  1398. [DebuggerStepThrough]
  1399. public static v256 mm256_unpackhi_epi16(v256 a, v256 b)
  1400. {
  1401. return new v256(Sse2.unpackhi_epi16(a.Lo128, b.Lo128), Sse2.unpackhi_epi16(a.Hi128, b.Hi128));
  1402. }
  1403. /// <summary>
  1404. /// Unpack and interleave 32-bit integers from the high half of each 128-bit lane in a and b, and store the results in dst.
  1405. /// </summary>
  1406. /// <param name="a">Vector a</param>
  1407. /// <param name="b">Vector b</param>
  1408. /// <returns>Vector</returns>
  1409. [DebuggerStepThrough]
  1410. public static v256 mm256_unpackhi_epi32(v256 a, v256 b)
  1411. {
  1412. return new v256(Sse2.unpackhi_epi32(a.Lo128, b.Lo128), Sse2.unpackhi_epi32(a.Hi128, b.Hi128));
  1413. }
  1414. /// <summary>
  1415. /// Unpack and interleave 64-bit integers from the high half of each 128-bit lane in a and b, and store the results in dst.
  1416. /// </summary>
  1417. /// <param name="a">Vector a</param>
  1418. /// <param name="b">Vector b</param>
  1419. /// <returns>Vector</returns>
  1420. [DebuggerStepThrough]
  1421. public static v256 mm256_unpackhi_epi64(v256 a, v256 b)
  1422. {
  1423. return new v256(Sse2.unpackhi_epi64(a.Lo128, b.Lo128), Sse2.unpackhi_epi64(a.Hi128, b.Hi128));
  1424. }
  1425. /// <summary>
  1426. /// Unpack and interleave 8-bit integers from the low half of each 128-bit lane in a and b, and store the results in dst.
  1427. /// </summary>
  1428. /// <param name="a">Vector a</param>
  1429. /// <param name="b">Vector b</param>
  1430. /// <returns>Vector</returns>
  1431. [DebuggerStepThrough]
  1432. public static v256 mm256_unpacklo_epi8(v256 a, v256 b)
  1433. {
  1434. return new v256(Sse2.unpacklo_epi8(a.Lo128, b.Lo128), Sse2.unpacklo_epi8(a.Hi128, b.Hi128));
  1435. }
  1436. /// <summary>
  1437. /// Unpack and interleave 16-bit integers from the low half of each 128-bit lane in a and b, and store the results in dst.
  1438. /// </summary>
  1439. /// <param name="a">Vector a</param>
  1440. /// <param name="b">Vector b</param>
  1441. /// <returns>Vector</returns>
  1442. [DebuggerStepThrough]
  1443. public static v256 mm256_unpacklo_epi16(v256 a, v256 b)
  1444. {
  1445. return new v256(Sse2.unpacklo_epi16(a.Lo128, b.Lo128), Sse2.unpacklo_epi16(a.Hi128, b.Hi128));
  1446. }
  1447. /// <summary>
  1448. /// Unpack and interleave 32-bit integers from the low half of each 128-bit lane in a and b, and store the results in dst.
  1449. /// </summary>
  1450. /// <param name="a">Vector a</param>
  1451. /// <param name="b">Vector b</param>
  1452. /// <returns>Vector</returns>
  1453. [DebuggerStepThrough]
  1454. public static v256 mm256_unpacklo_epi32(v256 a, v256 b)
  1455. {
  1456. return new v256(Sse2.unpacklo_epi32(a.Lo128, b.Lo128), Sse2.unpacklo_epi32(a.Hi128, b.Hi128));
  1457. }
  1458. /// <summary>
  1459. /// Unpack and interleave 64-bit integers from the low half of each 128-bit lane in a and b, and store the results in dst.
  1460. /// </summary>
  1461. /// <param name="a">Vector a</param>
  1462. /// <param name="b">Vector b</param>
  1463. /// <returns>Vector</returns>
  1464. [DebuggerStepThrough]
  1465. public static v256 mm256_unpacklo_epi64(v256 a, v256 b)
  1466. {
  1467. return new v256(Sse2.unpacklo_epi64(a.Lo128, b.Lo128), Sse2.unpacklo_epi64(a.Hi128, b.Hi128));
  1468. }
  1469. /// <summary>
  1470. /// Shuffle 8-bit integers in a within 128-bit lanes according to
  1471. /// shuffle control mask in the corresponding 8-bit element of b,
  1472. /// and store the results in dst.
  1473. /// </summary>
  1474. /// <param name="a">Vector a</param>
  1475. /// <param name="b">Vector b</param>
  1476. /// <returns>Vector</returns>
  1477. [DebuggerStepThrough]
  1478. public static v256 mm256_shuffle_epi8(v256 a, v256 b)
  1479. {
  1480. return new v256(Ssse3.shuffle_epi8(a.Lo128, b.Lo128), Ssse3.shuffle_epi8(a.Hi128, b.Hi128));
  1481. }
  1482. /// <summary>
  1483. /// Shuffle 32-bit integers in a within 128-bit lanes using the control in imm8, and store the results in dst.
  1484. /// </summary>
  1485. /// <param name="a">Vector a</param>
  1486. /// <param name="imm8">Control</param>
  1487. /// <returns>Vector</returns>
  1488. [DebuggerStepThrough]
  1489. public static v256 mm256_shuffle_epi32(v256 a, int imm8)
  1490. {
  1491. return new v256(Sse2.shuffle_epi32(a.Lo128, imm8), Sse2.shuffle_epi32(a.Hi128, imm8));
  1492. }
  1493. /// <summary>
  1494. /// Shuffle 16-bit integers in the high 64 bits of 128-bit lanes of
  1495. /// a using the control in imm8. Store the results in the high 64
  1496. /// bits of 128-bit lanes of dst, with the low 64 bits of 128-bit
  1497. /// lanes being copied from from a to dst.
  1498. /// </summary>
  1499. /// <param name="a">Vector a</param>
  1500. /// <param name="imm8">Control</param>
  1501. /// <returns>Vector</returns>
  1502. [DebuggerStepThrough]
  1503. public static v256 mm256_shufflehi_epi16(v256 a, int imm8)
  1504. {
  1505. return new v256(Sse2.shufflehi_epi16(a.Lo128, imm8), Sse2.shufflehi_epi16(a.Hi128, imm8));
  1506. }
  1507. /// <summary>
  1508. /// Shuffle 16-bit integers in the low 64 bits of 128-bit lanes of
  1509. /// a using the control in imm8. Store the results in the low 64
  1510. /// bits of 128-bit lanes of dst, with the high 64 bits of 128-bit
  1511. /// lanes being copied from from a to dst.
  1512. /// </summary>
  1513. /// <param name="a">Vector a</param>
  1514. /// <param name="imm8">Control</param>
  1515. /// <returns>Vector</returns>
  1516. [DebuggerStepThrough]
  1517. public static v256 mm256_shufflelo_epi16(v256 a, int imm8)
  1518. {
  1519. return new v256(Sse2.shufflelo_epi16(a.Lo128, imm8), Sse2.shufflelo_epi16(a.Hi128, imm8));
  1520. }
  1521. /// <summary>
  1522. /// Extract 128 bits (composed of integer data) from a, selected with imm8, and store the result in dst.
  1523. /// </summary>
  1524. /// <param name="a">Vector a</param>
  1525. /// <param name="imm8">Selection</param>
  1526. /// <returns>Vector</returns>
  1527. [DebuggerStepThrough]
  1528. public static v128 mm256_extracti128_si256(v256 a, int imm8)
  1529. {
  1530. // Burst IR is fine.
  1531. return Avx.mm256_extractf128_si256(a, imm8);
  1532. }
  1533. /// <summary>
  1534. /// Copy a to dst, then insert 128 bits (composed of integer data) from b into dst at the location specified by imm8.
  1535. /// </summary>
  1536. /// <param name="a">Vector a</param>
  1537. /// <param name="b">Vector b</param>
  1538. /// <param name="imm8">Location</param>
  1539. /// <returns>Vector</returns>
  1540. [DebuggerStepThrough]
  1541. public static v256 mm256_inserti128_si256(v256 a, v128 b, int imm8)
  1542. {
  1543. // Burst IR is fine.
  1544. return Avx.mm256_insertf128_ps(a, b, imm8);
  1545. }
  1546. /// <summary>
  1547. /// Broadcast the low single-precision (32-bit) floating-point element from a to all elements of dst.
  1548. /// </summary>
  1549. /// <param name="a">Vector a</param>
  1550. /// <returns>Vector</returns>
  1551. [DebuggerStepThrough]
  1552. public static v128 broadcastss_ps(v128 a)
  1553. {
  1554. return new v128(a.Float0);
  1555. }
  1556. /// <summary>
  1557. /// Broadcast the low single-precision (32-bit) floating-point element from a to all elements of dst.
  1558. /// </summary>
  1559. /// <param name="a">Vector a</param>
  1560. /// <returns>Vector</returns>
  1561. [DebuggerStepThrough]
  1562. public static v256 mm256_broadcastss_ps(v128 a)
  1563. {
  1564. return new v256(a.Float0);
  1565. }
  1566. /// <summary>
  1567. /// Broadcast the low double-precision (64-bit) floating-point element from a to all elements of dst.
  1568. /// </summary>
  1569. /// <param name="a">Vector a</param>
  1570. /// <returns>Vector</returns>
  1571. [DebuggerStepThrough]
  1572. public static v128 broadcastsd_pd(v128 a)
  1573. {
  1574. return new v128(a.Double0);
  1575. }
  1576. /// <summary>
  1577. /// Broadcast the low double-precision (64-bit) floating-point element from a to all elements of dst.
  1578. /// </summary>
  1579. /// <param name="a">Vector a</param>
  1580. /// <returns>Vector</returns>
  1581. [DebuggerStepThrough]
  1582. public static v256 mm256_broadcastsd_pd(v128 a)
  1583. {
  1584. return new v256(a.Double0);
  1585. }
  1586. /// <summary>
  1587. /// Broadcast the low packed 8-bit integer from a to all elements of dst.
  1588. /// </summary>
  1589. /// <param name="a">Vector a</param>
  1590. /// <returns>Vector</returns>
  1591. [DebuggerStepThrough]
  1592. public static v128 broadcastb_epi8(v128 a)
  1593. {
  1594. return new v128(a.Byte0);
  1595. }
  1596. /// <summary>
  1597. /// Broadcast the low packed 16-bit integer from a to all elements of dst.
  1598. /// </summary>
  1599. /// <param name="a">Vector a</param>
  1600. /// <returns>Vector</returns>
  1601. [DebuggerStepThrough]
  1602. public static v128 broadcastw_epi16(v128 a)
  1603. {
  1604. return new v128(a.SShort0);
  1605. }
  1606. /// <summary>
  1607. /// Broadcast the low packed 32-bit integer from a to all elements of dst.
  1608. /// </summary>
  1609. /// <param name="a">Vector a</param>
  1610. /// <returns>Vector</returns>
  1611. [DebuggerStepThrough]
  1612. public static v128 broadcastd_epi32(v128 a)
  1613. {
  1614. return new v128(a.SInt0);
  1615. }
  1616. /// <summary>
  1617. /// Broadcast the low packed 64-bit integer from a to all elements of dst.
  1618. /// </summary>
  1619. /// <param name="a">Vector a</param>
  1620. /// <returns>Vector</returns>
  1621. [DebuggerStepThrough]
  1622. public static v128 broadcastq_epi64(v128 a)
  1623. {
  1624. return new v128(a.SLong0);
  1625. }
  1626. /// <summary>
  1627. /// Broadcast the low packed 8-bit integer from a to all elements of dst.
  1628. /// </summary>
  1629. /// <param name="a">Vector a</param>
  1630. /// <returns>Vector</returns>
  1631. [DebuggerStepThrough]
  1632. public static v256 mm256_broadcastb_epi8(v128 a)
  1633. {
  1634. return new v256(a.Byte0);
  1635. }
  1636. /// <summary>
  1637. /// Broadcast the low packed 16-bit integer from a to all elements of dst.
  1638. /// </summary>
  1639. /// <param name="a">Vector a</param>
  1640. /// <returns>Vector</returns>
  1641. [DebuggerStepThrough]
  1642. public static v256 mm256_broadcastw_epi16(v128 a)
  1643. {
  1644. return new v256(a.SShort0);
  1645. }
  1646. /// <summary>
  1647. /// Broadcast the low packed 32-bit integer from a to all elements of dst.
  1648. /// </summary>
  1649. /// <param name="a">Vector a</param>
  1650. /// <returns>Vector</returns>
  1651. [DebuggerStepThrough]
  1652. public static v256 mm256_broadcastd_epi32(v128 a)
  1653. {
  1654. return new v256(a.SInt0);
  1655. }
  1656. /// <summary>
  1657. /// Broadcast the low packed 64-bit integer from a to all elements of dst.
  1658. /// </summary>
  1659. /// <param name="a">Vector a</param>
  1660. /// <returns>Vector</returns>
  1661. [DebuggerStepThrough]
  1662. public static v256 mm256_broadcastq_epi64(v128 a)
  1663. {
  1664. return new v256(a.SLong0);
  1665. }
  1666. /// <summary>
  1667. /// Broadcast 128 bits of integer data from a to all 128-bit lanes in dst
  1668. /// </summary>
  1669. /// <param name="a">Vector a</param>
  1670. /// <returns>Vector</returns>
  1671. [DebuggerStepThrough]
  1672. public static v256 mm256_broadcastsi128_si256(v128 a)
  1673. {
  1674. // Burst IR is fine
  1675. return new v256(a, a);
  1676. }
  1677. /// <summary>
  1678. /// Sign extend packed 8-bit integers in a to packed 16-bit integers, and store the results in dst.
  1679. /// </summary>
  1680. /// <param name="a">Vector a</param>
  1681. /// <returns>Vector</returns>
  1682. [DebuggerStepThrough]
  1683. public static v256 mm256_cvtepi8_epi16(v128 a)
  1684. {
  1685. v256 dst = default;
  1686. short* dptr = &dst.SShort0;
  1687. sbyte* aptr = &a.SByte0;
  1688. for (int j = 0; j <= 15; j++)
  1689. {
  1690. dptr[j] = aptr[j];
  1691. }
  1692. return dst;
  1693. }
  1694. /// <summary>
  1695. /// Sign extend packed 8-bit integers in a to packed 32-bit integers, and store the results in dst.
  1696. /// </summary>
  1697. /// <param name="a">Vector a</param>
  1698. /// <returns>Vector</returns>
  1699. [DebuggerStepThrough]
  1700. public static v256 mm256_cvtepi8_epi32(v128 a)
  1701. {
  1702. v256 dst = default;
  1703. int* dptr = &dst.SInt0;
  1704. sbyte* aptr = &a.SByte0;
  1705. for (int j = 0; j <= 7; j++)
  1706. {
  1707. dptr[j] = aptr[j];
  1708. }
  1709. return dst;
  1710. }
  1711. /// <summary>
  1712. /// Sign extend packed 8-bit integers in a to packed 64-bit integers, and store the results in dst.
  1713. /// </summary>
  1714. /// <param name="a">Vector a</param>
  1715. /// <returns>Vector</returns>
  1716. [DebuggerStepThrough]
  1717. public static v256 mm256_cvtepi8_epi64(v128 a)
  1718. {
  1719. v256 dst = default;
  1720. long* dptr = &dst.SLong0;
  1721. sbyte* aptr = &a.SByte0;
  1722. for (int j = 0; j <= 3; j++)
  1723. {
  1724. dptr[j] = aptr[j];
  1725. }
  1726. return dst;
  1727. }
  1728. /// <summary>
  1729. /// Sign extend packed 16-bit integers in a to packed 32-bit integers, and store the results in dst.
  1730. /// </summary>
  1731. /// <param name="a">Vector a</param>
  1732. /// <returns>Vector</returns>
  1733. [DebuggerStepThrough]
  1734. public static v256 mm256_cvtepi16_epi32(v128 a)
  1735. {
  1736. v256 dst = default;
  1737. int* dptr = &dst.SInt0;
  1738. short* aptr = &a.SShort0;
  1739. for (int j = 0; j <= 7; j++)
  1740. {
  1741. dptr[j] = aptr[j];
  1742. }
  1743. return dst;
  1744. }
  1745. /// <summary>
  1746. /// Sign extend packed 16-bit integers in a to packed 64-bit integers, and store the results in dst.
  1747. /// </summary>
  1748. /// <param name="a">Vector a</param>
  1749. /// <returns>Vector</returns>
  1750. [DebuggerStepThrough]
  1751. public static v256 mm256_cvtepi16_epi64(v128 a)
  1752. {
  1753. v256 dst = default;
  1754. long* dptr = &dst.SLong0;
  1755. short* aptr = &a.SShort0;
  1756. for (int j = 0; j <= 3; j++)
  1757. {
  1758. dptr[j] = aptr[j];
  1759. }
  1760. return dst;
  1761. }
  1762. /// <summary>
  1763. /// Sign extend packed 32-bit integers in a to packed 64-bit integers, and store the results in dst.
  1764. /// </summary>
  1765. /// <param name="a">Vector a</param>
  1766. /// <returns>Vector</returns>
  1767. [DebuggerStepThrough]
  1768. public static v256 mm256_cvtepi32_epi64(v128 a)
  1769. {
  1770. v256 dst = default;
  1771. long* dptr = &dst.SLong0;
  1772. int* aptr = &a.SInt0;
  1773. for (int j = 0; j <= 3; j++)
  1774. {
  1775. dptr[j] = aptr[j];
  1776. }
  1777. return dst;
  1778. }
  1779. /// <summary>
  1780. /// Sign extend packed unsigned 8-bit integers in a to packed 16-bit integers, and store the results in dst.
  1781. /// </summary>
  1782. /// <param name="a">Vector a</param>
  1783. /// <returns>Vector</returns>
  1784. [DebuggerStepThrough]
  1785. public static v256 mm256_cvtepu8_epi16(v128 a)
  1786. {
  1787. v256 dst = default;
  1788. short* dptr = &dst.SShort0;
  1789. byte* aptr = &a.Byte0;
  1790. for (int j = 0; j <= 15; j++)
  1791. {
  1792. dptr[j] = aptr[j];
  1793. }
  1794. return dst;
  1795. }
  1796. /// <summary>
  1797. /// Sign extend packed unsigned 8-bit integers in a to packed 32-bit integers, and store the results in dst.
  1798. /// </summary>
  1799. /// <param name="a">Vector a</param>
  1800. /// <returns>Vector</returns>
  1801. [DebuggerStepThrough]
  1802. public static v256 mm256_cvtepu8_epi32(v128 a)
  1803. {
  1804. v256 dst = default;
  1805. int* dptr = &dst.SInt0;
  1806. byte* aptr = &a.Byte0;
  1807. for (int j = 0; j <= 7; j++)
  1808. {
  1809. dptr[j] = aptr[j];
  1810. }
  1811. return dst;
  1812. }
  1813. /// <summary>
  1814. /// Sign extend packed unsigned 8-bit integers in a to packed 64-bit integers, and store the results in dst.
  1815. /// </summary>
  1816. /// <param name="a">Vector a</param>
  1817. /// <returns>Vector</returns>
  1818. [DebuggerStepThrough]
  1819. public static v256 mm256_cvtepu8_epi64(v128 a)
  1820. {
  1821. v256 dst = default;
  1822. long* dptr = &dst.SLong0;
  1823. byte* aptr = &a.Byte0;
  1824. for (int j = 0; j <= 3; j++)
  1825. {
  1826. dptr[j] = aptr[j];
  1827. }
  1828. return dst;
  1829. }
  1830. /// <summary>
  1831. /// Sign extend packed unsigned 16-bit integers in a to packed 32-bit integers, and store the results in dst.
  1832. /// </summary>
  1833. /// <param name="a">Vector a</param>
  1834. /// <returns>Vector</returns>
  1835. [DebuggerStepThrough]
  1836. public static v256 mm256_cvtepu16_epi32(v128 a)
  1837. {
  1838. v256 dst = default;
  1839. int* dptr = &dst.SInt0;
  1840. ushort* aptr = &a.UShort0;
  1841. for (int j = 0; j <= 7; j++)
  1842. {
  1843. dptr[j] = aptr[j];
  1844. }
  1845. return dst;
  1846. }
  1847. /// <summary>
  1848. /// Sign extend packed unsigned 16-bit integers in a to packed 64-bit integers, and store the results in dst.
  1849. /// </summary>
  1850. /// <param name="a">Vector a</param>
  1851. /// <returns>Vector</returns>
  1852. [DebuggerStepThrough]
  1853. public static v256 mm256_cvtepu16_epi64(v128 a)
  1854. {
  1855. v256 dst = default;
  1856. long* dptr = &dst.SLong0;
  1857. ushort* aptr = &a.UShort0;
  1858. for (int j = 0; j <= 3; j++)
  1859. {
  1860. dptr[j] = aptr[j];
  1861. }
  1862. return dst;
  1863. }
  1864. /// <summary>
  1865. /// Sign extend packed unsigned 32-bit integers in a to packed 64-bit integers, and store the results in dst.
  1866. /// </summary>
  1867. /// <param name="a">Vector a</param>
  1868. /// <returns>Vector</returns>
  1869. [DebuggerStepThrough]
  1870. public static v256 mm256_cvtepu32_epi64(v128 a)
  1871. {
  1872. v256 dst = default;
  1873. long* dptr = &dst.SLong0;
  1874. uint* aptr = &a.UInt0;
  1875. for (int j = 0; j <= 3; j++)
  1876. {
  1877. dptr[j] = aptr[j];
  1878. }
  1879. return dst;
  1880. }
  1881. /// <summary>
  1882. /// Load packed 32-bit integers from memory into dst using mask
  1883. /// (elements are zeroed out when the highest bit is not set in the
  1884. /// corresponding element).
  1885. /// </summary>
  1886. /// <param name="mem_addr">Memory address</param>
  1887. /// <param name="mask">Mask</param>
  1888. /// <returns>Vector</returns>
  1889. [DebuggerStepThrough]
  1890. public static v128 maskload_epi32(void* mem_addr, v128 mask)
  1891. {
  1892. v128 dst = default;
  1893. int* sptr = (int*)mem_addr;
  1894. int* mptr = &mask.SInt0;
  1895. int* dptr = &dst.SInt0;
  1896. for (int i = 0; i < 4; ++i)
  1897. {
  1898. if (mptr[i] < 0)
  1899. {
  1900. dptr[i] = sptr[i];
  1901. }
  1902. }
  1903. return dst;
  1904. }
  1905. /// <summary>
  1906. /// Load packed 64-bit integers from memory into dst using mask
  1907. /// (elements are zeroed out when the highest bit is not set in the
  1908. /// corresponding element).
  1909. /// </summary>
  1910. /// <param name="mem_addr">Memory address</param>
  1911. /// <param name="mask">Mask</param>
  1912. /// <returns>Vector</returns>
  1913. [DebuggerStepThrough]
  1914. public static v128 maskload_epi64(void* mem_addr, v128 mask)
  1915. {
  1916. v128 dst = default;
  1917. long* sptr = (long*)mem_addr;
  1918. long* mptr = &mask.SLong0;
  1919. long* dptr = &dst.SLong0;
  1920. for (int i = 0; i < 2; ++i)
  1921. {
  1922. if (mptr[i] < 0)
  1923. {
  1924. dptr[i] = sptr[i];
  1925. }
  1926. }
  1927. return dst;
  1928. }
  1929. /// <summary>
  1930. /// Store packed 32-bit integers from a into memory using mask
  1931. /// (elements are not stored when the highest bit is not set in the
  1932. /// corresponding element).
  1933. /// </summary>
  1934. /// <param name="mem_addr">Memory address</param>
  1935. /// <param name="mask">Mask</param>
  1936. /// <param name="a">Vector a</param>
  1937. [DebuggerStepThrough]
  1938. public static void maskstore_epi32(void* mem_addr, v128 mask, v128 a)
  1939. {
  1940. int* dptr = (int*)mem_addr;
  1941. int* mptr = &mask.SInt0;
  1942. int* sptr = &a.SInt0;
  1943. for (int i = 0; i < 4; ++i)
  1944. {
  1945. if (mptr[i] < 0)
  1946. {
  1947. dptr[i] = sptr[i];
  1948. }
  1949. }
  1950. }
  1951. /// <summary>
  1952. /// Store packed 64-bit integers from a into memory using mask
  1953. /// (elements are not stored when the highest bit is not set in the
  1954. /// corresponding element).
  1955. /// </summary>
  1956. /// <param name="mem_addr">Memory address</param>
  1957. /// <param name="mask">Mask</param>
  1958. /// <param name="a">Vector a</param>
  1959. [DebuggerStepThrough]
  1960. public static void maskstore_epi64(void* mem_addr, v128 mask, v128 a)
  1961. {
  1962. long* dptr = (long*)mem_addr;
  1963. long* mptr = &mask.SLong0;
  1964. long* sptr = &a.SLong0;
  1965. for (int i = 0; i < 2; ++i)
  1966. {
  1967. if (mptr[i] < 0)
  1968. {
  1969. dptr[i] = sptr[i];
  1970. }
  1971. }
  1972. }
  1973. /// <summary>
  1974. /// Load packed 32-bit integers from memory into dst using mask
  1975. /// (elements are zeroed out when the highest bit is not set in the
  1976. /// corresponding element).
  1977. /// </summary>
  1978. /// <param name="mem_addr">Memory address</param>
  1979. /// <param name="mask">Mask</param>
  1980. /// <returns>Vector</returns>
  1981. [DebuggerStepThrough]
  1982. public static v256 mm256_maskload_epi32(void* mem_addr, v256 mask)
  1983. {
  1984. v256 dst = default;
  1985. int* sptr = (int*)mem_addr;
  1986. int* mptr = &mask.SInt0;
  1987. int* dptr = &dst.SInt0;
  1988. for (int i = 0; i < 8; ++i)
  1989. {
  1990. if (mptr[i] < 0)
  1991. {
  1992. dptr[i] = sptr[i];
  1993. }
  1994. }
  1995. return dst;
  1996. }
  1997. /// <summary>
  1998. /// Load packed 64-bit integers from memory into dst using mask
  1999. /// (elements are zeroed out when the highest bit is not set in the
  2000. /// corresponding element).
  2001. /// </summary>
  2002. /// <param name="mem_addr">Memory address</param>
  2003. /// <param name="mask">Mask</param>
  2004. /// <returns>Vector</returns>
  2005. [DebuggerStepThrough]
  2006. public static v256 mm256_maskload_epi64(void* mem_addr, v256 mask)
  2007. {
  2008. v256 dst = default;
  2009. long* sptr = (long*)mem_addr;
  2010. long* mptr = &mask.SLong0;
  2011. long* dptr = &dst.SLong0;
  2012. for (int i = 0; i < 4; ++i)
  2013. {
  2014. if (mptr[i] < 0)
  2015. {
  2016. dptr[i] = sptr[i];
  2017. }
  2018. }
  2019. return dst;
  2020. }
  2021. /// <summary>
  2022. /// Store packed 32-bit integers from a into memory using mask
  2023. /// (elements are not stored when the highest bit is not set in the
  2024. /// corresponding element).
  2025. /// </summary>
  2026. /// <param name="mem_addr">Memory address</param>
  2027. /// <param name="mask">Mask</param>
  2028. /// <param name="a">Vector a</param>
  2029. [DebuggerStepThrough]
  2030. public static void mm256_maskstore_epi32(void* mem_addr, v256 mask, v256 a)
  2031. {
  2032. int* dptr = (int*)mem_addr;
  2033. int* mptr = &mask.SInt0;
  2034. int* sptr = &a.SInt0;
  2035. for (int i = 0; i < 8; ++i)
  2036. {
  2037. if (mptr[i] < 0)
  2038. {
  2039. dptr[i] = sptr[i];
  2040. }
  2041. }
  2042. }
  2043. /// <summary>
  2044. /// Store packed 64-bit integers from a into memory using mask
  2045. /// (elements are not stored when the highest bit is not set in the
  2046. /// corresponding element).
  2047. /// </summary>
  2048. /// <param name="mem_addr">Memory address</param>
  2049. /// <param name="mask">Mask</param>
  2050. /// <param name="a">Vector a</param>
  2051. [DebuggerStepThrough]
  2052. public static void mm256_maskstore_epi64(void* mem_addr, v256 mask, v256 a)
  2053. {
  2054. long* dptr = (long*)mem_addr;
  2055. long* mptr = &mask.SLong0;
  2056. long* sptr = &a.SLong0;
  2057. for (int i = 0; i < 4; ++i)
  2058. {
  2059. if (mptr[i] < 0)
  2060. {
  2061. dptr[i] = sptr[i];
  2062. }
  2063. }
  2064. }
  2065. /// <summary>
  2066. /// Shuffle 32-bit integers in a across lanes using the corresponding index in idx, and store the results in dst.
  2067. /// </summary>
  2068. /// <param name="a">Vector a</param>
  2069. /// <param name="idx">idx</param>
  2070. /// <returns>Vector</returns>
  2071. [DebuggerStepThrough]
  2072. public static v256 mm256_permutevar8x32_epi32(v256 a, v256 idx)
  2073. {
  2074. v256 dst = default;
  2075. int* iptr = &idx.SInt0;
  2076. int* aptr = &a.SInt0;
  2077. int* dptr = &dst.SInt0;
  2078. for (int i = 0; i < 8; ++i)
  2079. {
  2080. int index = iptr[i] & 7;
  2081. dptr[i] = aptr[index];
  2082. }
  2083. return dst;
  2084. }
  2085. /// <summary>
  2086. /// Shuffle single-precision (32-bit) floating-point elements in a across lanes using the corresponding index in idx.
  2087. /// </summary>
  2088. /// <param name="a">Vector a</param>
  2089. /// <param name="idx">idx</param>
  2090. /// <returns>Vector</returns>
  2091. [DebuggerStepThrough]
  2092. public static v256 mm256_permutevar8x32_ps(v256 a, v256 idx)
  2093. {
  2094. return mm256_permutevar8x32_epi32(a, idx);
  2095. }
  2096. /// <summary>
  2097. /// Shuffle 64-bit integers in a across lanes using the control in imm8, and store the results in dst.
  2098. /// </summary>
  2099. /// <param name="a">Vector a</param>
  2100. /// <param name="imm8">Control</param>
  2101. /// <returns>Vector</returns>
  2102. [DebuggerStepThrough]
  2103. public static v256 mm256_permute4x64_epi64(v256 a, int imm8)
  2104. {
  2105. v256 dst = default;
  2106. long* aptr = &a.SLong0;
  2107. long* dptr = &dst.SLong0;
  2108. for (int i = 0; i < 4; ++i, imm8 >>= 2)
  2109. {
  2110. dptr[i] = aptr[imm8 & 3];
  2111. }
  2112. return dst;
  2113. }
  2114. /// <summary>
  2115. /// Shuffle double-precision (64-bit) floating-point elements in a across lanes using the control in imm8, and store the results in dst.
  2116. /// </summary>
  2117. /// <param name="a">Vector a</param>
  2118. /// <param name="imm8">Control</param>
  2119. /// <returns>Vector</returns>
  2120. [DebuggerStepThrough]
  2121. public static v256 mm256_permute4x64_pd(v256 a, int imm8)
  2122. {
  2123. return mm256_permute4x64_epi64(a, imm8);
  2124. }
  2125. /// <summary>
  2126. /// Shuffle 128-bits (composed of integer data) selected by imm8 from a and b, and store the results in dst.
  2127. /// </summary>
  2128. /// <param name="a">Vector a</param>
  2129. /// <param name="b">Vector b</param>
  2130. /// <param name="imm8">Selection</param>
  2131. /// <returns>Vector</returns>
  2132. [DebuggerStepThrough]
  2133. public static v256 mm256_permute2x128_si256(v256 a, v256 b, int imm8)
  2134. {
  2135. return Avx.mm256_permute2f128_si256(a, b, imm8);
  2136. }
  2137. /// <summary>
  2138. /// Load 256-bits of integer data from memory into dst using a
  2139. /// non-temporal memory hint. mem_addr must be aligned on a 32-byte
  2140. /// boundary or a general-protection exception may be generated.
  2141. /// </summary>
  2142. /// <param name="mem_addr">Memory address</param>
  2143. /// <returns>Vector</returns>
  2144. [DebuggerStepThrough]
  2145. public static v256 mm256_stream_load_si256(void* mem_addr)
  2146. {
  2147. return *(v256*)mem_addr;
  2148. }
  2149. private static void EmulatedGather<T, U>(T* dptr, void* base_addr, long* indexPtr, int scale, int n, U* mask) where T : unmanaged where U : unmanaged, IComparable<U>
  2150. {
  2151. U maskZero = default;
  2152. for (int i = 0; i < n; ++i)
  2153. {
  2154. long baseIndex = indexPtr[i];
  2155. long offset = baseIndex * scale;
  2156. T* mem_addr = (T*)((byte*)base_addr + offset);
  2157. if (mask == null || mask[i].CompareTo(maskZero) < 0)
  2158. {
  2159. dptr[i] = *mem_addr;
  2160. }
  2161. }
  2162. }
  2163. private static void EmulatedGather<T, U>(T* dptr, void* base_addr, int* indexPtr, int scale, int n, U* mask) where T : unmanaged where U : unmanaged, IComparable<U>
  2164. {
  2165. U maskZero = default;
  2166. for (int i = 0; i < n; ++i)
  2167. {
  2168. long baseIndex = indexPtr[i];
  2169. long offset = baseIndex * scale;
  2170. T* mem_addr = (T*)((byte*)base_addr + offset);
  2171. if (mask == null || mask[i].CompareTo(maskZero) < 0)
  2172. {
  2173. dptr[i] = *mem_addr;
  2174. }
  2175. }
  2176. }
  2177. /// <summary>
  2178. /// Gather 32-bit integers from memory using 32-bit indices. 32-bit
  2179. /// elements are loaded from addresses starting at base_addr and
  2180. /// offset by each 32-bit element in vindex (each index is scaled
  2181. /// by the factor in scale). Gathered elements are merged into dst.
  2182. /// scale should be 1, 2, 4 or 8.
  2183. /// </summary>
  2184. /// <param name="base_addr">Base address</param>
  2185. /// <param name="vindex">Offset</param>
  2186. /// <param name="scale">Index scale</param>
  2187. /// <returns>Vector</returns>
  2188. [DebuggerStepThrough]
  2189. public static v256 mm256_i32gather_epi32(void* base_addr, v256 vindex, int scale)
  2190. {
  2191. v256 dst = default;
  2192. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SInt0, scale, sizeof(v256) / sizeof(int), (int*)null);
  2193. return dst;
  2194. }
  2195. /// <summary>
  2196. /// Gather double-precision (64-bit) floating-point elements from
  2197. /// memory using 32-bit indices. 64-bit elements are loaded from
  2198. /// addresses starting at base_addr and offset by each 32-bit
  2199. /// element in vindex (each index is scaled by the factor in
  2200. /// scale). Gathered elements are merged into dst. scale should be
  2201. /// 1, 2, 4 or 8.
  2202. /// </summary>
  2203. /// <param name="base_addr">Base address</param>
  2204. /// <param name="vindex">Offset</param>
  2205. /// <param name="scale">Index scale</param>
  2206. /// <returns>Vector</returns>
  2207. [DebuggerStepThrough]
  2208. public static v256 mm256_i32gather_pd(void* base_addr, v128 vindex, int scale)
  2209. {
  2210. v256 dst = default;
  2211. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SInt0, scale, 4, null);
  2212. return dst;
  2213. }
  2214. /// <summary>
  2215. /// Gather single-precision (32-bit) floating-point elements from
  2216. /// memory using 32-bit indices. 32-bit elements are loaded from
  2217. /// addresses starting at base_addr and offset by each 32-bit
  2218. /// element in vindex (each index is scaled by the factor in
  2219. /// scale). Gathered elements are merged into dst using mask
  2220. /// (elements are copied from src when the highest bit is not set
  2221. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2222. /// </summary>
  2223. /// <param name="base_addr">Base address</param>
  2224. /// <param name="vindex">Offset</param>
  2225. /// <param name="scale">Index scale</param>
  2226. /// <returns>Vector</returns>
  2227. [DebuggerStepThrough]
  2228. public static v256 mm256_i32gather_ps(void* base_addr, v256 vindex, int scale)
  2229. {
  2230. v256 dst = default;
  2231. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SInt0, scale, 8, null);
  2232. return dst;
  2233. }
  2234. /// <summary>
  2235. /// Gather double-precision (64-bit) floating-point elements from
  2236. /// memory using 64-bit indices. 64-bit elements are loaded from
  2237. /// addresses starting at base_addr and offset by each 64-bit
  2238. /// element in vindex (each index is scaled by the factor in
  2239. /// scale). Gathered elements are merged into dst. scale should be
  2240. /// 1, 2, 4 or 8.
  2241. /// </summary>
  2242. /// <param name="base_addr">Base address</param>
  2243. /// <param name="vindex">Offset</param>
  2244. /// <param name="scale">Index scale</param>
  2245. /// <returns>Vector</returns>
  2246. [DebuggerStepThrough]
  2247. public static v256 mm256_i64gather_pd(void* base_addr, v256 vindex, int scale)
  2248. {
  2249. v256 dst = default;
  2250. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SLong0, scale, 4, null);
  2251. return dst;
  2252. }
  2253. /// <summary>
  2254. /// Gather single-precision (32-bit) floating-point elements from
  2255. /// memory using 64-bit indices. 32-bit elements are loaded from
  2256. /// addresses starting at base_addr and offset by each 64-bit
  2257. /// element in vindex (each index is scaled by the factor in
  2258. /// scale). Gathered elements are merged into dst. scale should be
  2259. /// 1, 2, 4 or 8.
  2260. /// </summary>
  2261. /// <param name="base_addr">Base address</param>
  2262. /// <param name="vindex">Offset</param>
  2263. /// <param name="scale">Index scale</param>
  2264. /// <returns>Vector</returns>
  2265. [DebuggerStepThrough]
  2266. public static v128 mm256_i64gather_ps(void* base_addr, v256 vindex, int scale)
  2267. {
  2268. v128 dst = default;
  2269. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SLong0, scale, 4, null);
  2270. return dst;
  2271. }
  2272. /// <summary>
  2273. /// Gather double-precision (64-bit) floating-point elements from
  2274. /// memory using 32-bit indices. 64-bit elements are loaded from
  2275. /// addresses starting at base_addr and offset by each 32-bit
  2276. /// element in vindex (each index is scaled by the factor in
  2277. /// scale). Gathered elements are merged into dst. scale should be
  2278. /// 1, 2, 4 or 8.
  2279. /// </summary>
  2280. /// <param name="base_addr">Base address</param>
  2281. /// <param name="vindex">Offset</param>
  2282. /// <param name="scale">Index scale</param>
  2283. /// <returns>Vector</returns>
  2284. [DebuggerStepThrough]
  2285. public static v128 i32gather_pd(void* base_addr, v128 vindex, int scale)
  2286. {
  2287. v128 dst = default;
  2288. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SInt0, scale, 2, null);
  2289. return dst;
  2290. }
  2291. /// <summary>
  2292. /// Gather single-precision (32-bit) floating-point elements from
  2293. /// memory using 32-bit indices. 32-bit elements are loaded from
  2294. /// addresses starting at base_addr and offset by each 32-bit
  2295. /// element in vindex (each index is scaled by the factor in
  2296. /// scale). Gathered elements are merged into dst. scale should be
  2297. /// 1, 2, 4 or 8.
  2298. /// </summary>
  2299. /// <param name="base_addr">Base address</param>
  2300. /// <param name="vindex">Offset</param>
  2301. /// <param name="scale">Index scale</param>
  2302. /// <returns>Vector</returns>
  2303. [DebuggerStepThrough]
  2304. public static v128 i32gather_ps(void* base_addr, v128 vindex, int scale)
  2305. {
  2306. v128 dst = default;
  2307. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SInt0, scale, 4, null);
  2308. return dst;
  2309. }
  2310. /// <summary>
  2311. /// Gather double-precision (64-bit) floating-point elements from
  2312. /// memory using 64-bit indices. 64-bit elements are loaded from
  2313. /// addresses starting at base_addr and offset by each 64-bit
  2314. /// element in vindex (each index is scaled by the factor in
  2315. /// scale). Gathered elements are merged into dst. scale should be
  2316. /// 1, 2, 4 or 8.
  2317. /// </summary>
  2318. /// <param name="base_addr">Base address</param>
  2319. /// <param name="vindex">Offset</param>
  2320. /// <param name="scale">Index scale</param>
  2321. /// <returns>Vector</returns>
  2322. [DebuggerStepThrough]
  2323. public static v128 i64gather_pd(void* base_addr, v128 vindex, int scale)
  2324. {
  2325. v128 dst = default;
  2326. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SLong0, scale, 2, null);
  2327. return dst;
  2328. }
  2329. /// <summary>
  2330. /// Gather single-precision (32-bit) floating-point elements from
  2331. /// memory using 64-bit indices. 32-bit elements are loaded from
  2332. /// addresses starting at base_addr and offset by each 64-bit
  2333. /// element in vindex (each index is scaled by the factor in
  2334. /// scale). Gathered elements are merged into dst. scale should be
  2335. /// 1, 2, 4 or 8.
  2336. /// </summary>
  2337. /// <param name="base_addr">Base address</param>
  2338. /// <param name="vindex">Offset</param>
  2339. /// <param name="scale">Index scale</param>
  2340. /// <returns>Vector</returns>
  2341. [DebuggerStepThrough]
  2342. public static v128 i64gather_ps(void* base_addr, v128 vindex, int scale)
  2343. {
  2344. v128 dst = default;
  2345. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SLong0, scale, 2, null);
  2346. return dst;
  2347. }
  2348. /// <summary>
  2349. /// Gather 64-bit integers from memory using 32-bit indices. 64-bit
  2350. /// elements are loaded from addresses starting at base_addr and
  2351. /// offset by each 32-bit element in vindex (each index is scaled
  2352. /// by the factor in scale). Gathered elements are merged into dst.
  2353. /// scale should be 1, 2, 4 or 8.
  2354. /// </summary>
  2355. /// <param name="base_addr">Base address</param>
  2356. /// <param name="vindex">Offset</param>
  2357. /// <param name="scale">Index scale</param>
  2358. /// <returns>Vector</returns>
  2359. [DebuggerStepThrough]
  2360. public static v256 mm256_i32gather_epi64(void* base_addr, v128 vindex, int scale)
  2361. {
  2362. v256 dst = default;
  2363. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SInt0, scale, 4, null);
  2364. return dst;
  2365. }
  2366. /// <summary>
  2367. /// Gather 32-bit integers from memory using 64-bit indices. 32-bit
  2368. /// elements are loaded from addresses starting at base_addr and
  2369. /// offset by each 64-bit element in vindex (each index is scaled
  2370. /// by the factor in scale). Gathered elements are merged into dst.
  2371. /// scale should be 1, 2, 4 or 8.
  2372. /// </summary>
  2373. /// <param name="base_addr">Base address</param>
  2374. /// <param name="vindex">Offset</param>
  2375. /// <param name="scale">Index scale</param>
  2376. /// <returns>Vector</returns>
  2377. [DebuggerStepThrough]
  2378. public static v128 mm256_i64gather_epi32(void* base_addr, v256 vindex, int scale)
  2379. {
  2380. v128 dst = default;
  2381. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SLong0, scale, 4, null);
  2382. return dst;
  2383. }
  2384. /// <summary>
  2385. /// Gather 64-bit integers from memory using 64-bit indices. 64-bit
  2386. /// elements are loaded from addresses starting at base_addr and
  2387. /// offset by each 64-bit element in vindex (each index is scaled
  2388. /// by the factor in scale). Gathered elements are merged into dst.
  2389. /// scale should be 1, 2, 4 or 8.
  2390. /// </summary>
  2391. /// <param name="base_addr">Base address</param>
  2392. /// <param name="vindex">Offset</param>
  2393. /// <param name="scale">Index scale</param>
  2394. /// <returns>Vector</returns>
  2395. [DebuggerStepThrough]
  2396. public static v256 mm256_i64gather_epi64(void* base_addr, v256 vindex, int scale)
  2397. {
  2398. v256 dst = default;
  2399. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SLong0, scale, 4, null);
  2400. return dst;
  2401. }
  2402. /// <summary>
  2403. /// Gather 32-bit integers from memory using 32-bit indices. 32-bit
  2404. /// elements are loaded from addresses starting at base_addr and
  2405. /// offset by each 32-bit element in vindex (each index is scaled
  2406. /// by the factor in scale). Gathered elements are merged into dst.
  2407. /// scale should be 1, 2, 4 or 8.
  2408. /// </summary>
  2409. /// <param name="base_addr">Base address</param>
  2410. /// <param name="vindex">Offset</param>
  2411. /// <param name="scale">Index scale</param>
  2412. /// <returns>Vector</returns>
  2413. [DebuggerStepThrough]
  2414. public static v128 i32gather_epi32(void* base_addr, v128 vindex, int scale)
  2415. {
  2416. v128 dst = default;
  2417. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SInt0, scale, 4, null);
  2418. return dst;
  2419. }
  2420. /// <summary>
  2421. /// Gather 64-bit integers from memory using 32-bit indices. 64-bit
  2422. /// elements are loaded from addresses starting at base_addr and
  2423. /// offset by each 32-bit element in vindex (each index is scaled
  2424. /// by the factor in scale). Gathered elements are merged into dst.
  2425. /// scale should be 1, 2, 4 or 8.
  2426. /// </summary>
  2427. /// <param name="base_addr">Base address</param>
  2428. /// <param name="vindex">Offset</param>
  2429. /// <param name="scale">Index scale</param>
  2430. /// <returns>Vector</returns>
  2431. [DebuggerStepThrough]
  2432. public static v128 i32gather_epi64(void* base_addr, v128 vindex, int scale)
  2433. {
  2434. v128 dst = default;
  2435. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SInt0, scale, 2, null);
  2436. return dst;
  2437. }
  2438. /// <summary>
  2439. /// Gather 32-bit integers from memory using 64-bit indices. 32-bit
  2440. /// elements are loaded from addresses starting at base_addr and
  2441. /// offset by each 64-bit element in vindex (each index is scaled
  2442. /// by the factor in scale). Gathered elements are merged into dst.
  2443. /// scale should be 1, 2, 4 or 8.
  2444. /// </summary>
  2445. /// <param name="base_addr">Base address</param>
  2446. /// <param name="vindex">Offset</param>
  2447. /// <param name="scale">Index scale</param>
  2448. /// <returns>Vector</returns>
  2449. [DebuggerStepThrough]
  2450. public static v128 i64gather_epi32(void* base_addr, v128 vindex, int scale)
  2451. {
  2452. v128 dst = default;
  2453. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SLong0, scale, 2, null);
  2454. return dst;
  2455. }
  2456. /// <summary>
  2457. /// Gather 64-bit integers from memory using 64-bit indices. 64-bit
  2458. /// elements are loaded from addresses starting at base_addr and
  2459. /// offset by each 64-bit element in vindex (each index is scaled
  2460. /// by the factor in scale). Gathered elements are merged into dst.
  2461. /// scale should be 1, 2, 4 or 8.
  2462. /// </summary>
  2463. /// <param name="base_addr">Base address</param>
  2464. /// <param name="vindex">Offset</param>
  2465. /// <param name="scale">Index scale</param>
  2466. /// <returns>Vector</returns>
  2467. [DebuggerStepThrough]
  2468. public static v128 i64gather_epi64(void* base_addr, v128 vindex, int scale)
  2469. {
  2470. v128 dst = default;
  2471. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SLong0, scale, 2, null);
  2472. return dst;
  2473. }
  2474. /// <summary>
  2475. /// Gather double-precision (64-bit) floating-point elements from
  2476. /// memory using 32-bit indices. 64-bit elements are loaded from
  2477. /// addresses starting at base_addr and offset by each 32-bit
  2478. /// element in vindex (each index is scaled by the factor in
  2479. /// scale). Gathered elements are merged into dst using mask
  2480. /// (elements are copied from src when the highest bit is not set
  2481. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2482. /// </summary>
  2483. /// <param name="src">Source</param>
  2484. /// <param name="base_addr">Base address</param>
  2485. /// <param name="vindex">Offset</param>
  2486. /// <param name="mask">Mask</param>
  2487. /// <param name="scale">Index scale</param>
  2488. /// <returns>Vector</returns>
  2489. [DebuggerStepThrough]
  2490. public static v256 mm256_mask_i32gather_pd(v256 src, void* base_addr, v128 vindex, v256 mask, int scale)
  2491. {
  2492. v256 dst = src;
  2493. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SInt0, scale, 4, &mask.SLong0);
  2494. return dst;
  2495. }
  2496. /// <summary>
  2497. /// Gather single-precision (32-bit) floating-point elements from
  2498. /// memory using 32-bit indices. 32-bit elements are loaded from
  2499. /// addresses starting at base_addr and offset by each 32-bit
  2500. /// element in vindex (each index is scaled by the factor in
  2501. /// scale). Gathered elements are merged into dst using mask
  2502. /// (elements are copied from src when the highest bit is not set
  2503. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2504. /// </summary>
  2505. /// <param name="src">Source</param>
  2506. /// <param name="base_addr">Base address</param>
  2507. /// <param name="vindex">Offset</param>
  2508. /// <param name="mask">Mask</param>
  2509. /// <param name="scale">Index scale</param>
  2510. /// <returns>Vector</returns>
  2511. [DebuggerStepThrough]
  2512. public static v256 mm256_mask_i32gather_ps(v256 src, void* base_addr, v256 vindex, v256 mask, int scale)
  2513. {
  2514. v256 dst = src;
  2515. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SInt0, scale, 8, &mask.SInt0);
  2516. return dst;
  2517. }
  2518. /// <summary>
  2519. /// Gather double-precision (64-bit) floating-point elements from
  2520. /// memory using 64-bit indices. 64-bit elements are loaded from
  2521. /// addresses starting at base_addr and offset by each 64-bit
  2522. /// element in vindex (each index is scaled by the factor in
  2523. /// scale). Gathered elements are merged into dst using mask
  2524. /// (elements are copied from src when the highest bit is not set
  2525. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2526. /// </summary>
  2527. /// <param name="src">Source</param>
  2528. /// <param name="base_addr">Base address</param>
  2529. /// <param name="vindex">Offset</param>
  2530. /// <param name="mask">Mask</param>
  2531. /// <param name="scale">Index scale</param>
  2532. /// <returns>Vector</returns>
  2533. [DebuggerStepThrough]
  2534. public static v256 mm256_mask_i64gather_pd(v256 src, void* base_addr, v256 vindex, v256 mask, int scale)
  2535. {
  2536. v256 dst = src;
  2537. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SLong0, scale, 4, &mask.SLong0);
  2538. return dst;
  2539. }
  2540. /// <summary>
  2541. /// Gather single-precision (32-bit) floating-point elements from
  2542. /// memory using 64-bit indices. 32-bit elements are loaded from
  2543. /// addresses starting at base_addr and offset by each 64-bit
  2544. /// element in vindex (each index is scaled by the factor in
  2545. /// scale). Gathered elements are merged into dst using mask
  2546. /// (elements are copied from src when the highest bit is not set
  2547. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2548. /// </summary>
  2549. /// <param name="src">Source</param>
  2550. /// <param name="base_addr">Base address</param>
  2551. /// <param name="vindex">Offset</param>
  2552. /// <param name="mask">Mask</param>
  2553. /// <param name="scale">Index scale</param>
  2554. /// <returns>Vector</returns>
  2555. [DebuggerStepThrough]
  2556. public static v128 mm256_mask_i64gather_ps(v128 src, void* base_addr, v256 vindex, v128 mask, int scale)
  2557. {
  2558. v128 dst = src;
  2559. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SLong0, scale, 4, &mask.SInt0);
  2560. return dst;
  2561. }
  2562. /// <summary>
  2563. /// Gather 32-bit integers from memory using 32-bit indices. 32-bit
  2564. /// elements are loaded from addresses starting at base_addr and
  2565. /// offset by each 32-bit element in vindex (each index is scaled
  2566. /// by the factor in scale). Gathered elements are merged into dst
  2567. /// using mask (elements are copied from src when the highest bit
  2568. /// is not set in the corresponding element). scale should be 1, 2,
  2569. /// 4 or 8.
  2570. /// </summary>
  2571. /// <param name="src">Source</param>
  2572. /// <param name="base_addr">Base address</param>
  2573. /// <param name="vindex">Offset</param>
  2574. /// <param name="mask">Mask</param>
  2575. /// <param name="scale">Index scale</param>
  2576. /// <returns>Vector</returns>
  2577. [DebuggerStepThrough]
  2578. public static v256 mm256_mask_i32gather_epi32(v256 src, void* base_addr, v256 vindex, v256 mask, int scale)
  2579. {
  2580. v256 dst = src;
  2581. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SInt0, scale, 8, &mask.SInt0);
  2582. return dst;
  2583. }
  2584. /// <summary>
  2585. /// Gather 64-bit integers from memory using 32-bit indices. 64-bit
  2586. /// elements are loaded from addresses starting at base_addr and
  2587. /// offset by each 32-bit element in vindex (each index is scaled
  2588. /// by the factor in scale). Gathered elements are merged into dst
  2589. /// using mask (elements are copied from src when the highest bit
  2590. /// is not set in the corresponding element). scale should be 1, 2,
  2591. /// 4 or 8.
  2592. /// </summary>
  2593. /// <param name="src">Source</param>
  2594. /// <param name="base_addr">Base address</param>
  2595. /// <param name="vindex">Offset</param>
  2596. /// <param name="mask">Mask</param>
  2597. /// <param name="scale">Index scale</param>
  2598. /// <returns>Vector</returns>
  2599. [DebuggerStepThrough]
  2600. public static v256 mm256_mask_i32gather_epi64(v256 src, void* base_addr, v128 vindex, v256 mask, int scale)
  2601. {
  2602. v256 dst = src;
  2603. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SInt0, scale, 4, &mask.SLong0);
  2604. return dst;
  2605. }
  2606. /// <summary>
  2607. /// Gather 64-bit integers from memory using 64-bit indices. 64-bit
  2608. /// elements are loaded from addresses starting at base_addr and
  2609. /// offset by each 64-bit element in vindex (each index is scaled
  2610. /// by the factor in scale). Gathered elements are merged into dst
  2611. /// using mask (elements are copied from src when the highest bit
  2612. /// is not set in the corresponding element). scale should be 1, 2,
  2613. /// 4 or 8.
  2614. /// </summary>
  2615. /// <param name="src">Source</param>
  2616. /// <param name="base_addr">Base address</param>
  2617. /// <param name="vindex">Offset</param>
  2618. /// <param name="mask">Mask</param>
  2619. /// <param name="scale">Index scale</param>
  2620. /// <returns>Vector</returns>
  2621. [DebuggerStepThrough]
  2622. public static v256 mm256_mask_i64gather_epi64(v256 src, void* base_addr, v256 vindex, v256 mask, int scale)
  2623. {
  2624. v256 dst = src;
  2625. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SLong0, scale, 4, &mask.SLong0);
  2626. return dst;
  2627. }
  2628. /// <summary>
  2629. /// Gather 32-bit integers from memory using 64-bit indices. 32-bit
  2630. /// elements are loaded from addresses starting at base_addr and
  2631. /// offset by each 64-bit element in vindex (each index is scaled
  2632. /// by the factor in scale). Gathered elements are merged into dst
  2633. /// using mask (elements are copied from src when the highest bit
  2634. /// is not set in the corresponding element). scale should be 1, 2,
  2635. /// 4 or 8.
  2636. /// </summary>
  2637. /// <param name="src">Source</param>
  2638. /// <param name="base_addr">Base address</param>
  2639. /// <param name="vindex">Offset</param>
  2640. /// <param name="mask">Mask</param>
  2641. /// <param name="scale">Index scale</param>
  2642. /// <returns>Vector</returns>
  2643. [DebuggerStepThrough]
  2644. public static v128 mm256_mask_i64gather_epi32(v128 src, void* base_addr, v256 vindex, v128 mask, int scale)
  2645. {
  2646. v128 dst = src;
  2647. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SLong0, scale, 4, &mask.SInt0);
  2648. return dst;
  2649. }
  2650. /// <summary>
  2651. /// Gather double-precision (64-bit) floating-point elements from
  2652. /// memory using 32-bit indices. 64-bit elements are loaded from
  2653. /// addresses starting at base_addr and offset by each 32-bit
  2654. /// element in vindex (each index is scaled by the factor in
  2655. /// scale). Gathered elements are merged into dst using mask
  2656. /// (elements are copied from src when the highest bit is not set
  2657. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2658. /// </summary>
  2659. /// <param name="src">Source</param>
  2660. /// <param name="base_addr">Base address</param>
  2661. /// <param name="vindex">Offset</param>
  2662. /// <param name="mask">Mask</param>
  2663. /// <param name="scale">Index scale</param>
  2664. /// <returns>Vector</returns>
  2665. [DebuggerStepThrough]
  2666. public static v128 mask_i32gather_pd(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2667. {
  2668. v128 dst = src;
  2669. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SInt0, scale, 2, &mask.SLong0);
  2670. return dst;
  2671. }
  2672. /// <summary>
  2673. /// Gather single-precision (32-bit) floating-point elements from
  2674. /// memory using 32-bit indices. 32-bit elements are loaded from
  2675. /// addresses starting at base_addr and offset by each 32-bit
  2676. /// element in vindex (each index is scaled by the factor in
  2677. /// scale). Gathered elements are merged into dst using mask
  2678. /// (elements are copied from src when the highest bit is not set
  2679. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2680. /// </summary>
  2681. /// <param name="src">Source</param>
  2682. /// <param name="base_addr">Base address</param>
  2683. /// <param name="vindex">Offset</param>
  2684. /// <param name="mask">Mask</param>
  2685. /// <param name="scale">Index scale</param>
  2686. /// <returns>Vector</returns>
  2687. [DebuggerStepThrough]
  2688. public static v128 mask_i32gather_ps(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2689. {
  2690. v128 dst = src;
  2691. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SInt0, scale, 4, &mask.SInt0);
  2692. return dst;
  2693. }
  2694. /// <summary>
  2695. /// Gather double-precision (64-bit) floating-point elements from
  2696. /// memory using 64-bit indices. 64-bit elements are loaded from
  2697. /// addresses starting at base_addr and offset by each 64-bit
  2698. /// element in vindex (each index is scaled by the factor in
  2699. /// scale). Gathered elements are merged into dst using mask
  2700. /// (elements are copied from src when the highest bit is not set
  2701. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2702. /// </summary>
  2703. /// <param name="src">Source</param>
  2704. /// <param name="base_addr">Base address</param>
  2705. /// <param name="vindex">Offset</param>
  2706. /// <param name="mask">Mask</param>
  2707. /// <param name="scale">Index scale</param>
  2708. /// <returns>Vector</returns>
  2709. [DebuggerStepThrough]
  2710. public static v128 mask_i64gather_pd(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2711. {
  2712. v128 dst = src;
  2713. EmulatedGather<double, long>(&dst.Double0, base_addr, &vindex.SLong0, scale, 2, &mask.SLong0);
  2714. return dst;
  2715. }
  2716. /// <summary>
  2717. /// Gather single-precision (32-bit) floating-point elements from
  2718. /// memory using 64-bit indices. 32-bit elements are loaded from
  2719. /// addresses starting at base_addr and offset by each 64-bit
  2720. /// element in vindex (each index is scaled by the factor in
  2721. /// scale). Gathered elements are merged into dst using mask
  2722. /// (elements are copied from src when the highest bit is not set
  2723. /// in the corresponding element). scale should be 1, 2, 4 or 8.
  2724. /// </summary>
  2725. /// <param name="src">Source</param>
  2726. /// <param name="base_addr">Base address</param>
  2727. /// <param name="vindex">Offset</param>
  2728. /// <param name="mask">Mask</param>
  2729. /// <param name="scale">Index scale</param>
  2730. /// <returns>Vector</returns>
  2731. [DebuggerStepThrough]
  2732. public static v128 mask_i64gather_ps(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2733. {
  2734. v128 dst = src;
  2735. dst.UInt2 = dst.UInt3 = 0;
  2736. EmulatedGather<float, int>(&dst.Float0, base_addr, &vindex.SLong0, scale, 2, &mask.SInt0);
  2737. return dst;
  2738. }
  2739. /// <summary>
  2740. /// Gather 32-bit integers from memory using 32-bit indices. 32-bit
  2741. /// elements are loaded from addresses starting at base_addr and
  2742. /// offset by each 32-bit element in vindex (each index is scaled
  2743. /// by the factor in scale). Gathered elements are merged into dst
  2744. /// using mask (elements are copied from src when the highest bit
  2745. /// is not set in the corresponding element). scale should be 1, 2,
  2746. /// 4 or 8.
  2747. /// </summary>
  2748. /// <param name="src">Source</param>
  2749. /// <param name="base_addr">Base address</param>
  2750. /// <param name="vindex">Offset</param>
  2751. /// <param name="mask">Mask</param>
  2752. /// <param name="scale">Index scale</param>
  2753. /// <returns>Vector</returns>
  2754. [DebuggerStepThrough]
  2755. public static v128 mask_i32gather_epi32(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2756. {
  2757. v128 dst = src;
  2758. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SInt0, scale, 4, &mask.SInt0);
  2759. return dst;
  2760. }
  2761. /// <summary>
  2762. /// Gather 64-bit integers from memory using 32-bit indices. 64-bit
  2763. /// elements are loaded from addresses starting at base_addr and
  2764. /// offset by each 32-bit element in vindex (each index is scaled
  2765. /// by the factor in scale). Gathered elements are merged into dst
  2766. /// using mask (elements are copied from src when the highest bit
  2767. /// is not set in the corresponding element). scale should be 1, 2,
  2768. /// 4 or 8.
  2769. /// </summary>
  2770. /// <param name="src">Source</param>
  2771. /// <param name="base_addr">Base address</param>
  2772. /// <param name="vindex">Offset</param>
  2773. /// <param name="mask">Mask</param>
  2774. /// <param name="scale">Index scale</param>
  2775. /// <returns>Vector</returns>
  2776. [DebuggerStepThrough]
  2777. public static v128 mask_i32gather_epi64(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2778. {
  2779. v128 dst = src;
  2780. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SInt0, scale, 2, &mask.SLong0);
  2781. return dst;
  2782. }
  2783. /// <summary>
  2784. /// Gather 32-bit integers from memory using 64-bit indices. 32-bit
  2785. /// elements are loaded from addresses starting at base_addr and
  2786. /// offset by each 64-bit element in vindex (each index is scaled
  2787. /// by the factor in scale). Gathered elements are merged into dst
  2788. /// using mask (elements are copied from src when the highest bit
  2789. /// is not set in the corresponding element). scale should be 1, 2,
  2790. /// 4 or 8.
  2791. /// </summary>
  2792. /// <param name="src">Source</param>
  2793. /// <param name="base_addr">Base address</param>
  2794. /// <param name="vindex">Offset</param>
  2795. /// <param name="mask">Mask</param>
  2796. /// <param name="scale">Index scale</param>
  2797. /// <returns>Vector</returns>
  2798. [DebuggerStepThrough]
  2799. public static v128 mask_i64gather_epi32(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2800. {
  2801. v128 dst = src;
  2802. dst.UInt2 = dst.UInt3 = 0;
  2803. EmulatedGather<int, int>(&dst.SInt0, base_addr, &vindex.SLong0, scale, 2, &mask.SInt0);
  2804. return dst;
  2805. }
  2806. /// <summary>
  2807. /// Gather 64-bit integers from memory using 64-bit indices. 64-bit
  2808. /// elements are loaded from addresses starting at base_addr and
  2809. /// offset by each 64-bit element in vindex (each index is scaled
  2810. /// by the factor in scale). Gathered elements are merged into dst
  2811. /// using mask (elements are copied from src when the highest bit
  2812. /// is not set in the corresponding element). scale should be 1, 2,
  2813. /// 4 or 8.
  2814. /// </summary>
  2815. /// <param name="src">Source</param>
  2816. /// <param name="base_addr">Base address</param>
  2817. /// <param name="vindex">Offset</param>
  2818. /// <param name="mask">Mask</param>
  2819. /// <param name="scale">Index scale</param>
  2820. /// <returns>Vector</returns>
  2821. [DebuggerStepThrough]
  2822. public static v128 mask_i64gather_epi64(v128 src, void* base_addr, v128 vindex, v128 mask, int scale)
  2823. {
  2824. v128 dst = src;
  2825. EmulatedGather<long, long>(&dst.SLong0, base_addr, &vindex.SLong0, scale, 2, &mask.SLong0);
  2826. return dst;
  2827. }
  2828. }
  2829. }
  2830. }