Path: blob/master/tools/android-sdk/renderscript/clang-include/emmintrin.h
496 views
/*===---- emmintrin.h - SSE2 intrinsics ------------------------------------===1*2* Permission is hereby granted, free of charge, to any person obtaining a copy3* of this software and associated documentation files (the "Software"), to deal4* in the Software without restriction, including without limitation the rights5* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell6* copies of the Software, and to permit persons to whom the Software is7* furnished to do so, subject to the following conditions:8*9* The above copyright notice and this permission notice shall be included in10* all copies or substantial portions of the Software.11*12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE15* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER16* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,17* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN18* THE SOFTWARE.19*20*===-----------------------------------------------------------------------===21*/2223#ifndef __EMMINTRIN_H24#define __EMMINTRIN_H2526#include <xmmintrin.h>2728typedef double __m128d __attribute__((__vector_size__(16)));29typedef long long __m128i __attribute__((__vector_size__(16)));3031/* Type defines. */32typedef double __v2df __attribute__ ((__vector_size__ (16)));33typedef long long __v2di __attribute__ ((__vector_size__ (16)));34typedef short __v8hi __attribute__((__vector_size__(16)));35typedef char __v16qi __attribute__((__vector_size__(16)));3637/* Unsigned types */38typedef unsigned long long __v2du __attribute__ ((__vector_size__ (16)));39typedef unsigned short __v8hu __attribute__((__vector_size__(16)));40typedef unsigned char __v16qu __attribute__((__vector_size__(16)));4142/* We need an explicitly signed variant for char. Note that this shouldn't43* appear in the interface though. */44typedef signed char __v16qs __attribute__((__vector_size__(16)));4546#include <f16cintrin.h>4748/* Define the default attributes for the functions in this file. */49#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))5051static __inline__ __m128d __DEFAULT_FN_ATTRS52_mm_add_sd(__m128d __a, __m128d __b)53{54__a[0] += __b[0];55return __a;56}5758static __inline__ __m128d __DEFAULT_FN_ATTRS59_mm_add_pd(__m128d __a, __m128d __b)60{61return (__m128d)((__v2df)__a + (__v2df)__b);62}6364static __inline__ __m128d __DEFAULT_FN_ATTRS65_mm_sub_sd(__m128d __a, __m128d __b)66{67__a[0] -= __b[0];68return __a;69}7071static __inline__ __m128d __DEFAULT_FN_ATTRS72_mm_sub_pd(__m128d __a, __m128d __b)73{74return (__m128d)((__v2df)__a - (__v2df)__b);75}7677static __inline__ __m128d __DEFAULT_FN_ATTRS78_mm_mul_sd(__m128d __a, __m128d __b)79{80__a[0] *= __b[0];81return __a;82}8384static __inline__ __m128d __DEFAULT_FN_ATTRS85_mm_mul_pd(__m128d __a, __m128d __b)86{87return (__m128d)((__v2df)__a * (__v2df)__b);88}8990static __inline__ __m128d __DEFAULT_FN_ATTRS91_mm_div_sd(__m128d __a, __m128d __b)92{93__a[0] /= __b[0];94return __a;95}9697static __inline__ __m128d __DEFAULT_FN_ATTRS98_mm_div_pd(__m128d __a, __m128d __b)99{100return (__m128d)((__v2df)__a / (__v2df)__b);101}102103static __inline__ __m128d __DEFAULT_FN_ATTRS104_mm_sqrt_sd(__m128d __a, __m128d __b)105{106__m128d __c = __builtin_ia32_sqrtsd((__v2df)__b);107return (__m128d) { __c[0], __a[1] };108}109110static __inline__ __m128d __DEFAULT_FN_ATTRS111_mm_sqrt_pd(__m128d __a)112{113return __builtin_ia32_sqrtpd((__v2df)__a);114}115116static __inline__ __m128d __DEFAULT_FN_ATTRS117_mm_min_sd(__m128d __a, __m128d __b)118{119return __builtin_ia32_minsd((__v2df)__a, (__v2df)__b);120}121122static __inline__ __m128d __DEFAULT_FN_ATTRS123_mm_min_pd(__m128d __a, __m128d __b)124{125return __builtin_ia32_minpd((__v2df)__a, (__v2df)__b);126}127128static __inline__ __m128d __DEFAULT_FN_ATTRS129_mm_max_sd(__m128d __a, __m128d __b)130{131return __builtin_ia32_maxsd((__v2df)__a, (__v2df)__b);132}133134static __inline__ __m128d __DEFAULT_FN_ATTRS135_mm_max_pd(__m128d __a, __m128d __b)136{137return __builtin_ia32_maxpd((__v2df)__a, (__v2df)__b);138}139140static __inline__ __m128d __DEFAULT_FN_ATTRS141_mm_and_pd(__m128d __a, __m128d __b)142{143return (__m128d)((__v4su)__a & (__v4su)__b);144}145146static __inline__ __m128d __DEFAULT_FN_ATTRS147_mm_andnot_pd(__m128d __a, __m128d __b)148{149return (__m128d)(~(__v4su)__a & (__v4su)__b);150}151152static __inline__ __m128d __DEFAULT_FN_ATTRS153_mm_or_pd(__m128d __a, __m128d __b)154{155return (__m128d)((__v4su)__a | (__v4su)__b);156}157158static __inline__ __m128d __DEFAULT_FN_ATTRS159_mm_xor_pd(__m128d __a, __m128d __b)160{161return (__m128d)((__v4su)__a ^ (__v4su)__b);162}163164static __inline__ __m128d __DEFAULT_FN_ATTRS165_mm_cmpeq_pd(__m128d __a, __m128d __b)166{167return (__m128d)__builtin_ia32_cmpeqpd((__v2df)__a, (__v2df)__b);168}169170static __inline__ __m128d __DEFAULT_FN_ATTRS171_mm_cmplt_pd(__m128d __a, __m128d __b)172{173return (__m128d)__builtin_ia32_cmpltpd((__v2df)__a, (__v2df)__b);174}175176static __inline__ __m128d __DEFAULT_FN_ATTRS177_mm_cmple_pd(__m128d __a, __m128d __b)178{179return (__m128d)__builtin_ia32_cmplepd((__v2df)__a, (__v2df)__b);180}181182static __inline__ __m128d __DEFAULT_FN_ATTRS183_mm_cmpgt_pd(__m128d __a, __m128d __b)184{185return (__m128d)__builtin_ia32_cmpltpd((__v2df)__b, (__v2df)__a);186}187188static __inline__ __m128d __DEFAULT_FN_ATTRS189_mm_cmpge_pd(__m128d __a, __m128d __b)190{191return (__m128d)__builtin_ia32_cmplepd((__v2df)__b, (__v2df)__a);192}193194static __inline__ __m128d __DEFAULT_FN_ATTRS195_mm_cmpord_pd(__m128d __a, __m128d __b)196{197return (__m128d)__builtin_ia32_cmpordpd((__v2df)__a, (__v2df)__b);198}199200static __inline__ __m128d __DEFAULT_FN_ATTRS201_mm_cmpunord_pd(__m128d __a, __m128d __b)202{203return (__m128d)__builtin_ia32_cmpunordpd((__v2df)__a, (__v2df)__b);204}205206static __inline__ __m128d __DEFAULT_FN_ATTRS207_mm_cmpneq_pd(__m128d __a, __m128d __b)208{209return (__m128d)__builtin_ia32_cmpneqpd((__v2df)__a, (__v2df)__b);210}211212static __inline__ __m128d __DEFAULT_FN_ATTRS213_mm_cmpnlt_pd(__m128d __a, __m128d __b)214{215return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__a, (__v2df)__b);216}217218static __inline__ __m128d __DEFAULT_FN_ATTRS219_mm_cmpnle_pd(__m128d __a, __m128d __b)220{221return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__a, (__v2df)__b);222}223224static __inline__ __m128d __DEFAULT_FN_ATTRS225_mm_cmpngt_pd(__m128d __a, __m128d __b)226{227return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__b, (__v2df)__a);228}229230static __inline__ __m128d __DEFAULT_FN_ATTRS231_mm_cmpnge_pd(__m128d __a, __m128d __b)232{233return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__b, (__v2df)__a);234}235236static __inline__ __m128d __DEFAULT_FN_ATTRS237_mm_cmpeq_sd(__m128d __a, __m128d __b)238{239return (__m128d)__builtin_ia32_cmpeqsd((__v2df)__a, (__v2df)__b);240}241242static __inline__ __m128d __DEFAULT_FN_ATTRS243_mm_cmplt_sd(__m128d __a, __m128d __b)244{245return (__m128d)__builtin_ia32_cmpltsd((__v2df)__a, (__v2df)__b);246}247248static __inline__ __m128d __DEFAULT_FN_ATTRS249_mm_cmple_sd(__m128d __a, __m128d __b)250{251return (__m128d)__builtin_ia32_cmplesd((__v2df)__a, (__v2df)__b);252}253254static __inline__ __m128d __DEFAULT_FN_ATTRS255_mm_cmpgt_sd(__m128d __a, __m128d __b)256{257__m128d __c = __builtin_ia32_cmpltsd((__v2df)__b, (__v2df)__a);258return (__m128d) { __c[0], __a[1] };259}260261static __inline__ __m128d __DEFAULT_FN_ATTRS262_mm_cmpge_sd(__m128d __a, __m128d __b)263{264__m128d __c = __builtin_ia32_cmplesd((__v2df)__b, (__v2df)__a);265return (__m128d) { __c[0], __a[1] };266}267268static __inline__ __m128d __DEFAULT_FN_ATTRS269_mm_cmpord_sd(__m128d __a, __m128d __b)270{271return (__m128d)__builtin_ia32_cmpordsd((__v2df)__a, (__v2df)__b);272}273274static __inline__ __m128d __DEFAULT_FN_ATTRS275_mm_cmpunord_sd(__m128d __a, __m128d __b)276{277return (__m128d)__builtin_ia32_cmpunordsd((__v2df)__a, (__v2df)__b);278}279280static __inline__ __m128d __DEFAULT_FN_ATTRS281_mm_cmpneq_sd(__m128d __a, __m128d __b)282{283return (__m128d)__builtin_ia32_cmpneqsd((__v2df)__a, (__v2df)__b);284}285286static __inline__ __m128d __DEFAULT_FN_ATTRS287_mm_cmpnlt_sd(__m128d __a, __m128d __b)288{289return (__m128d)__builtin_ia32_cmpnltsd((__v2df)__a, (__v2df)__b);290}291292static __inline__ __m128d __DEFAULT_FN_ATTRS293_mm_cmpnle_sd(__m128d __a, __m128d __b)294{295return (__m128d)__builtin_ia32_cmpnlesd((__v2df)__a, (__v2df)__b);296}297298static __inline__ __m128d __DEFAULT_FN_ATTRS299_mm_cmpngt_sd(__m128d __a, __m128d __b)300{301__m128d __c = __builtin_ia32_cmpnltsd((__v2df)__b, (__v2df)__a);302return (__m128d) { __c[0], __a[1] };303}304305static __inline__ __m128d __DEFAULT_FN_ATTRS306_mm_cmpnge_sd(__m128d __a, __m128d __b)307{308__m128d __c = __builtin_ia32_cmpnlesd((__v2df)__b, (__v2df)__a);309return (__m128d) { __c[0], __a[1] };310}311312static __inline__ int __DEFAULT_FN_ATTRS313_mm_comieq_sd(__m128d __a, __m128d __b)314{315return __builtin_ia32_comisdeq((__v2df)__a, (__v2df)__b);316}317318static __inline__ int __DEFAULT_FN_ATTRS319_mm_comilt_sd(__m128d __a, __m128d __b)320{321return __builtin_ia32_comisdlt((__v2df)__a, (__v2df)__b);322}323324static __inline__ int __DEFAULT_FN_ATTRS325_mm_comile_sd(__m128d __a, __m128d __b)326{327return __builtin_ia32_comisdle((__v2df)__a, (__v2df)__b);328}329330static __inline__ int __DEFAULT_FN_ATTRS331_mm_comigt_sd(__m128d __a, __m128d __b)332{333return __builtin_ia32_comisdgt((__v2df)__a, (__v2df)__b);334}335336static __inline__ int __DEFAULT_FN_ATTRS337_mm_comige_sd(__m128d __a, __m128d __b)338{339return __builtin_ia32_comisdge((__v2df)__a, (__v2df)__b);340}341342static __inline__ int __DEFAULT_FN_ATTRS343_mm_comineq_sd(__m128d __a, __m128d __b)344{345return __builtin_ia32_comisdneq((__v2df)__a, (__v2df)__b);346}347348static __inline__ int __DEFAULT_FN_ATTRS349_mm_ucomieq_sd(__m128d __a, __m128d __b)350{351return __builtin_ia32_ucomisdeq((__v2df)__a, (__v2df)__b);352}353354static __inline__ int __DEFAULT_FN_ATTRS355_mm_ucomilt_sd(__m128d __a, __m128d __b)356{357return __builtin_ia32_ucomisdlt((__v2df)__a, (__v2df)__b);358}359360static __inline__ int __DEFAULT_FN_ATTRS361_mm_ucomile_sd(__m128d __a, __m128d __b)362{363return __builtin_ia32_ucomisdle((__v2df)__a, (__v2df)__b);364}365366static __inline__ int __DEFAULT_FN_ATTRS367_mm_ucomigt_sd(__m128d __a, __m128d __b)368{369return __builtin_ia32_ucomisdgt((__v2df)__a, (__v2df)__b);370}371372static __inline__ int __DEFAULT_FN_ATTRS373_mm_ucomige_sd(__m128d __a, __m128d __b)374{375return __builtin_ia32_ucomisdge((__v2df)__a, (__v2df)__b);376}377378static __inline__ int __DEFAULT_FN_ATTRS379_mm_ucomineq_sd(__m128d __a, __m128d __b)380{381return __builtin_ia32_ucomisdneq((__v2df)__a, (__v2df)__b);382}383384static __inline__ __m128 __DEFAULT_FN_ATTRS385_mm_cvtpd_ps(__m128d __a)386{387return __builtin_ia32_cvtpd2ps((__v2df)__a);388}389390static __inline__ __m128d __DEFAULT_FN_ATTRS391_mm_cvtps_pd(__m128 __a)392{393return (__m128d) __builtin_convertvector(394__builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1), __v2df);395}396397static __inline__ __m128d __DEFAULT_FN_ATTRS398_mm_cvtepi32_pd(__m128i __a)399{400return (__m128d) __builtin_convertvector(401__builtin_shufflevector((__v4si)__a, (__v4si)__a, 0, 1), __v2df);402}403404static __inline__ __m128i __DEFAULT_FN_ATTRS405_mm_cvtpd_epi32(__m128d __a)406{407return __builtin_ia32_cvtpd2dq((__v2df)__a);408}409410static __inline__ int __DEFAULT_FN_ATTRS411_mm_cvtsd_si32(__m128d __a)412{413return __builtin_ia32_cvtsd2si((__v2df)__a);414}415416static __inline__ __m128 __DEFAULT_FN_ATTRS417_mm_cvtsd_ss(__m128 __a, __m128d __b)418{419__a[0] = __b[0];420return __a;421}422423static __inline__ __m128d __DEFAULT_FN_ATTRS424_mm_cvtsi32_sd(__m128d __a, int __b)425{426__a[0] = __b;427return __a;428}429430static __inline__ __m128d __DEFAULT_FN_ATTRS431_mm_cvtss_sd(__m128d __a, __m128 __b)432{433__a[0] = __b[0];434return __a;435}436437static __inline__ __m128i __DEFAULT_FN_ATTRS438_mm_cvttpd_epi32(__m128d __a)439{440return (__m128i)__builtin_ia32_cvttpd2dq((__v2df)__a);441}442443static __inline__ int __DEFAULT_FN_ATTRS444_mm_cvttsd_si32(__m128d __a)445{446return __a[0];447}448449static __inline__ __m64 __DEFAULT_FN_ATTRS450_mm_cvtpd_pi32(__m128d __a)451{452return (__m64)__builtin_ia32_cvtpd2pi((__v2df)__a);453}454455static __inline__ __m64 __DEFAULT_FN_ATTRS456_mm_cvttpd_pi32(__m128d __a)457{458return (__m64)__builtin_ia32_cvttpd2pi((__v2df)__a);459}460461static __inline__ __m128d __DEFAULT_FN_ATTRS462_mm_cvtpi32_pd(__m64 __a)463{464return __builtin_ia32_cvtpi2pd((__v2si)__a);465}466467static __inline__ double __DEFAULT_FN_ATTRS468_mm_cvtsd_f64(__m128d __a)469{470return __a[0];471}472473static __inline__ __m128d __DEFAULT_FN_ATTRS474_mm_load_pd(double const *__dp)475{476return *(__m128d*)__dp;477}478479static __inline__ __m128d __DEFAULT_FN_ATTRS480_mm_load1_pd(double const *__dp)481{482struct __mm_load1_pd_struct {483double __u;484} __attribute__((__packed__, __may_alias__));485double __u = ((struct __mm_load1_pd_struct*)__dp)->__u;486return (__m128d){ __u, __u };487}488489#define _mm_load_pd1(dp) _mm_load1_pd(dp)490491static __inline__ __m128d __DEFAULT_FN_ATTRS492_mm_loadr_pd(double const *__dp)493{494__m128d __u = *(__m128d*)__dp;495return __builtin_shufflevector((__v2df)__u, (__v2df)__u, 1, 0);496}497498static __inline__ __m128d __DEFAULT_FN_ATTRS499_mm_loadu_pd(double const *__dp)500{501struct __loadu_pd {502__m128d __v;503} __attribute__((__packed__, __may_alias__));504return ((struct __loadu_pd*)__dp)->__v;505}506507static __inline__ __m128i __DEFAULT_FN_ATTRS508_mm_loadu_si64(void const *__a)509{510struct __loadu_si64 {511long long __v;512} __attribute__((__packed__, __may_alias__));513long long __u = ((struct __loadu_si64*)__a)->__v;514return (__m128i){__u, 0L};515}516517static __inline__ __m128d __DEFAULT_FN_ATTRS518_mm_load_sd(double const *__dp)519{520struct __mm_load_sd_struct {521double __u;522} __attribute__((__packed__, __may_alias__));523double __u = ((struct __mm_load_sd_struct*)__dp)->__u;524return (__m128d){ __u, 0 };525}526527static __inline__ __m128d __DEFAULT_FN_ATTRS528_mm_loadh_pd(__m128d __a, double const *__dp)529{530struct __mm_loadh_pd_struct {531double __u;532} __attribute__((__packed__, __may_alias__));533double __u = ((struct __mm_loadh_pd_struct*)__dp)->__u;534return (__m128d){ __a[0], __u };535}536537static __inline__ __m128d __DEFAULT_FN_ATTRS538_mm_loadl_pd(__m128d __a, double const *__dp)539{540struct __mm_loadl_pd_struct {541double __u;542} __attribute__((__packed__, __may_alias__));543double __u = ((struct __mm_loadl_pd_struct*)__dp)->__u;544return (__m128d){ __u, __a[1] };545}546547static __inline__ __m128d __DEFAULT_FN_ATTRS548_mm_undefined_pd(void)549{550return (__m128d)__builtin_ia32_undef128();551}552553static __inline__ __m128d __DEFAULT_FN_ATTRS554_mm_set_sd(double __w)555{556return (__m128d){ __w, 0 };557}558559static __inline__ __m128d __DEFAULT_FN_ATTRS560_mm_set1_pd(double __w)561{562return (__m128d){ __w, __w };563}564565static __inline__ __m128d __DEFAULT_FN_ATTRS566_mm_set_pd(double __w, double __x)567{568return (__m128d){ __x, __w };569}570571static __inline__ __m128d __DEFAULT_FN_ATTRS572_mm_setr_pd(double __w, double __x)573{574return (__m128d){ __w, __x };575}576577static __inline__ __m128d __DEFAULT_FN_ATTRS578_mm_setzero_pd(void)579{580return (__m128d){ 0, 0 };581}582583static __inline__ __m128d __DEFAULT_FN_ATTRS584_mm_move_sd(__m128d __a, __m128d __b)585{586return (__m128d){ __b[0], __a[1] };587}588589static __inline__ void __DEFAULT_FN_ATTRS590_mm_store_sd(double *__dp, __m128d __a)591{592struct __mm_store_sd_struct {593double __u;594} __attribute__((__packed__, __may_alias__));595((struct __mm_store_sd_struct*)__dp)->__u = __a[0];596}597598static __inline__ void __DEFAULT_FN_ATTRS599_mm_store_pd(double *__dp, __m128d __a)600{601*(__m128d*)__dp = __a;602}603604static __inline__ void __DEFAULT_FN_ATTRS605_mm_store1_pd(double *__dp, __m128d __a)606{607__a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);608_mm_store_pd(__dp, __a);609}610611static __inline__ void __DEFAULT_FN_ATTRS612_mm_store_pd1(double *__dp, __m128d __a)613{614return _mm_store1_pd(__dp, __a);615}616617static __inline__ void __DEFAULT_FN_ATTRS618_mm_storeu_pd(double *__dp, __m128d __a)619{620struct __storeu_pd {621__m128d __v;622} __attribute__((__packed__, __may_alias__));623((struct __storeu_pd*)__dp)->__v = __a;624}625626static __inline__ void __DEFAULT_FN_ATTRS627_mm_storer_pd(double *__dp, __m128d __a)628{629__a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 1, 0);630*(__m128d *)__dp = __a;631}632633static __inline__ void __DEFAULT_FN_ATTRS634_mm_storeh_pd(double *__dp, __m128d __a)635{636struct __mm_storeh_pd_struct {637double __u;638} __attribute__((__packed__, __may_alias__));639((struct __mm_storeh_pd_struct*)__dp)->__u = __a[1];640}641642static __inline__ void __DEFAULT_FN_ATTRS643_mm_storel_pd(double *__dp, __m128d __a)644{645struct __mm_storeh_pd_struct {646double __u;647} __attribute__((__packed__, __may_alias__));648((struct __mm_storeh_pd_struct*)__dp)->__u = __a[0];649}650651static __inline__ __m128i __DEFAULT_FN_ATTRS652_mm_add_epi8(__m128i __a, __m128i __b)653{654return (__m128i)((__v16qu)__a + (__v16qu)__b);655}656657static __inline__ __m128i __DEFAULT_FN_ATTRS658_mm_add_epi16(__m128i __a, __m128i __b)659{660return (__m128i)((__v8hu)__a + (__v8hu)__b);661}662663static __inline__ __m128i __DEFAULT_FN_ATTRS664_mm_add_epi32(__m128i __a, __m128i __b)665{666return (__m128i)((__v4su)__a + (__v4su)__b);667}668669static __inline__ __m64 __DEFAULT_FN_ATTRS670_mm_add_si64(__m64 __a, __m64 __b)671{672return (__m64)__builtin_ia32_paddq((__v1di)__a, (__v1di)__b);673}674675static __inline__ __m128i __DEFAULT_FN_ATTRS676_mm_add_epi64(__m128i __a, __m128i __b)677{678return (__m128i)((__v2du)__a + (__v2du)__b);679}680681static __inline__ __m128i __DEFAULT_FN_ATTRS682_mm_adds_epi8(__m128i __a, __m128i __b)683{684return (__m128i)__builtin_ia32_paddsb128((__v16qi)__a, (__v16qi)__b);685}686687static __inline__ __m128i __DEFAULT_FN_ATTRS688_mm_adds_epi16(__m128i __a, __m128i __b)689{690return (__m128i)__builtin_ia32_paddsw128((__v8hi)__a, (__v8hi)__b);691}692693static __inline__ __m128i __DEFAULT_FN_ATTRS694_mm_adds_epu8(__m128i __a, __m128i __b)695{696return (__m128i)__builtin_ia32_paddusb128((__v16qi)__a, (__v16qi)__b);697}698699static __inline__ __m128i __DEFAULT_FN_ATTRS700_mm_adds_epu16(__m128i __a, __m128i __b)701{702return (__m128i)__builtin_ia32_paddusw128((__v8hi)__a, (__v8hi)__b);703}704705static __inline__ __m128i __DEFAULT_FN_ATTRS706_mm_avg_epu8(__m128i __a, __m128i __b)707{708return (__m128i)__builtin_ia32_pavgb128((__v16qi)__a, (__v16qi)__b);709}710711static __inline__ __m128i __DEFAULT_FN_ATTRS712_mm_avg_epu16(__m128i __a, __m128i __b)713{714return (__m128i)__builtin_ia32_pavgw128((__v8hi)__a, (__v8hi)__b);715}716717static __inline__ __m128i __DEFAULT_FN_ATTRS718_mm_madd_epi16(__m128i __a, __m128i __b)719{720return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)__a, (__v8hi)__b);721}722723static __inline__ __m128i __DEFAULT_FN_ATTRS724_mm_max_epi16(__m128i __a, __m128i __b)725{726return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)__a, (__v8hi)__b);727}728729static __inline__ __m128i __DEFAULT_FN_ATTRS730_mm_max_epu8(__m128i __a, __m128i __b)731{732return (__m128i)__builtin_ia32_pmaxub128((__v16qi)__a, (__v16qi)__b);733}734735static __inline__ __m128i __DEFAULT_FN_ATTRS736_mm_min_epi16(__m128i __a, __m128i __b)737{738return (__m128i)__builtin_ia32_pminsw128((__v8hi)__a, (__v8hi)__b);739}740741static __inline__ __m128i __DEFAULT_FN_ATTRS742_mm_min_epu8(__m128i __a, __m128i __b)743{744return (__m128i)__builtin_ia32_pminub128((__v16qi)__a, (__v16qi)__b);745}746747static __inline__ __m128i __DEFAULT_FN_ATTRS748_mm_mulhi_epi16(__m128i __a, __m128i __b)749{750return (__m128i)__builtin_ia32_pmulhw128((__v8hi)__a, (__v8hi)__b);751}752753static __inline__ __m128i __DEFAULT_FN_ATTRS754_mm_mulhi_epu16(__m128i __a, __m128i __b)755{756return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b);757}758759/// \brief Multiplies the corresponding elements of two [8 x short] vectors and760/// returns a vector containing the low-order 16 bits of each 32-bit product761/// in the corresponding element.762///763/// \headerfile <x86intrin.h>764///765/// This intrinsic corresponds to the \c VPMULLW / PMULLW instruction.766///767/// \param __a768/// A 128-bit integer vector containing one of the source operands.769/// \param __b770/// A 128-bit integer vector containing one of the source operands.771/// \returns A 128-bit integer vector containing the products of both operands.772static __inline__ __m128i __DEFAULT_FN_ATTRS773_mm_mullo_epi16(__m128i __a, __m128i __b)774{775return (__m128i)((__v8hu)__a * (__v8hu)__b);776}777778/// \brief Multiplies 32-bit unsigned integer values contained in the lower bits779/// of the two 64-bit integer vectors and returns the 64-bit unsigned780/// product.781///782/// \headerfile <x86intrin.h>783///784/// This intrinsic corresponds to the \c PMULUDQ instruction.785///786/// \param __a787/// A 64-bit integer containing one of the source operands.788/// \param __b789/// A 64-bit integer containing one of the source operands.790/// \returns A 64-bit integer vector containing the product of both operands.791static __inline__ __m64 __DEFAULT_FN_ATTRS792_mm_mul_su32(__m64 __a, __m64 __b)793{794return __builtin_ia32_pmuludq((__v2si)__a, (__v2si)__b);795}796797/// \brief Multiplies 32-bit unsigned integer values contained in the lower798/// bits of the corresponding elements of two [2 x i64] vectors, and returns799/// the 64-bit products in the corresponding elements of a [2 x i64] vector.800///801/// \headerfile <x86intrin.h>802///803/// This intrinsic corresponds to the \c VPMULUDQ / PMULUDQ instruction.804///805/// \param __a806/// A [2 x i64] vector containing one of the source operands.807/// \param __b808/// A [2 x i64] vector containing one of the source operands.809/// \returns A [2 x i64] vector containing the product of both operands.810static __inline__ __m128i __DEFAULT_FN_ATTRS811_mm_mul_epu32(__m128i __a, __m128i __b)812{813return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b);814}815816/// \brief Computes the absolute differences of corresponding 8-bit integer817/// values in two 128-bit vectors. Sums the first 8 absolute differences, and818/// separately sums the second 8 absolute differences. Packss these two819/// unsigned 16-bit integer sums into the upper and lower elements of a820/// [2 x i64] vector.821///822/// \headerfile <x86intrin.h>823///824/// This intrinsic corresponds to the \c VPSADBW / PSADBW instruction.825///826/// \param __a827/// A 128-bit integer vector containing one of the source operands.828/// \param __b829/// A 128-bit integer vector containing one of the source operands.830/// \returns A [2 x i64] vector containing the sums of the sets of absolute831/// differences between both operands.832static __inline__ __m128i __DEFAULT_FN_ATTRS833_mm_sad_epu8(__m128i __a, __m128i __b)834{835return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b);836}837838/// \brief Subtracts the corresponding 8-bit integer values in the operands.839///840/// \headerfile <x86intrin.h>841///842/// This intrinsic corresponds to the \c VPSUBB / PSUBB instruction.843///844/// \param __a845/// A 128-bit integer vector containing the minuends.846/// \param __b847/// A 128-bit integer vector containing the subtrahends.848/// \returns A 128-bit integer vector containing the differences of the values849/// in the operands.850static __inline__ __m128i __DEFAULT_FN_ATTRS851_mm_sub_epi8(__m128i __a, __m128i __b)852{853return (__m128i)((__v16qu)__a - (__v16qu)__b);854}855856/// \brief Subtracts the corresponding 16-bit integer values in the operands.857///858/// \headerfile <x86intrin.h>859///860/// This intrinsic corresponds to the \c VPSUBW / PSUBW instruction.861///862/// \param __a863/// A 128-bit integer vector containing the minuends.864/// \param __b865/// A 128-bit integer vector containing the subtrahends.866/// \returns A 128-bit integer vector containing the differences of the values867/// in the operands.868static __inline__ __m128i __DEFAULT_FN_ATTRS869_mm_sub_epi16(__m128i __a, __m128i __b)870{871return (__m128i)((__v8hu)__a - (__v8hu)__b);872}873874/// \brief Subtracts the corresponding 32-bit integer values in the operands.875///876/// \headerfile <x86intrin.h>877///878/// This intrinsic corresponds to the \c VPSUBD / PSUBD instruction.879///880/// \param __a881/// A 128-bit integer vector containing the minuends.882/// \param __b883/// A 128-bit integer vector containing the subtrahends.884/// \returns A 128-bit integer vector containing the differences of the values885/// in the operands.886static __inline__ __m128i __DEFAULT_FN_ATTRS887_mm_sub_epi32(__m128i __a, __m128i __b)888{889return (__m128i)((__v4su)__a - (__v4su)__b);890}891892/// \brief Subtracts signed or unsigned 64-bit integer values and writes the893/// difference to the corresponding bits in the destination.894///895/// \headerfile <x86intrin.h>896///897/// This intrinsic corresponds to the \c PSUBQ instruction.898///899/// \param __a900/// A 64-bit integer vector containing the minuend.901/// \param __b902/// A 64-bit integer vector containing the subtrahend.903/// \returns A 64-bit integer vector containing the difference of the values in904/// the operands.905static __inline__ __m64 __DEFAULT_FN_ATTRS906_mm_sub_si64(__m64 __a, __m64 __b)907{908return (__m64)__builtin_ia32_psubq((__v1di)__a, (__v1di)__b);909}910911/// \brief Subtracts the corresponding elements of two [2 x i64] vectors.912///913/// \headerfile <x86intrin.h>914///915/// This intrinsic corresponds to the \c VPSUBQ / PSUBQ instruction.916///917/// \param __a918/// A 128-bit integer vector containing the minuends.919/// \param __b920/// A 128-bit integer vector containing the subtrahends.921/// \returns A 128-bit integer vector containing the differences of the values922/// in the operands.923static __inline__ __m128i __DEFAULT_FN_ATTRS924_mm_sub_epi64(__m128i __a, __m128i __b)925{926return (__m128i)((__v2du)__a - (__v2du)__b);927}928929/// \brief Subtracts corresponding 8-bit signed integer values in the input and930/// returns the differences in the corresponding bytes in the destination.931/// Differences greater than 7Fh are saturated to 7Fh, and differences less932/// than 80h are saturated to 80h.933///934/// \headerfile <x86intrin.h>935///936/// This intrinsic corresponds to the \c VPSUBSB / PSUBSB instruction.937///938/// \param __a939/// A 128-bit integer vector containing the minuends.940/// \param __b941/// A 128-bit integer vector containing the subtrahends.942/// \returns A 128-bit integer vector containing the differences of the values943/// in the operands.944static __inline__ __m128i __DEFAULT_FN_ATTRS945_mm_subs_epi8(__m128i __a, __m128i __b)946{947return (__m128i)__builtin_ia32_psubsb128((__v16qi)__a, (__v16qi)__b);948}949950/// \brief Subtracts corresponding 16-bit signed integer values in the input and951/// returns the differences in the corresponding bytes in the destination.952/// Differences greater than 7FFFh are saturated to 7FFFh, and values less953/// than 8000h are saturated to 8000h.954///955/// \headerfile <x86intrin.h>956///957/// This intrinsic corresponds to the \c VPSUBSW / PSUBSW instruction.958///959/// \param __a960/// A 128-bit integer vector containing the minuends.961/// \param __b962/// A 128-bit integer vector containing the subtrahends.963/// \returns A 128-bit integer vector containing the differences of the values964/// in the operands.965static __inline__ __m128i __DEFAULT_FN_ATTRS966_mm_subs_epi16(__m128i __a, __m128i __b)967{968return (__m128i)__builtin_ia32_psubsw128((__v8hi)__a, (__v8hi)__b);969}970971/// \brief Subtracts corresponding 8-bit unsigned integer values in the input972/// and returns the differences in the corresponding bytes in the973/// destination. Differences less than 00h are saturated to 00h.974///975/// \headerfile <x86intrin.h>976///977/// This intrinsic corresponds to the \c VPSUBUSB / PSUBUSB instruction.978///979/// \param __a980/// A 128-bit integer vector containing the minuends.981/// \param __b982/// A 128-bit integer vector containing the subtrahends.983/// \returns A 128-bit integer vector containing the unsigned integer984/// differences of the values in the operands.985static __inline__ __m128i __DEFAULT_FN_ATTRS986_mm_subs_epu8(__m128i __a, __m128i __b)987{988return (__m128i)__builtin_ia32_psubusb128((__v16qi)__a, (__v16qi)__b);989}990991/// \brief Subtracts corresponding 16-bit unsigned integer values in the input992/// and returns the differences in the corresponding bytes in the993/// destination. Differences less than 0000h are saturated to 0000h.994///995/// \headerfile <x86intrin.h>996///997/// This intrinsic corresponds to the \c VPSUBUSW / PSUBUSW instruction.998///999/// \param __a1000/// A 128-bit integer vector containing the minuends.1001/// \param __b1002/// A 128-bit integer vector containing the subtrahends.1003/// \returns A 128-bit integer vector containing the unsigned integer1004/// differences of the values in the operands.1005static __inline__ __m128i __DEFAULT_FN_ATTRS1006_mm_subs_epu16(__m128i __a, __m128i __b)1007{1008return (__m128i)__builtin_ia32_psubusw128((__v8hi)__a, (__v8hi)__b);1009}10101011/// \brief Performs a bitwise AND of two 128-bit integer vectors.1012///1013/// \headerfile <x86intrin.h>1014///1015/// This intrinsic corresponds to the \c VPAND / PAND instruction.1016///1017/// \param __a1018/// A 128-bit integer vector containing one of the source operands.1019/// \param __b1020/// A 128-bit integer vector containing one of the source operands.1021/// \returns A 128-bit integer vector containing the bitwise AND of the values1022/// in both operands.1023static __inline__ __m128i __DEFAULT_FN_ATTRS1024_mm_and_si128(__m128i __a, __m128i __b)1025{1026return (__m128i)((__v2du)__a & (__v2du)__b);1027}10281029/// \brief Performs a bitwise AND of two 128-bit integer vectors, using the1030/// one's complement of the values contained in the first source operand.1031///1032/// \headerfile <x86intrin.h>1033///1034/// This intrinsic corresponds to the \c VPANDN / PANDN instruction.1035///1036/// \param __a1037/// A 128-bit vector containing the left source operand. The one's complement1038/// of this value is used in the bitwise AND.1039/// \param __b1040/// A 128-bit vector containing the right source operand.1041/// \returns A 128-bit integer vector containing the bitwise AND of the one's1042/// complement of the first operand and the values in the second operand.1043static __inline__ __m128i __DEFAULT_FN_ATTRS1044_mm_andnot_si128(__m128i __a, __m128i __b)1045{1046return (__m128i)(~(__v2du)__a & (__v2du)__b);1047}1048/// \brief Performs a bitwise OR of two 128-bit integer vectors.1049///1050/// \headerfile <x86intrin.h>1051///1052/// This intrinsic corresponds to the \c VPOR / POR instruction.1053///1054/// \param __a1055/// A 128-bit integer vector containing one of the source operands.1056/// \param __b1057/// A 128-bit integer vector containing one of the source operands.1058/// \returns A 128-bit integer vector containing the bitwise OR of the values1059/// in both operands.1060static __inline__ __m128i __DEFAULT_FN_ATTRS1061_mm_or_si128(__m128i __a, __m128i __b)1062{1063return (__m128i)((__v2du)__a | (__v2du)__b);1064}10651066/// \brief Performs a bitwise exclusive OR of two 128-bit integer vectors.1067///1068/// \headerfile <x86intrin.h>1069///1070/// This intrinsic corresponds to the \c VPXOR / PXOR instruction.1071///1072/// \param __a1073/// A 128-bit integer vector containing one of the source operands.1074/// \param __b1075/// A 128-bit integer vector containing one of the source operands.1076/// \returns A 128-bit integer vector containing the bitwise exclusive OR of the1077/// values in both operands.1078static __inline__ __m128i __DEFAULT_FN_ATTRS1079_mm_xor_si128(__m128i __a, __m128i __b)1080{1081return (__m128i)((__v2du)__a ^ (__v2du)__b);1082}10831084/// \brief Left-shifts the 128-bit integer vector operand by the specified1085/// number of bytes. Low-order bits are cleared.1086///1087/// \headerfile <x86intrin.h>1088///1089/// \code1090/// __m128i _mm_slli_si128(__m128i a, const int imm);1091/// \endcode1092///1093/// This intrinsic corresponds to the \c VPSLLDQ / PSLLDQ instruction.1094///1095/// \param a1096/// A 128-bit integer vector containing the source operand.1097/// \param imm1098/// An immediate value specifying the number of bytes to left-shift1099/// operand a.1100/// \returns A 128-bit integer vector containing the left-shifted value.1101#define _mm_slli_si128(a, imm) __extension__ ({ \1102(__m128i)__builtin_shufflevector( \1103(__v16qi)_mm_setzero_si128(), \1104(__v16qi)(__m128i)(a), \1105((char)(imm)&0xF0) ? 0 : 16 - (char)(imm), \1106((char)(imm)&0xF0) ? 1 : 17 - (char)(imm), \1107((char)(imm)&0xF0) ? 2 : 18 - (char)(imm), \1108((char)(imm)&0xF0) ? 3 : 19 - (char)(imm), \1109((char)(imm)&0xF0) ? 4 : 20 - (char)(imm), \1110((char)(imm)&0xF0) ? 5 : 21 - (char)(imm), \1111((char)(imm)&0xF0) ? 6 : 22 - (char)(imm), \1112((char)(imm)&0xF0) ? 7 : 23 - (char)(imm), \1113((char)(imm)&0xF0) ? 8 : 24 - (char)(imm), \1114((char)(imm)&0xF0) ? 9 : 25 - (char)(imm), \1115((char)(imm)&0xF0) ? 10 : 26 - (char)(imm), \1116((char)(imm)&0xF0) ? 11 : 27 - (char)(imm), \1117((char)(imm)&0xF0) ? 12 : 28 - (char)(imm), \1118((char)(imm)&0xF0) ? 13 : 29 - (char)(imm), \1119((char)(imm)&0xF0) ? 14 : 30 - (char)(imm), \1120((char)(imm)&0xF0) ? 15 : 31 - (char)(imm)); })11211122#define _mm_bslli_si128(a, imm) \1123_mm_slli_si128((a), (imm))11241125/// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand1126/// by the specified number of bits. Low-order bits are cleared.1127///1128/// \headerfile <x86intrin.h>1129///1130/// This intrinsic corresponds to the \c VPSLLW / PSLLW instruction.1131///1132/// \param __a1133/// A 128-bit integer vector containing the source operand.1134/// \param __count1135/// An integer value specifying the number of bits to left-shift each value1136/// in operand __a.1137/// \returns A 128-bit integer vector containing the left-shifted values.1138static __inline__ __m128i __DEFAULT_FN_ATTRS1139_mm_slli_epi16(__m128i __a, int __count)1140{1141return (__m128i)__builtin_ia32_psllwi128((__v8hi)__a, __count);1142}11431144/// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand1145/// by the specified number of bits. Low-order bits are cleared.1146///1147/// \headerfile <x86intrin.h>1148///1149/// This intrinsic corresponds to the \c VPSLLW / PSLLW instruction.1150///1151/// \param __a1152/// A 128-bit integer vector containing the source operand.1153/// \param __count1154/// A 128-bit integer vector in which bits [63:0] specify the number of bits1155/// to left-shift each value in operand __a.1156/// \returns A 128-bit integer vector containing the left-shifted values.1157static __inline__ __m128i __DEFAULT_FN_ATTRS1158_mm_sll_epi16(__m128i __a, __m128i __count)1159{1160return (__m128i)__builtin_ia32_psllw128((__v8hi)__a, (__v8hi)__count);1161}11621163/// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand1164/// by the specified number of bits. Low-order bits are cleared.1165///1166/// \headerfile <x86intrin.h>1167///1168/// This intrinsic corresponds to the \c VPSLLD / PSLLD instruction.1169///1170/// \param __a1171/// A 128-bit integer vector containing the source operand.1172/// \param __count1173/// An integer value specifying the number of bits to left-shift each value1174/// in operand __a.1175/// \returns A 128-bit integer vector containing the left-shifted values.1176static __inline__ __m128i __DEFAULT_FN_ATTRS1177_mm_slli_epi32(__m128i __a, int __count)1178{1179return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count);1180}11811182/// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand1183/// by the specified number of bits. Low-order bits are cleared.1184///1185/// \headerfile <x86intrin.h>1186///1187/// This intrinsic corresponds to the \c VPSLLD / PSLLD instruction.1188///1189/// \param __a1190/// A 128-bit integer vector containing the source operand.1191/// \param __count1192/// A 128-bit integer vector in which bits [63:0] specify the number of bits1193/// to left-shift each value in operand __a.1194/// \returns A 128-bit integer vector containing the left-shifted values.1195static __inline__ __m128i __DEFAULT_FN_ATTRS1196_mm_sll_epi32(__m128i __a, __m128i __count)1197{1198return (__m128i)__builtin_ia32_pslld128((__v4si)__a, (__v4si)__count);1199}12001201/// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand1202/// by the specified number of bits. Low-order bits are cleared.1203///1204/// \headerfile <x86intrin.h>1205///1206/// This intrinsic corresponds to the \c VPSLLQ / PSLLQ instruction.1207///1208/// \param __a1209/// A 128-bit integer vector containing the source operand.1210/// \param __count1211/// An integer value specifying the number of bits to left-shift each value1212/// in operand __a.1213/// \returns A 128-bit integer vector containing the left-shifted values.1214static __inline__ __m128i __DEFAULT_FN_ATTRS1215_mm_slli_epi64(__m128i __a, int __count)1216{1217return __builtin_ia32_psllqi128((__v2di)__a, __count);1218}12191220/// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand1221/// by the specified number of bits. Low-order bits are cleared.1222///1223/// \headerfile <x86intrin.h>1224///1225/// This intrinsic corresponds to the \c VPSLLQ / PSLLQ instruction.1226///1227/// \param __a1228/// A 128-bit integer vector containing the source operand.1229/// \param __count1230/// A 128-bit integer vector in which bits [63:0] specify the number of bits1231/// to left-shift each value in operand __a.1232/// \returns A 128-bit integer vector containing the left-shifted values.1233static __inline__ __m128i __DEFAULT_FN_ATTRS1234_mm_sll_epi64(__m128i __a, __m128i __count)1235{1236return __builtin_ia32_psllq128((__v2di)__a, (__v2di)__count);1237}12381239/// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand1240/// by the specified number of bits. High-order bits are filled with the sign1241/// bit of the initial value.1242///1243/// \headerfile <x86intrin.h>1244///1245/// This intrinsic corresponds to the \c VPSRAW / PSRAW instruction.1246///1247/// \param __a1248/// A 128-bit integer vector containing the source operand.1249/// \param __count1250/// An integer value specifying the number of bits to right-shift each value1251/// in operand __a.1252/// \returns A 128-bit integer vector containing the right-shifted values.1253static __inline__ __m128i __DEFAULT_FN_ATTRS1254_mm_srai_epi16(__m128i __a, int __count)1255{1256return (__m128i)__builtin_ia32_psrawi128((__v8hi)__a, __count);1257}12581259/// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand1260/// by the specified number of bits. High-order bits are filled with the sign1261/// bit of the initial value.1262///1263/// \headerfile <x86intrin.h>1264///1265/// This intrinsic corresponds to the \c VPSRAW / PSRAW instruction.1266///1267/// \param __a1268/// A 128-bit integer vector containing the source operand.1269/// \param __count1270/// A 128-bit integer vector in which bits [63:0] specify the number of bits1271/// to right-shift each value in operand __a.1272/// \returns A 128-bit integer vector containing the right-shifted values.1273static __inline__ __m128i __DEFAULT_FN_ATTRS1274_mm_sra_epi16(__m128i __a, __m128i __count)1275{1276return (__m128i)__builtin_ia32_psraw128((__v8hi)__a, (__v8hi)__count);1277}12781279/// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand1280/// by the specified number of bits. High-order bits are filled with the sign1281/// bit of the initial value.1282///1283/// \headerfile <x86intrin.h>1284///1285/// This intrinsic corresponds to the \c VPSRAD / PSRAD instruction.1286///1287/// \param __a1288/// A 128-bit integer vector containing the source operand.1289/// \param __count1290/// An integer value specifying the number of bits to right-shift each value1291/// in operand __a.1292/// \returns A 128-bit integer vector containing the right-shifted values.1293static __inline__ __m128i __DEFAULT_FN_ATTRS1294_mm_srai_epi32(__m128i __a, int __count)1295{1296return (__m128i)__builtin_ia32_psradi128((__v4si)__a, __count);1297}12981299/// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand1300/// by the specified number of bits. High-order bits are filled with the sign1301/// bit of the initial value.1302///1303/// \headerfile <x86intrin.h>1304///1305/// This intrinsic corresponds to the \c VPSRAD / PSRAD instruction.1306///1307/// \param __a1308/// A 128-bit integer vector containing the source operand.1309/// \param __count1310/// A 128-bit integer vector in which bits [63:0] specify the number of bits1311/// to right-shift each value in operand __a.1312/// \returns A 128-bit integer vector containing the right-shifted values.1313static __inline__ __m128i __DEFAULT_FN_ATTRS1314_mm_sra_epi32(__m128i __a, __m128i __count)1315{1316return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count);1317}13181319/// \brief Right-shifts the 128-bit integer vector operand by the specified1320/// number of bytes. High-order bits are cleared.1321///1322/// \headerfile <x86intrin.h>1323///1324/// \code1325/// __m128i _mm_srli_si128(__m128i a, const int imm);1326/// \endcode1327///1328/// This intrinsic corresponds to the \c VPSRLDQ / PSRLDQ instruction.1329///1330/// \param a1331/// A 128-bit integer vector containing the source operand.1332/// \param imm1333/// An immediate value specifying the number of bytes to right-shift operand1334/// a.1335/// \returns A 128-bit integer vector containing the right-shifted value.1336#define _mm_srli_si128(a, imm) __extension__ ({ \1337(__m128i)__builtin_shufflevector( \1338(__v16qi)(__m128i)(a), \1339(__v16qi)_mm_setzero_si128(), \1340((char)(imm)&0xF0) ? 16 : (char)(imm) + 0, \1341((char)(imm)&0xF0) ? 17 : (char)(imm) + 1, \1342((char)(imm)&0xF0) ? 18 : (char)(imm) + 2, \1343((char)(imm)&0xF0) ? 19 : (char)(imm) + 3, \1344((char)(imm)&0xF0) ? 20 : (char)(imm) + 4, \1345((char)(imm)&0xF0) ? 21 : (char)(imm) + 5, \1346((char)(imm)&0xF0) ? 22 : (char)(imm) + 6, \1347((char)(imm)&0xF0) ? 23 : (char)(imm) + 7, \1348((char)(imm)&0xF0) ? 24 : (char)(imm) + 8, \1349((char)(imm)&0xF0) ? 25 : (char)(imm) + 9, \1350((char)(imm)&0xF0) ? 26 : (char)(imm) + 10, \1351((char)(imm)&0xF0) ? 27 : (char)(imm) + 11, \1352((char)(imm)&0xF0) ? 28 : (char)(imm) + 12, \1353((char)(imm)&0xF0) ? 29 : (char)(imm) + 13, \1354((char)(imm)&0xF0) ? 30 : (char)(imm) + 14, \1355((char)(imm)&0xF0) ? 31 : (char)(imm) + 15); })13561357#define _mm_bsrli_si128(a, imm) \1358_mm_srli_si128((a), (imm))13591360/// \brief Right-shifts each of 16-bit values in the 128-bit integer vector1361/// operand by the specified number of bits. High-order bits are cleared.1362///1363/// \headerfile <x86intrin.h>1364///1365/// This intrinsic corresponds to the \c VPSRLW / PSRLW instruction.1366///1367/// \param __a1368/// A 128-bit integer vector containing the source operand.1369/// \param __count1370/// An integer value specifying the number of bits to right-shift each value1371/// in operand __a.1372/// \returns A 128-bit integer vector containing the right-shifted values.1373static __inline__ __m128i __DEFAULT_FN_ATTRS1374_mm_srli_epi16(__m128i __a, int __count)1375{1376return (__m128i)__builtin_ia32_psrlwi128((__v8hi)__a, __count);1377}13781379/// \brief Right-shifts each of 16-bit values in the 128-bit integer vector1380/// operand by the specified number of bits. High-order bits are cleared.1381///1382/// \headerfile <x86intrin.h>1383///1384/// This intrinsic corresponds to the \c VPSRLW / PSRLW instruction.1385///1386/// \param __a1387/// A 128-bit integer vector containing the source operand.1388/// \param __count1389/// A 128-bit integer vector in which bits [63:0] specify the number of bits1390/// to right-shift each value in operand __a.1391/// \returns A 128-bit integer vector containing the right-shifted values.1392static __inline__ __m128i __DEFAULT_FN_ATTRS1393_mm_srl_epi16(__m128i __a, __m128i __count)1394{1395return (__m128i)__builtin_ia32_psrlw128((__v8hi)__a, (__v8hi)__count);1396}13971398/// \brief Right-shifts each of 32-bit values in the 128-bit integer vector1399/// operand by the specified number of bits. High-order bits are cleared.1400///1401/// \headerfile <x86intrin.h>1402///1403/// This intrinsic corresponds to the \c VPSRLD / PSRLD instruction.1404///1405/// \param __a1406/// A 128-bit integer vector containing the source operand.1407/// \param __count1408/// An integer value specifying the number of bits to right-shift each value1409/// in operand __a.1410/// \returns A 128-bit integer vector containing the right-shifted values.1411static __inline__ __m128i __DEFAULT_FN_ATTRS1412_mm_srli_epi32(__m128i __a, int __count)1413{1414return (__m128i)__builtin_ia32_psrldi128((__v4si)__a, __count);1415}14161417/// \brief Right-shifts each of 32-bit values in the 128-bit integer vector1418/// operand by the specified number of bits. High-order bits are cleared.1419///1420/// \headerfile <x86intrin.h>1421///1422/// This intrinsic corresponds to the \c VPSRLD / PSRLD instruction.1423///1424/// \param __a1425/// A 128-bit integer vector containing the source operand.1426/// \param __count1427/// A 128-bit integer vector in which bits [63:0] specify the number of bits1428/// to right-shift each value in operand __a.1429/// \returns A 128-bit integer vector containing the right-shifted values.1430static __inline__ __m128i __DEFAULT_FN_ATTRS1431_mm_srl_epi32(__m128i __a, __m128i __count)1432{1433return (__m128i)__builtin_ia32_psrld128((__v4si)__a, (__v4si)__count);1434}14351436/// \brief Right-shifts each of 64-bit values in the 128-bit integer vector1437/// operand by the specified number of bits. High-order bits are cleared.1438///1439/// \headerfile <x86intrin.h>1440///1441/// This intrinsic corresponds to the \c VPSRLQ / PSRLQ instruction.1442///1443/// \param __a1444/// A 128-bit integer vector containing the source operand.1445/// \param __count1446/// An integer value specifying the number of bits to right-shift each value1447/// in operand __a.1448/// \returns A 128-bit integer vector containing the right-shifted values.1449static __inline__ __m128i __DEFAULT_FN_ATTRS1450_mm_srli_epi64(__m128i __a, int __count)1451{1452return __builtin_ia32_psrlqi128((__v2di)__a, __count);1453}14541455/// \brief Right-shifts each of 64-bit values in the 128-bit integer vector1456/// operand by the specified number of bits. High-order bits are cleared.1457///1458/// \headerfile <x86intrin.h>1459///1460/// This intrinsic corresponds to the \c VPSRLQ / PSRLQ instruction.1461///1462/// \param __a1463/// A 128-bit integer vector containing the source operand.1464/// \param __count1465/// A 128-bit integer vector in which bits [63:0] specify the number of bits1466/// to right-shift each value in operand __a.1467/// \returns A 128-bit integer vector containing the right-shifted values.1468static __inline__ __m128i __DEFAULT_FN_ATTRS1469_mm_srl_epi64(__m128i __a, __m128i __count)1470{1471return __builtin_ia32_psrlq128((__v2di)__a, (__v2di)__count);1472}14731474/// \brief Compares each of the corresponding 8-bit values of the 128-bit1475/// integer vectors for equality. Each comparison yields 0h for false, FFh1476/// for true.1477///1478/// \headerfile <x86intrin.h>1479///1480/// This intrinsic corresponds to the \c VPCMPEQB / PCMPEQB instruction.1481///1482/// \param __a1483/// A 128-bit integer vector.1484/// \param __b1485/// A 128-bit integer vector.1486/// \returns A 128-bit integer vector containing the comparison results.1487static __inline__ __m128i __DEFAULT_FN_ATTRS1488_mm_cmpeq_epi8(__m128i __a, __m128i __b)1489{1490return (__m128i)((__v16qi)__a == (__v16qi)__b);1491}14921493/// \brief Compares each of the corresponding 16-bit values of the 128-bit1494/// integer vectors for equality. Each comparison yields 0h for false, FFFFh1495/// for true.1496///1497/// \headerfile <x86intrin.h>1498///1499/// This intrinsic corresponds to the \c VPCMPEQW / PCMPEQW instruction.1500///1501/// \param __a1502/// A 128-bit integer vector.1503/// \param __b1504/// A 128-bit integer vector.1505/// \returns A 128-bit integer vector containing the comparison results.1506static __inline__ __m128i __DEFAULT_FN_ATTRS1507_mm_cmpeq_epi16(__m128i __a, __m128i __b)1508{1509return (__m128i)((__v8hi)__a == (__v8hi)__b);1510}15111512/// \brief Compares each of the corresponding 32-bit values of the 128-bit1513/// integer vectors for equality. Each comparison yields 0h for false,1514/// FFFFFFFFh for true.1515///1516/// \headerfile <x86intrin.h>1517///1518/// This intrinsic corresponds to the \c VPCMPEQD / PCMPEQD instruction.1519///1520/// \param __a1521/// A 128-bit integer vector.1522/// \param __b1523/// A 128-bit integer vector.1524/// \returns A 128-bit integer vector containing the comparison results.1525static __inline__ __m128i __DEFAULT_FN_ATTRS1526_mm_cmpeq_epi32(__m128i __a, __m128i __b)1527{1528return (__m128i)((__v4si)__a == (__v4si)__b);1529}15301531/// \brief Compares each of the corresponding signed 8-bit values of the 128-bit1532/// integer vectors to determine if the values in the first operand are1533/// greater than those in the second operand. Each comparison yields 0h for1534/// false, FFh for true.1535///1536/// \headerfile <x86intrin.h>1537///1538/// This intrinsic corresponds to the \c VPCMPGTB / PCMPGTB instruction.1539///1540/// \param __a1541/// A 128-bit integer vector.1542/// \param __b1543/// A 128-bit integer vector.1544/// \returns A 128-bit integer vector containing the comparison results.1545static __inline__ __m128i __DEFAULT_FN_ATTRS1546_mm_cmpgt_epi8(__m128i __a, __m128i __b)1547{1548/* This function always performs a signed comparison, but __v16qi is a char1549which may be signed or unsigned, so use __v16qs. */1550return (__m128i)((__v16qs)__a > (__v16qs)__b);1551}15521553/// \brief Compares each of the corresponding signed 16-bit values of the1554/// 128-bit integer vectors to determine if the values in the first operand1555/// are greater than those in the second operand. Each comparison yields 0h1556/// for false, FFFFh for true.1557///1558/// \headerfile <x86intrin.h>1559///1560/// This intrinsic corresponds to the \c VPCMPGTW / PCMPGTW instruction.1561///1562/// \param __a1563/// A 128-bit integer vector.1564/// \param __b1565/// A 128-bit integer vector.1566/// \returns A 128-bit integer vector containing the comparison results.1567static __inline__ __m128i __DEFAULT_FN_ATTRS1568_mm_cmpgt_epi16(__m128i __a, __m128i __b)1569{1570return (__m128i)((__v8hi)__a > (__v8hi)__b);1571}15721573/// \brief Compares each of the corresponding signed 32-bit values of the1574/// 128-bit integer vectors to determine if the values in the first operand1575/// are greater than those in the second operand. Each comparison yields 0h1576/// for false, FFFFFFFFh for true.1577///1578/// \headerfile <x86intrin.h>1579///1580/// This intrinsic corresponds to the \c VPCMPGTD / PCMPGTD instruction.1581///1582/// \param __a1583/// A 128-bit integer vector.1584/// \param __b1585/// A 128-bit integer vector.1586/// \returns A 128-bit integer vector containing the comparison results.1587static __inline__ __m128i __DEFAULT_FN_ATTRS1588_mm_cmpgt_epi32(__m128i __a, __m128i __b)1589{1590return (__m128i)((__v4si)__a > (__v4si)__b);1591}15921593/// \brief Compares each of the corresponding signed 8-bit values of the 128-bit1594/// integer vectors to determine if the values in the first operand are less1595/// than those in the second operand. Each comparison yields 0h for false,1596/// FFh for true.1597///1598/// \headerfile <x86intrin.h>1599///1600/// This intrinsic corresponds to the \c VPCMPGTB / PCMPGTB instruction.1601///1602/// \param __a1603/// A 128-bit integer vector.1604/// \param __b1605/// A 128-bit integer vector.1606/// \returns A 128-bit integer vector containing the comparison results.1607static __inline__ __m128i __DEFAULT_FN_ATTRS1608_mm_cmplt_epi8(__m128i __a, __m128i __b)1609{1610return _mm_cmpgt_epi8(__b, __a);1611}16121613/// \brief Compares each of the corresponding signed 16-bit values of the1614/// 128-bit integer vectors to determine if the values in the first operand1615/// are less than those in the second operand. Each comparison yields 0h for1616/// false, FFFFh for true.1617///1618/// \headerfile <x86intrin.h>1619///1620/// This intrinsic corresponds to the \c VPCMPGTW / PCMPGTW instruction.1621///1622/// \param __a1623/// A 128-bit integer vector.1624/// \param __b1625/// A 128-bit integer vector.1626/// \returns A 128-bit integer vector containing the comparison results.1627static __inline__ __m128i __DEFAULT_FN_ATTRS1628_mm_cmplt_epi16(__m128i __a, __m128i __b)1629{1630return _mm_cmpgt_epi16(__b, __a);1631}16321633/// \brief Compares each of the corresponding signed 32-bit values of the1634/// 128-bit integer vectors to determine if the values in the first operand1635/// are less than those in the second operand. Each comparison yields 0h for1636/// false, FFFFFFFFh for true.1637///1638/// \headerfile <x86intrin.h>1639///1640/// This intrinsic corresponds to the \c VPCMPGTD / PCMPGTD instruction.1641///1642/// \param __a1643/// A 128-bit integer vector.1644/// \param __b1645/// A 128-bit integer vector.1646/// \returns A 128-bit integer vector containing the comparison results.1647static __inline__ __m128i __DEFAULT_FN_ATTRS1648_mm_cmplt_epi32(__m128i __a, __m128i __b)1649{1650return _mm_cmpgt_epi32(__b, __a);1651}16521653#ifdef __x86_64__1654/// \brief Converts a 64-bit signed integer value from the second operand into a1655/// double-precision value and returns it in the lower element of a [2 x1656/// double] vector; the upper element of the returned vector is copied from1657/// the upper element of the first operand.1658///1659/// \headerfile <x86intrin.h>1660///1661/// This intrinsic corresponds to the \c VCVTSI2SD / CVTSI2SD instruction.1662///1663/// \param __a1664/// A 128-bit vector of [2 x double]. The upper 64 bits of this operand are1665/// copied to the upper 64 bits of the destination.1666/// \param __b1667/// A 64-bit signed integer operand containing the value to be converted.1668/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the1669/// converted value of the second operand. The upper 64 bits are copied from1670/// the upper 64 bits of the first operand.1671static __inline__ __m128d __DEFAULT_FN_ATTRS1672_mm_cvtsi64_sd(__m128d __a, long long __b)1673{1674__a[0] = __b;1675return __a;1676}16771678/// \brief Converts the first (lower) element of a vector of [2 x double] into a1679/// 64-bit signed integer value, according to the current rounding mode.1680///1681/// \headerfile <x86intrin.h>1682///1683/// This intrinsic corresponds to the \c VCVTSD2SI / CVTSD2SI instruction.1684///1685/// \param __a1686/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the1687/// conversion.1688/// \returns A 64-bit signed integer containing the converted value.1689static __inline__ long long __DEFAULT_FN_ATTRS1690_mm_cvtsd_si64(__m128d __a)1691{1692return __builtin_ia32_cvtsd2si64((__v2df)__a);1693}16941695/// \brief Converts the first (lower) element of a vector of [2 x double] into a1696/// 64-bit signed integer value, truncating the result when it is inexact.1697///1698/// \headerfile <x86intrin.h>1699///1700/// This intrinsic corresponds to the \c VCVTTSD2SI / CVTTSD2SI instruction.1701///1702/// \param __a1703/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the1704/// conversion.1705/// \returns A 64-bit signed integer containing the converted value.1706static __inline__ long long __DEFAULT_FN_ATTRS1707_mm_cvttsd_si64(__m128d __a)1708{1709return __a[0];1710}1711#endif17121713/// \brief Converts a vector of [4 x i32] into a vector of [4 x float].1714///1715/// \headerfile <x86intrin.h>1716///1717/// This intrinsic corresponds to the \c VCVTDQ2PS / CVTDQ2PS instruction.1718///1719/// \param __a1720/// A 128-bit integer vector.1721/// \returns A 128-bit vector of [4 x float] containing the converted values.1722static __inline__ __m128 __DEFAULT_FN_ATTRS1723_mm_cvtepi32_ps(__m128i __a)1724{1725return __builtin_ia32_cvtdq2ps((__v4si)__a);1726}17271728/// \brief Converts a vector of [4 x float] into a vector of [4 x i32].1729///1730/// \headerfile <x86intrin.h>1731///1732/// This intrinsic corresponds to the \c VCVTPS2DQ / CVTPS2DQ instruction.1733///1734/// \param __a1735/// A 128-bit vector of [4 x float].1736/// \returns A 128-bit integer vector of [4 x i32] containing the converted1737/// values.1738static __inline__ __m128i __DEFAULT_FN_ATTRS1739_mm_cvtps_epi32(__m128 __a)1740{1741return (__m128i)__builtin_ia32_cvtps2dq((__v4sf)__a);1742}17431744/// \brief Converts a vector of [4 x float] into a vector of [4 x i32],1745/// truncating the result when it is inexact.1746///1747/// \headerfile <x86intrin.h>1748///1749/// This intrinsic corresponds to the \c VCVTTPS2DQ / CVTTPS2DQ instruction.1750///1751/// \param __a1752/// A 128-bit vector of [4 x float].1753/// \returns A 128-bit vector of [4 x i32] containing the converted values.1754static __inline__ __m128i __DEFAULT_FN_ATTRS1755_mm_cvttps_epi32(__m128 __a)1756{1757return (__m128i)__builtin_convertvector((__v4sf)__a, __v4si);1758}17591760/// \brief Returns a vector of [4 x i32] where the lowest element is the input1761/// operand and the remaining elements are zero.1762///1763/// \headerfile <x86intrin.h>1764///1765/// This intrinsic corresponds to the \c VMOVD / MOVD instruction.1766///1767/// \param __a1768/// A 32-bit signed integer operand.1769/// \returns A 128-bit vector of [4 x i32].1770static __inline__ __m128i __DEFAULT_FN_ATTRS1771_mm_cvtsi32_si128(int __a)1772{1773return (__m128i)(__v4si){ __a, 0, 0, 0 };1774}17751776#ifdef __x86_64__1777/// \brief Returns a vector of [2 x i64] where the lower element is the input1778/// operand and the upper element is zero.1779///1780/// \headerfile <x86intrin.h>1781///1782/// This intrinsic corresponds to the \c VMOVQ / MOVQ instruction.1783///1784/// \param __a1785/// A 64-bit signed integer operand containing the value to be converted.1786/// \returns A 128-bit vector of [2 x i64] containing the converted value.1787static __inline__ __m128i __DEFAULT_FN_ATTRS1788_mm_cvtsi64_si128(long long __a)1789{1790return (__m128i){ __a, 0 };1791}1792#endif17931794/// \brief Moves the least significant 32 bits of a vector of [4 x i32] to a1795/// 32-bit signed integer value.1796///1797/// \headerfile <x86intrin.h>1798///1799/// This intrinsic corresponds to the \c VMOVD / MOVD instruction.1800///1801/// \param __a1802/// A vector of [4 x i32]. The least significant 32 bits are moved to the1803/// destination.1804/// \returns A 32-bit signed integer containing the moved value.1805static __inline__ int __DEFAULT_FN_ATTRS1806_mm_cvtsi128_si32(__m128i __a)1807{1808__v4si __b = (__v4si)__a;1809return __b[0];1810}18111812#ifdef __x86_64__1813/// \brief Moves the least significant 64 bits of a vector of [2 x i64] to a1814/// 64-bit signed integer value.1815///1816/// \headerfile <x86intrin.h>1817///1818/// This intrinsic corresponds to the \c VMOVQ / MOVQ instruction.1819///1820/// \param __a1821/// A vector of [2 x i64]. The least significant 64 bits are moved to the1822/// destination.1823/// \returns A 64-bit signed integer containing the moved value.1824static __inline__ long long __DEFAULT_FN_ATTRS1825_mm_cvtsi128_si64(__m128i __a)1826{1827return __a[0];1828}1829#endif18301831/// \brief Moves packed integer values from an aligned 128-bit memory location1832/// to elements in a 128-bit integer vector.1833///1834/// \headerfile <x86intrin.h>1835///1836/// This intrinsic corresponds to the \c VMOVDQA / MOVDQA instruction.1837///1838/// \param __p1839/// An aligned pointer to a memory location containing integer values.1840/// \returns A 128-bit integer vector containing the moved values.1841static __inline__ __m128i __DEFAULT_FN_ATTRS1842_mm_load_si128(__m128i const *__p)1843{1844return *__p;1845}18461847/// \brief Moves packed integer values from an unaligned 128-bit memory location1848/// to elements in a 128-bit integer vector.1849///1850/// \headerfile <x86intrin.h>1851///1852/// This intrinsic corresponds to the \c VMOVDQU / MOVDQU instruction.1853///1854/// \param __p1855/// A pointer to a memory location containing integer values.1856/// \returns A 128-bit integer vector containing the moved values.1857static __inline__ __m128i __DEFAULT_FN_ATTRS1858_mm_loadu_si128(__m128i const *__p)1859{1860struct __loadu_si128 {1861__m128i __v;1862} __attribute__((__packed__, __may_alias__));1863return ((struct __loadu_si128*)__p)->__v;1864}18651866/// \brief Returns a vector of [2 x i64] where the lower element is taken from1867/// the lower element of the operand, and the upper element is zero.1868///1869/// \headerfile <x86intrin.h>1870///1871/// This intrinsic corresponds to the \c VMOVQ / MOVQ instruction.1872///1873/// \param __p1874/// A 128-bit vector of [2 x i64]. Bits [63:0] are written to bits [63:0] of1875/// the destination.1876/// \returns A 128-bit vector of [2 x i64]. The lower order bits contain the1877/// moved value. The higher order bits are cleared.1878static __inline__ __m128i __DEFAULT_FN_ATTRS1879_mm_loadl_epi64(__m128i const *__p)1880{1881struct __mm_loadl_epi64_struct {1882long long __u;1883} __attribute__((__packed__, __may_alias__));1884return (__m128i) { ((struct __mm_loadl_epi64_struct*)__p)->__u, 0};1885}18861887/// \brief Generates a 128-bit vector of [4 x i32] with unspecified content.1888/// This could be used as an argument to another intrinsic function where the1889/// argument is required but the value is not actually used.1890///1891/// \headerfile <x86intrin.h>1892///1893/// This intrinsic has no corresponding instruction.1894///1895/// \returns A 128-bit vector of [4 x i32] with unspecified content.1896static __inline__ __m128i __DEFAULT_FN_ATTRS1897_mm_undefined_si128(void)1898{1899return (__m128i)__builtin_ia32_undef128();1900}19011902/// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with1903/// the specified 64-bit integer values.1904///1905/// \headerfile <x86intrin.h>1906///1907/// This intrinsic is a utility function and does not correspond to a specific1908/// instruction.1909///1910/// \param __q11911/// A 64-bit integer value used to initialize the upper 64 bits of the1912/// destination vector of [2 x i64].1913/// \param __q01914/// A 64-bit integer value used to initialize the lower 64 bits of the1915/// destination vector of [2 x i64].1916/// \returns An initialized 128-bit vector of [2 x i64] containing the values1917/// provided in the operands.1918static __inline__ __m128i __DEFAULT_FN_ATTRS1919_mm_set_epi64x(long long __q1, long long __q0)1920{1921return (__m128i){ __q0, __q1 };1922}19231924/// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with1925/// the specified 64-bit integer values.1926///1927/// \headerfile <x86intrin.h>1928///1929/// This intrinsic is a utility function and does not correspond to a specific1930/// instruction.1931///1932/// \param __q11933/// A 64-bit integer value used to initialize the upper 64 bits of the1934/// destination vector of [2 x i64].1935/// \param __q01936/// A 64-bit integer value used to initialize the lower 64 bits of the1937/// destination vector of [2 x i64].1938/// \returns An initialized 128-bit vector of [2 x i64] containing the values1939/// provided in the operands.1940static __inline__ __m128i __DEFAULT_FN_ATTRS1941_mm_set_epi64(__m64 __q1, __m64 __q0)1942{1943return (__m128i){ (long long)__q0, (long long)__q1 };1944}19451946/// \brief Initializes the 32-bit values in a 128-bit vector of [4 x i32] with1947/// the specified 32-bit integer values.1948///1949/// \headerfile <x86intrin.h>1950///1951/// This intrinsic is a utility function and does not correspond to a specific1952/// instruction.1953///1954/// \param __i31955/// A 32-bit integer value used to initialize bits [127:96] of the1956/// destination vector.1957/// \param __i21958/// A 32-bit integer value used to initialize bits [95:64] of the destination1959/// vector.1960/// \param __i11961/// A 32-bit integer value used to initialize bits [63:32] of the destination1962/// vector.1963/// \param __i01964/// A 32-bit integer value used to initialize bits [31:0] of the destination1965/// vector.1966/// \returns An initialized 128-bit vector of [4 x i32] containing the values1967/// provided in the operands.1968static __inline__ __m128i __DEFAULT_FN_ATTRS1969_mm_set_epi32(int __i3, int __i2, int __i1, int __i0)1970{1971return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};1972}19731974/// \brief Initializes the 16-bit values in a 128-bit vector of [8 x i16] with1975/// the specified 16-bit integer values.1976///1977/// \headerfile <x86intrin.h>1978///1979/// This intrinsic is a utility function and does not correspond to a specific1980/// instruction.1981///1982/// \param __w71983/// A 16-bit integer value used to initialize bits [127:112] of the1984/// destination vector.1985/// \param __w61986/// A 16-bit integer value used to initialize bits [111:96] of the1987/// destination vector.1988/// \param __w51989/// A 16-bit integer value used to initialize bits [95:80] of the destination1990/// vector.1991/// \param __w41992/// A 16-bit integer value used to initialize bits [79:64] of the destination1993/// vector.1994/// \param __w31995/// A 16-bit integer value used to initialize bits [63:48] of the destination1996/// vector.1997/// \param __w21998/// A 16-bit integer value used to initialize bits [47:32] of the destination1999/// vector.2000/// \param __w12001/// A 16-bit integer value used to initialize bits [31:16] of the destination2002/// vector.2003/// \param __w02004/// A 16-bit integer value used to initialize bits [15:0] of the destination2005/// vector.2006/// \returns An initialized 128-bit vector of [8 x i16] containing the values2007/// provided in the operands.2008static __inline__ __m128i __DEFAULT_FN_ATTRS2009_mm_set_epi16(short __w7, short __w6, short __w5, short __w4, short __w3, short __w2, short __w1, short __w0)2010{2011return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };2012}20132014/// \brief Initializes the 8-bit values in a 128-bit vector of [16 x i8] with2015/// the specified 8-bit integer values.2016///2017/// \headerfile <x86intrin.h>2018///2019/// This intrinsic is a utility function and does not correspond to a specific2020/// instruction.2021///2022/// \param __b152023/// Initializes bits [127:120] of the destination vector.2024/// \param __b142025/// Initializes bits [119:112] of the destination vector.2026/// \param __b132027/// Initializes bits [111:104] of the destination vector.2028/// \param __b122029/// Initializes bits [103:96] of the destination vector.2030/// \param __b112031/// Initializes bits [95:88] of the destination vector.2032/// \param __b102033/// Initializes bits [87:80] of the destination vector.2034/// \param __b92035/// Initializes bits [79:72] of the destination vector.2036/// \param __b82037/// Initializes bits [71:64] of the destination vector.2038/// \param __b72039/// Initializes bits [63:56] of the destination vector.2040/// \param __b62041/// Initializes bits [55:48] of the destination vector.2042/// \param __b52043/// Initializes bits [47:40] of the destination vector.2044/// \param __b42045/// Initializes bits [39:32] of the destination vector.2046/// \param __b32047/// Initializes bits [31:24] of the destination vector.2048/// \param __b22049/// Initializes bits [23:16] of the destination vector.2050/// \param __b12051/// Initializes bits [15:8] of the destination vector.2052/// \param __b02053/// Initializes bits [7:0] of the destination vector.2054/// \returns An initialized 128-bit vector of [16 x i8] containing the values2055/// provided in the operands.2056static __inline__ __m128i __DEFAULT_FN_ATTRS2057_mm_set_epi8(char __b15, char __b14, char __b13, char __b12, char __b11, char __b10, char __b9, char __b8, char __b7, char __b6, char __b5, char __b4, char __b3, char __b2, char __b1, char __b0)2058{2059return (__m128i)(__v16qi){ __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15 };2060}20612062/// \brief Initializes both values in a 128-bit integer vector with the2063/// specified 64-bit integer value.2064///2065/// \headerfile <x86intrin.h>2066///2067/// This intrinsic is a utility function and does not correspond to a specific2068/// instruction.2069///2070/// \param __q2071/// Integer value used to initialize the elements of the destination integer2072/// vector.2073/// \returns An initialized 128-bit integer vector of [2 x i64] with both2074/// elements containing the value provided in the operand.2075static __inline__ __m128i __DEFAULT_FN_ATTRS2076_mm_set1_epi64x(long long __q)2077{2078return (__m128i){ __q, __q };2079}20802081/// \brief Initializes both values in a 128-bit vector of [2 x i64] with the2082/// specified 64-bit value.2083///2084/// \headerfile <x86intrin.h>2085///2086/// This intrinsic is a utility function and does not correspond to a specific2087/// instruction.2088///2089/// \param __q2090/// A 64-bit value used to initialize the elements of the destination integer2091/// vector.2092/// \returns An initialized 128-bit vector of [2 x i64] with all elements2093/// containing the value provided in the operand.2094static __inline__ __m128i __DEFAULT_FN_ATTRS2095_mm_set1_epi64(__m64 __q)2096{2097return (__m128i){ (long long)__q, (long long)__q };2098}20992100/// \brief Initializes all values in a 128-bit vector of [4 x i32] with the2101/// specified 32-bit value.2102///2103/// \headerfile <x86intrin.h>2104///2105/// This intrinsic is a utility function and does not correspond to a specific2106/// instruction.2107///2108/// \param __i2109/// A 32-bit value used to initialize the elements of the destination integer2110/// vector.2111/// \returns An initialized 128-bit vector of [4 x i32] with all elements2112/// containing the value provided in the operand.2113static __inline__ __m128i __DEFAULT_FN_ATTRS2114_mm_set1_epi32(int __i)2115{2116return (__m128i)(__v4si){ __i, __i, __i, __i };2117}21182119/// \brief Initializes all values in a 128-bit vector of [8 x i16] with the2120/// specified 16-bit value.2121///2122/// \headerfile <x86intrin.h>2123///2124/// This intrinsic is a utility function and does not correspond to a specific2125/// instruction.2126///2127/// \param __w2128/// A 16-bit value used to initialize the elements of the destination integer2129/// vector.2130/// \returns An initialized 128-bit vector of [8 x i16] with all elements2131/// containing the value provided in the operand.2132static __inline__ __m128i __DEFAULT_FN_ATTRS2133_mm_set1_epi16(short __w)2134{2135return (__m128i)(__v8hi){ __w, __w, __w, __w, __w, __w, __w, __w };2136}21372138/// \brief Initializes all values in a 128-bit vector of [16 x i8] with the2139/// specified 8-bit value.2140///2141/// \headerfile <x86intrin.h>2142///2143/// This intrinsic is a utility function and does not correspond to a specific2144/// instruction.2145///2146/// \param __b2147/// An 8-bit value used to initialize the elements of the destination integer2148/// vector.2149/// \returns An initialized 128-bit vector of [16 x i8] with all elements2150/// containing the value provided in the operand.2151static __inline__ __m128i __DEFAULT_FN_ATTRS2152_mm_set1_epi8(char __b)2153{2154return (__m128i)(__v16qi){ __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b };2155}21562157static __inline__ __m128i __DEFAULT_FN_ATTRS2158_mm_setr_epi64(__m64 __q0, __m64 __q1)2159{2160return (__m128i){ (long long)__q0, (long long)__q1 };2161}21622163static __inline__ __m128i __DEFAULT_FN_ATTRS2164_mm_setr_epi32(int __i0, int __i1, int __i2, int __i3)2165{2166return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};2167}21682169static __inline__ __m128i __DEFAULT_FN_ATTRS2170_mm_setr_epi16(short __w0, short __w1, short __w2, short __w3, short __w4, short __w5, short __w6, short __w7)2171{2172return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };2173}21742175static __inline__ __m128i __DEFAULT_FN_ATTRS2176_mm_setr_epi8(char __b0, char __b1, char __b2, char __b3, char __b4, char __b5, char __b6, char __b7, char __b8, char __b9, char __b10, char __b11, char __b12, char __b13, char __b14, char __b15)2177{2178return (__m128i)(__v16qi){ __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15 };2179}21802181static __inline__ __m128i __DEFAULT_FN_ATTRS2182_mm_setzero_si128(void)2183{2184return (__m128i){ 0LL, 0LL };2185}21862187static __inline__ void __DEFAULT_FN_ATTRS2188_mm_store_si128(__m128i *__p, __m128i __b)2189{2190*__p = __b;2191}21922193static __inline__ void __DEFAULT_FN_ATTRS2194_mm_storeu_si128(__m128i *__p, __m128i __b)2195{2196struct __storeu_si128 {2197__m128i __v;2198} __attribute__((__packed__, __may_alias__));2199((struct __storeu_si128*)__p)->__v = __b;2200}22012202static __inline__ void __DEFAULT_FN_ATTRS2203_mm_maskmoveu_si128(__m128i __d, __m128i __n, char *__p)2204{2205__builtin_ia32_maskmovdqu((__v16qi)__d, (__v16qi)__n, __p);2206}22072208static __inline__ void __DEFAULT_FN_ATTRS2209_mm_storel_epi64(__m128i *__p, __m128i __a)2210{2211struct __mm_storel_epi64_struct {2212long long __u;2213} __attribute__((__packed__, __may_alias__));2214((struct __mm_storel_epi64_struct*)__p)->__u = __a[0];2215}22162217static __inline__ void __DEFAULT_FN_ATTRS2218_mm_stream_pd(double *__p, __m128d __a)2219{2220__builtin_nontemporal_store((__v2df)__a, (__v2df*)__p);2221}22222223static __inline__ void __DEFAULT_FN_ATTRS2224_mm_stream_si128(__m128i *__p, __m128i __a)2225{2226__builtin_nontemporal_store((__v2di)__a, (__v2di*)__p);2227}22282229static __inline__ void __DEFAULT_FN_ATTRS2230_mm_stream_si32(int *__p, int __a)2231{2232__builtin_ia32_movnti(__p, __a);2233}22342235#ifdef __x86_64__2236static __inline__ void __DEFAULT_FN_ATTRS2237_mm_stream_si64(long long *__p, long long __a)2238{2239__builtin_ia32_movnti64(__p, __a);2240}2241#endif22422243static __inline__ void __DEFAULT_FN_ATTRS2244_mm_clflush(void const *__p)2245{2246__builtin_ia32_clflush(__p);2247}22482249static __inline__ void __DEFAULT_FN_ATTRS2250_mm_lfence(void)2251{2252__builtin_ia32_lfence();2253}22542255static __inline__ void __DEFAULT_FN_ATTRS2256_mm_mfence(void)2257{2258__builtin_ia32_mfence();2259}22602261static __inline__ __m128i __DEFAULT_FN_ATTRS2262_mm_packs_epi16(__m128i __a, __m128i __b)2263{2264return (__m128i)__builtin_ia32_packsswb128((__v8hi)__a, (__v8hi)__b);2265}22662267static __inline__ __m128i __DEFAULT_FN_ATTRS2268_mm_packs_epi32(__m128i __a, __m128i __b)2269{2270return (__m128i)__builtin_ia32_packssdw128((__v4si)__a, (__v4si)__b);2271}22722273static __inline__ __m128i __DEFAULT_FN_ATTRS2274_mm_packus_epi16(__m128i __a, __m128i __b)2275{2276return (__m128i)__builtin_ia32_packuswb128((__v8hi)__a, (__v8hi)__b);2277}22782279static __inline__ int __DEFAULT_FN_ATTRS2280_mm_extract_epi16(__m128i __a, int __imm)2281{2282__v8hi __b = (__v8hi)__a;2283return (unsigned short)__b[__imm & 7];2284}22852286static __inline__ __m128i __DEFAULT_FN_ATTRS2287_mm_insert_epi16(__m128i __a, int __b, int __imm)2288{2289__v8hi __c = (__v8hi)__a;2290__c[__imm & 7] = __b;2291return (__m128i)__c;2292}22932294static __inline__ int __DEFAULT_FN_ATTRS2295_mm_movemask_epi8(__m128i __a)2296{2297return __builtin_ia32_pmovmskb128((__v16qi)__a);2298}22992300#define _mm_shuffle_epi32(a, imm) __extension__ ({ \2301(__m128i)__builtin_shufflevector((__v4si)(__m128i)(a), \2302(__v4si)_mm_undefined_si128(), \2303((imm) >> 0) & 0x3, ((imm) >> 2) & 0x3, \2304((imm) >> 4) & 0x3, ((imm) >> 6) & 0x3); })23052306#define _mm_shufflelo_epi16(a, imm) __extension__ ({ \2307(__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \2308(__v8hi)_mm_undefined_si128(), \2309((imm) >> 0) & 0x3, ((imm) >> 2) & 0x3, \2310((imm) >> 4) & 0x3, ((imm) >> 6) & 0x3, \23114, 5, 6, 7); })23122313#define _mm_shufflehi_epi16(a, imm) __extension__ ({ \2314(__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \2315(__v8hi)_mm_undefined_si128(), \23160, 1, 2, 3, \23174 + (((imm) >> 0) & 0x3), \23184 + (((imm) >> 2) & 0x3), \23194 + (((imm) >> 4) & 0x3), \23204 + (((imm) >> 6) & 0x3)); })23212322static __inline__ __m128i __DEFAULT_FN_ATTRS2323_mm_unpackhi_epi8(__m128i __a, __m128i __b)2324{2325return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15);2326}23272328static __inline__ __m128i __DEFAULT_FN_ATTRS2329_mm_unpackhi_epi16(__m128i __a, __m128i __b)2330{2331return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7);2332}23332334static __inline__ __m128i __DEFAULT_FN_ATTRS2335_mm_unpackhi_epi32(__m128i __a, __m128i __b)2336{2337return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 2, 4+2, 3, 4+3);2338}23392340static __inline__ __m128i __DEFAULT_FN_ATTRS2341_mm_unpackhi_epi64(__m128i __a, __m128i __b)2342{2343return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 1, 2+1);2344}23452346static __inline__ __m128i __DEFAULT_FN_ATTRS2347_mm_unpacklo_epi8(__m128i __a, __m128i __b)2348{2349return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7);2350}23512352static __inline__ __m128i __DEFAULT_FN_ATTRS2353_mm_unpacklo_epi16(__m128i __a, __m128i __b)2354{2355return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3);2356}23572358static __inline__ __m128i __DEFAULT_FN_ATTRS2359_mm_unpacklo_epi32(__m128i __a, __m128i __b)2360{2361return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 0, 4+0, 1, 4+1);2362}23632364static __inline__ __m128i __DEFAULT_FN_ATTRS2365_mm_unpacklo_epi64(__m128i __a, __m128i __b)2366{2367return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 0, 2+0);2368}23692370static __inline__ __m64 __DEFAULT_FN_ATTRS2371_mm_movepi64_pi64(__m128i __a)2372{2373return (__m64)__a[0];2374}23752376static __inline__ __m128i __DEFAULT_FN_ATTRS2377_mm_movpi64_epi64(__m64 __a)2378{2379return (__m128i){ (long long)__a, 0 };2380}23812382static __inline__ __m128i __DEFAULT_FN_ATTRS2383_mm_move_epi64(__m128i __a)2384{2385return __builtin_shufflevector((__v2di)__a, (__m128i){ 0 }, 0, 2);2386}23872388static __inline__ __m128d __DEFAULT_FN_ATTRS2389_mm_unpackhi_pd(__m128d __a, __m128d __b)2390{2391return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 1, 2+1);2392}23932394static __inline__ __m128d __DEFAULT_FN_ATTRS2395_mm_unpacklo_pd(__m128d __a, __m128d __b)2396{2397return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 0, 2+0);2398}23992400static __inline__ int __DEFAULT_FN_ATTRS2401_mm_movemask_pd(__m128d __a)2402{2403return __builtin_ia32_movmskpd((__v2df)__a);2404}24052406#define _mm_shuffle_pd(a, b, i) __extension__ ({ \2407(__m128d)__builtin_shufflevector((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \24080 + (((i) >> 0) & 0x1), \24092 + (((i) >> 1) & 0x1)); })24102411static __inline__ __m128 __DEFAULT_FN_ATTRS2412_mm_castpd_ps(__m128d __a)2413{2414return (__m128)__a;2415}24162417static __inline__ __m128i __DEFAULT_FN_ATTRS2418_mm_castpd_si128(__m128d __a)2419{2420return (__m128i)__a;2421}24222423static __inline__ __m128d __DEFAULT_FN_ATTRS2424_mm_castps_pd(__m128 __a)2425{2426return (__m128d)__a;2427}24282429static __inline__ __m128i __DEFAULT_FN_ATTRS2430_mm_castps_si128(__m128 __a)2431{2432return (__m128i)__a;2433}24342435static __inline__ __m128 __DEFAULT_FN_ATTRS2436_mm_castsi128_ps(__m128i __a)2437{2438return (__m128)__a;2439}24402441static __inline__ __m128d __DEFAULT_FN_ATTRS2442_mm_castsi128_pd(__m128i __a)2443{2444return (__m128d)__a;2445}24462447static __inline__ void __DEFAULT_FN_ATTRS2448_mm_pause(void)2449{2450__builtin_ia32_pause();2451}24522453#undef __DEFAULT_FN_ATTRS24542455#define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))24562457#endif /* __EMMINTRIN_H */245824592460