827 lines · c
1/*===---- fmaintrin.h - FMA intrinsics -------------------------------------===2 *3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4 * See https://llvm.org/LICENSE.txt for license information.5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#ifndef __IMMINTRIN_H11#error "Never use <fmaintrin.h> directly; include <immintrin.h> instead."12#endif13 14#ifndef __FMAINTRIN_H15#define __FMAINTRIN_H16 17/* Define the default attributes for the functions in this file. */18#define __DEFAULT_FN_ATTRS128 \19 __attribute__((__always_inline__, __nodebug__, __target__("fma"), \20 __min_vector_width__(128)))21#define __DEFAULT_FN_ATTRS256 \22 __attribute__((__always_inline__, __nodebug__, __target__("fma"), \23 __min_vector_width__(256)))24 25#if defined(__cplusplus) && (__cplusplus >= 201103L)26#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr27#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 constexpr28#else29#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS12830#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS25631#endif32 33/// Computes a multiply-add of 128-bit vectors of [4 x float].34/// For each element, computes <c> (__A * __B) + __C </c>.35///36/// \headerfile <immintrin.h>37///38/// This intrinsic corresponds to the \c VFMADD213PS instruction.39///40/// \param __A41/// A 128-bit vector of [4 x float] containing the multiplicand.42/// \param __B43/// A 128-bit vector of [4 x float] containing the multiplier.44/// \param __C45/// A 128-bit vector of [4 x float] containing the addend.46/// \returns A 128-bit vector of [4 x float] containing the result.47static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR48_mm_fmadd_ps(__m128 __A, __m128 __B, __m128 __C)49{50 return (__m128)__builtin_elementwise_fma((__v4sf)__A, (__v4sf)__B,51 (__v4sf)__C);52}53 54/// Computes a multiply-add of 128-bit vectors of [2 x double].55/// For each element, computes <c> (__A * __B) + __C </c>.56///57/// \headerfile <immintrin.h>58///59/// This intrinsic corresponds to the \c VFMADD213PD instruction.60///61/// \param __A62/// A 128-bit vector of [2 x double] containing the multiplicand.63/// \param __B64/// A 128-bit vector of [2 x double] containing the multiplier.65/// \param __C66/// A 128-bit vector of [2 x double] containing the addend.67/// \returns A 128-bit [2 x double] vector containing the result.68static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR69_mm_fmadd_pd(__m128d __A, __m128d __B, __m128d __C)70{71 return (__m128d)__builtin_elementwise_fma((__v2df)__A, (__v2df)__B,72 (__v2df)__C);73}74 75/// Computes a scalar multiply-add of the single-precision values in the76/// low 32 bits of 128-bit vectors of [4 x float].77///78/// \code{.operation}79/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0]80/// result[127:32] = __A[127:32]81/// \endcode82///83/// \headerfile <immintrin.h>84///85/// This intrinsic corresponds to the \c VFMADD213SS instruction.86///87/// \param __A88/// A 128-bit vector of [4 x float] containing the multiplicand in the low89/// 32 bits.90/// \param __B91/// A 128-bit vector of [4 x float] containing the multiplier in the low92/// 32 bits.93/// \param __C94/// A 128-bit vector of [4 x float] containing the addend in the low95/// 32 bits.96/// \returns A 128-bit vector of [4 x float] containing the result in the low97/// 32 bits and a copy of \a __A[127:32] in the upper 96 bits.98static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR99_mm_fmadd_ss(__m128 __A, __m128 __B, __m128 __C) {100 __A[0] = __builtin_elementwise_fma(__A[0], __B[0], __C[0]);101 return __A;102}103 104/// Computes a scalar multiply-add of the double-precision values in the105/// low 64 bits of 128-bit vectors of [2 x double].106///107/// \code{.operation}108/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0]109/// result[127:64] = __A[127:64]110/// \endcode111///112/// \headerfile <immintrin.h>113///114/// This intrinsic corresponds to the \c VFMADD213SD instruction.115///116/// \param __A117/// A 128-bit vector of [2 x double] containing the multiplicand in the low118/// 64 bits.119/// \param __B120/// A 128-bit vector of [2 x double] containing the multiplier in the low121/// 64 bits.122/// \param __C123/// A 128-bit vector of [2 x double] containing the addend in the low124/// 64 bits.125/// \returns A 128-bit vector of [2 x double] containing the result in the low126/// 64 bits and a copy of \a __A[127:64] in the upper 64 bits.127static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR128_mm_fmadd_sd(__m128d __A, __m128d __B, __m128d __C) {129 __A[0] = __builtin_elementwise_fma(__A[0], __B[0], __C[0]);130 return __A;131}132 133/// Computes a multiply-subtract of 128-bit vectors of [4 x float].134/// For each element, computes <c> (__A * __B) - __C </c>.135///136/// \headerfile <immintrin.h>137///138/// This intrinsic corresponds to the \c VFMSUB213PS instruction.139///140/// \param __A141/// A 128-bit vector of [4 x float] containing the multiplicand.142/// \param __B143/// A 128-bit vector of [4 x float] containing the multiplier.144/// \param __C145/// A 128-bit vector of [4 x float] containing the subtrahend.146/// \returns A 128-bit vector of [4 x float] containing the result.147static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR148_mm_fmsub_ps(__m128 __A, __m128 __B, __m128 __C)149{150 return (__m128)__builtin_elementwise_fma((__v4sf)__A, (__v4sf)__B,151 -(__v4sf)__C);152}153 154/// Computes a multiply-subtract of 128-bit vectors of [2 x double].155/// For each element, computes <c> (__A * __B) - __C </c>.156///157/// \headerfile <immintrin.h>158///159/// This intrinsic corresponds to the \c VFMSUB213PD instruction.160///161/// \param __A162/// A 128-bit vector of [2 x double] containing the multiplicand.163/// \param __B164/// A 128-bit vector of [2 x double] containing the multiplier.165/// \param __C166/// A 128-bit vector of [2 x double] containing the addend.167/// \returns A 128-bit vector of [2 x double] containing the result.168static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR169_mm_fmsub_pd(__m128d __A, __m128d __B, __m128d __C)170{171 return (__m128d)__builtin_elementwise_fma((__v2df)__A, (__v2df)__B,172 -(__v2df)__C);173}174 175/// Computes a scalar multiply-subtract of the single-precision values in176/// the low 32 bits of 128-bit vectors of [4 x float].177///178/// \code{.operation}179/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0]180/// result[127:32] = __A[127:32]181/// \endcode182///183/// \headerfile <immintrin.h>184///185/// This intrinsic corresponds to the \c VFMSUB213SS instruction.186///187/// \param __A188/// A 128-bit vector of [4 x float] containing the multiplicand in the low189/// 32 bits.190/// \param __B191/// A 128-bit vector of [4 x float] containing the multiplier in the low192/// 32 bits.193/// \param __C194/// A 128-bit vector of [4 x float] containing the subtrahend in the low195/// 32 bits.196/// \returns A 128-bit vector of [4 x float] containing the result in the low197/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits.198static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR199_mm_fmsub_ss(__m128 __A, __m128 __B, __m128 __C) {200 __A[0] = __builtin_elementwise_fma(__A[0], __B[0], -__C[0]);201 return __A;202}203 204/// Computes a scalar multiply-subtract of the double-precision values in205/// the low 64 bits of 128-bit vectors of [2 x double].206///207/// \code{.operation}208/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0]209/// result[127:64] = __A[127:64]210/// \endcode211///212/// \headerfile <immintrin.h>213///214/// This intrinsic corresponds to the \c VFMSUB213SD instruction.215///216/// \param __A217/// A 128-bit vector of [2 x double] containing the multiplicand in the low218/// 64 bits.219/// \param __B220/// A 128-bit vector of [2 x double] containing the multiplier in the low221/// 64 bits.222/// \param __C223/// A 128-bit vector of [2 x double] containing the subtrahend in the low224/// 64 bits.225/// \returns A 128-bit vector of [2 x double] containing the result in the low226/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits.227static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR228_mm_fmsub_sd(__m128d __A, __m128d __B, __m128d __C) {229 __A[0] = __builtin_elementwise_fma(__A[0], __B[0], -__C[0]);230 return __A;231}232 233/// Computes a negated multiply-add of 128-bit vectors of [4 x float].234/// For each element, computes <c> -(__A * __B) + __C </c>.235///236/// \headerfile <immintrin.h>237///238/// This intrinsic corresponds to the \c VFNMADD213DPS instruction.239///240/// \param __A241/// A 128-bit vector of [4 x float] containing the multiplicand.242/// \param __B243/// A 128-bit vector of [4 x float] containing the multiplier.244/// \param __C245/// A 128-bit vector of [4 x float] containing the addend.246/// \returns A 128-bit [4 x float] vector containing the result.247static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR248_mm_fnmadd_ps(__m128 __A, __m128 __B, __m128 __C)249{250 return (__m128)__builtin_elementwise_fma(-(__v4sf)__A, (__v4sf)__B,251 (__v4sf)__C);252}253 254/// Computes a negated multiply-add of 128-bit vectors of [2 x double].255/// For each element, computes <c> -(__A * __B) + __C </c>.256///257/// \headerfile <immintrin.h>258///259/// This intrinsic corresponds to the \c VFNMADD213PD instruction.260///261/// \param __A262/// A 128-bit vector of [2 x double] containing the multiplicand.263/// \param __B264/// A 128-bit vector of [2 x double] containing the multiplier.265/// \param __C266/// A 128-bit vector of [2 x double] containing the addend.267/// \returns A 128-bit vector of [2 x double] containing the result.268static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR269_mm_fnmadd_pd(__m128d __A, __m128d __B, __m128d __C)270{271 return (__m128d)__builtin_elementwise_fma(-(__v2df)__A, (__v2df)__B,272 (__v2df)__C);273}274 275/// Computes a scalar negated multiply-add of the single-precision values in276/// the low 32 bits of 128-bit vectors of [4 x float].277///278/// \code{.operation}279/// result[31:0] = -(__A[31:0] * __B[31:0]) + __C[31:0]280/// result[127:32] = __A[127:32]281/// \endcode282///283/// \headerfile <immintrin.h>284///285/// This intrinsic corresponds to the \c VFNMADD213SS instruction.286///287/// \param __A288/// A 128-bit vector of [4 x float] containing the multiplicand in the low289/// 32 bits.290/// \param __B291/// A 128-bit vector of [4 x float] containing the multiplier in the low292/// 32 bits.293/// \param __C294/// A 128-bit vector of [4 x float] containing the addend in the low295/// 32 bits.296/// \returns A 128-bit vector of [4 x float] containing the result in the low297/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits.298static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR299_mm_fnmadd_ss(__m128 __A, __m128 __B, __m128 __C) {300 __A[0] = __builtin_elementwise_fma(__A[0], -__B[0], __C[0]);301 return __A;302}303 304/// Computes a scalar negated multiply-add of the double-precision values305/// in the low 64 bits of 128-bit vectors of [2 x double].306///307/// \code{.operation}308/// result[63:0] = -(__A[63:0] * __B[63:0]) + __C[63:0]309/// result[127:64] = __A[127:64]310/// \endcode311///312/// \headerfile <immintrin.h>313///314/// This intrinsic corresponds to the \c VFNMADD213SD instruction.315///316/// \param __A317/// A 128-bit vector of [2 x double] containing the multiplicand in the low318/// 64 bits.319/// \param __B320/// A 128-bit vector of [2 x double] containing the multiplier in the low321/// 64 bits.322/// \param __C323/// A 128-bit vector of [2 x double] containing the addend in the low324/// 64 bits.325/// \returns A 128-bit vector of [2 x double] containing the result in the low326/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits.327static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR328_mm_fnmadd_sd(__m128d __A, __m128d __B, __m128d __C) {329 __A[0] = __builtin_elementwise_fma(__A[0], -__B[0], __C[0]);330 return __A;331}332 333/// Computes a negated multiply-subtract of 128-bit vectors of [4 x float].334/// For each element, computes <c> -(__A * __B) - __C </c>.335///336/// \headerfile <immintrin.h>337///338/// This intrinsic corresponds to the \c VFNMSUB213PS instruction.339///340/// \param __A341/// A 128-bit vector of [4 x float] containing the multiplicand.342/// \param __B343/// A 128-bit vector of [4 x float] containing the multiplier.344/// \param __C345/// A 128-bit vector of [4 x float] containing the subtrahend.346/// \returns A 128-bit vector of [4 x float] containing the result.347static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR348_mm_fnmsub_ps(__m128 __A, __m128 __B, __m128 __C)349{350 return (__m128)__builtin_elementwise_fma(-(__v4sf)__A, (__v4sf)__B,351 -(__v4sf)__C);352}353 354/// Computes a negated multiply-subtract of 128-bit vectors of [2 x double].355/// For each element, computes <c> -(__A * __B) - __C </c>.356///357/// \headerfile <immintrin.h>358///359/// This intrinsic corresponds to the \c VFNMSUB213PD instruction.360///361/// \param __A362/// A 128-bit vector of [2 x double] containing the multiplicand.363/// \param __B364/// A 128-bit vector of [2 x double] containing the multiplier.365/// \param __C366/// A 128-bit vector of [2 x double] containing the subtrahend.367/// \returns A 128-bit vector of [2 x double] containing the result.368static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR369_mm_fnmsub_pd(__m128d __A, __m128d __B, __m128d __C)370{371 return (__m128d)__builtin_elementwise_fma(-(__v2df)__A, (__v2df)__B,372 -(__v2df)__C);373}374 375/// Computes a scalar negated multiply-subtract of the single-precision376/// values in the low 32 bits of 128-bit vectors of [4 x float].377///378/// \code{.operation}379/// result[31:0] = -(__A[31:0] * __B[31:0]) - __C[31:0]380/// result[127:32] = __A[127:32]381/// \endcode382///383/// \headerfile <immintrin.h>384///385/// This intrinsic corresponds to the \c VFNMSUB213SS instruction.386///387/// \param __A388/// A 128-bit vector of [4 x float] containing the multiplicand in the low389/// 32 bits.390/// \param __B391/// A 128-bit vector of [4 x float] containing the multiplier in the low392/// 32 bits.393/// \param __C394/// A 128-bit vector of [4 x float] containing the subtrahend in the low395/// 32 bits.396/// \returns A 128-bit vector of [4 x float] containing the result in the low397/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits.398static __inline__ __m128 __DEFAULT_FN_ATTRS128_CONSTEXPR399_mm_fnmsub_ss(__m128 __A, __m128 __B, __m128 __C) {400 __A[0] = __builtin_elementwise_fma(__A[0], -__B[0], -__C[0]);401 return __A;402}403 404/// Computes a scalar negated multiply-subtract of the double-precision405/// values in the low 64 bits of 128-bit vectors of [2 x double].406///407/// \code{.operation}408/// result[63:0] = -(__A[63:0] * __B[63:0]) - __C[63:0]409/// result[127:64] = __A[127:64]410/// \endcode411///412/// \headerfile <immintrin.h>413///414/// This intrinsic corresponds to the \c VFNMSUB213SD instruction.415///416/// \param __A417/// A 128-bit vector of [2 x double] containing the multiplicand in the low418/// 64 bits.419/// \param __B420/// A 128-bit vector of [2 x double] containing the multiplier in the low421/// 64 bits.422/// \param __C423/// A 128-bit vector of [2 x double] containing the subtrahend in the low424/// 64 bits.425/// \returns A 128-bit vector of [2 x double] containing the result in the low426/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits.427static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR428_mm_fnmsub_sd(__m128d __A, __m128d __B, __m128d __C) {429 __A[0] = __builtin_elementwise_fma(__A[0], -__B[0], -__C[0]);430 return __A;431}432 433/// Computes a multiply with alternating add/subtract of 128-bit vectors of434/// [4 x float].435///436/// \code{.operation}437/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0]438/// result[63:32] = (__A[63:32] * __B[63:32]) + __C[63:32]439/// result[95:64] = (__A[95:64] * __B[95:64]) - __C[95:64]440/// result[127:96] = (__A[127:96] * __B[127:96]) + __C[127:96]441/// \endcode442///443/// \headerfile <immintrin.h>444///445/// This intrinsic corresponds to the \c VFMADDSUB213PS instruction.446///447/// \param __A448/// A 128-bit vector of [4 x float] containing the multiplicand.449/// \param __B450/// A 128-bit vector of [4 x float] containing the multiplier.451/// \param __C452/// A 128-bit vector of [4 x float] containing the addend/subtrahend.453/// \returns A 128-bit vector of [4 x float] containing the result.454static __inline__ __m128 __DEFAULT_FN_ATTRS128455_mm_fmaddsub_ps(__m128 __A, __m128 __B, __m128 __C)456{457 return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);458}459 460/// Computes a multiply with alternating add/subtract of 128-bit vectors of461/// [2 x double].462///463/// \code{.operation}464/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0]465/// result[127:64] = (__A[127:64] * __B[127:64]) + __C[127:64]466/// \endcode467///468/// \headerfile <immintrin.h>469///470/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction.471///472/// \param __A473/// A 128-bit vector of [2 x double] containing the multiplicand.474/// \param __B475/// A 128-bit vector of [2 x double] containing the multiplier.476/// \param __C477/// A 128-bit vector of [2 x double] containing the addend/subtrahend.478/// \returns A 128-bit vector of [2 x double] containing the result.479static __inline__ __m128d __DEFAULT_FN_ATTRS128480_mm_fmaddsub_pd(__m128d __A, __m128d __B, __m128d __C)481{482 return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, (__v2df)__C);483}484 485/// Computes a multiply with alternating add/subtract of 128-bit vectors of486/// [4 x float].487///488/// \code{.operation}489/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0]490/// result[63:32] = (__A[63:32] * __B[63:32]) - __C[63:32]491/// result[95:64] = (__A[95:64] * __B[95:64]) + __C[95:64]492/// result[127:96 = (__A[127:96] * __B[127:96]) - __C[127:96]493/// \endcode494///495/// \headerfile <immintrin.h>496///497/// This intrinsic corresponds to the \c VFMSUBADD213PS instruction.498///499/// \param __A500/// A 128-bit vector of [4 x float] containing the multiplicand.501/// \param __B502/// A 128-bit vector of [4 x float] containing the multiplier.503/// \param __C504/// A 128-bit vector of [4 x float] containing the addend/subtrahend.505/// \returns A 128-bit vector of [4 x float] containing the result.506static __inline__ __m128 __DEFAULT_FN_ATTRS128507_mm_fmsubadd_ps(__m128 __A, __m128 __B, __m128 __C)508{509 return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);510}511 512/// Computes a multiply with alternating add/subtract of 128-bit vectors of513/// [2 x double].514///515/// \code{.operation}516/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0]517/// result[127:64] = (__A[127:64] * __B[127:64]) - __C[127:64]518/// \endcode519///520/// \headerfile <immintrin.h>521///522/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction.523///524/// \param __A525/// A 128-bit vector of [2 x double] containing the multiplicand.526/// \param __B527/// A 128-bit vector of [2 x double] containing the multiplier.528/// \param __C529/// A 128-bit vector of [2 x double] containing the addend/subtrahend.530/// \returns A 128-bit vector of [2 x double] containing the result.531static __inline__ __m128d __DEFAULT_FN_ATTRS128532_mm_fmsubadd_pd(__m128d __A, __m128d __B, __m128d __C)533{534 return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, -(__v2df)__C);535}536 537/// Computes a multiply-add of 256-bit vectors of [8 x float].538/// For each element, computes <c> (__A * __B) + __C </c>.539///540/// \headerfile <immintrin.h>541///542/// This intrinsic corresponds to the \c VFMADD213PS instruction.543///544/// \param __A545/// A 256-bit vector of [8 x float] containing the multiplicand.546/// \param __B547/// A 256-bit vector of [8 x float] containing the multiplier.548/// \param __C549/// A 256-bit vector of [8 x float] containing the addend.550/// \returns A 256-bit vector of [8 x float] containing the result.551static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR552_mm256_fmadd_ps(__m256 __A, __m256 __B, __m256 __C)553{554 return (__m256)__builtin_elementwise_fma((__v8sf)__A, (__v8sf)__B,555 (__v8sf)__C);556}557 558/// Computes a multiply-add of 256-bit vectors of [4 x double].559/// For each element, computes <c> (__A * __B) + __C </c>.560///561/// \headerfile <immintrin.h>562///563/// This intrinsic corresponds to the \c VFMADD213PD instruction.564///565/// \param __A566/// A 256-bit vector of [4 x double] containing the multiplicand.567/// \param __B568/// A 256-bit vector of [4 x double] containing the multiplier.569/// \param __C570/// A 256-bit vector of [4 x double] containing the addend.571/// \returns A 256-bit vector of [4 x double] containing the result.572static __inline__ __m256d __DEFAULT_FN_ATTRS256_CONSTEXPR573_mm256_fmadd_pd(__m256d __A, __m256d __B, __m256d __C)574{575 return (__m256d)__builtin_elementwise_fma((__v4df)__A, (__v4df)__B,576 (__v4df)__C);577}578 579/// Computes a multiply-subtract of 256-bit vectors of [8 x float].580/// For each element, computes <c> (__A * __B) - __C </c>.581///582/// \headerfile <immintrin.h>583///584/// This intrinsic corresponds to the \c VFMSUB213PS instruction.585///586/// \param __A587/// A 256-bit vector of [8 x float] containing the multiplicand.588/// \param __B589/// A 256-bit vector of [8 x float] containing the multiplier.590/// \param __C591/// A 256-bit vector of [8 x float] containing the subtrahend.592/// \returns A 256-bit vector of [8 x float] containing the result.593static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR594_mm256_fmsub_ps(__m256 __A, __m256 __B, __m256 __C)595{596 return (__m256)__builtin_elementwise_fma((__v8sf)__A, (__v8sf)__B,597 -(__v8sf)__C);598}599 600/// Computes a multiply-subtract of 256-bit vectors of [4 x double].601/// For each element, computes <c> (__A * __B) - __C </c>.602///603/// \headerfile <immintrin.h>604///605/// This intrinsic corresponds to the \c VFMSUB213PD instruction.606///607/// \param __A608/// A 256-bit vector of [4 x double] containing the multiplicand.609/// \param __B610/// A 256-bit vector of [4 x double] containing the multiplier.611/// \param __C612/// A 256-bit vector of [4 x double] containing the subtrahend.613/// \returns A 256-bit vector of [4 x double] containing the result.614static __inline__ __m256d __DEFAULT_FN_ATTRS256_CONSTEXPR615_mm256_fmsub_pd(__m256d __A, __m256d __B, __m256d __C)616{617 return (__m256d)__builtin_elementwise_fma((__v4df)__A, (__v4df)__B,618 -(__v4df)__C);619}620 621/// Computes a negated multiply-add of 256-bit vectors of [8 x float].622/// For each element, computes <c> -(__A * __B) + __C </c>.623///624/// \headerfile <immintrin.h>625///626/// This intrinsic corresponds to the \c VFNMADD213PS instruction.627///628/// \param __A629/// A 256-bit vector of [8 x float] containing the multiplicand.630/// \param __B631/// A 256-bit vector of [8 x float] containing the multiplier.632/// \param __C633/// A 256-bit vector of [8 x float] containing the addend.634/// \returns A 256-bit vector of [8 x float] containing the result.635static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR636_mm256_fnmadd_ps(__m256 __A, __m256 __B, __m256 __C)637{638 return (__m256)__builtin_elementwise_fma(-(__v8sf)__A, (__v8sf)__B,639 (__v8sf)__C);640}641 642/// Computes a negated multiply-add of 256-bit vectors of [4 x double].643/// For each element, computes <c> -(__A * __B) + __C </c>.644///645/// \headerfile <immintrin.h>646///647/// This intrinsic corresponds to the \c VFNMADD213PD instruction.648///649/// \param __A650/// A 256-bit vector of [4 x double] containing the multiplicand.651/// \param __B652/// A 256-bit vector of [4 x double] containing the multiplier.653/// \param __C654/// A 256-bit vector of [4 x double] containing the addend.655/// \returns A 256-bit vector of [4 x double] containing the result.656static __inline__ __m256d __DEFAULT_FN_ATTRS256_CONSTEXPR657_mm256_fnmadd_pd(__m256d __A, __m256d __B, __m256d __C)658{659 return (__m256d)__builtin_elementwise_fma(-(__v4df)__A, (__v4df)__B,660 (__v4df)__C);661}662 663/// Computes a negated multiply-subtract of 256-bit vectors of [8 x float].664/// For each element, computes <c> -(__A * __B) - __C </c>.665///666/// \headerfile <immintrin.h>667///668/// This intrinsic corresponds to the \c VFNMSUB213PS instruction.669///670/// \param __A671/// A 256-bit vector of [8 x float] containing the multiplicand.672/// \param __B673/// A 256-bit vector of [8 x float] containing the multiplier.674/// \param __C675/// A 256-bit vector of [8 x float] containing the subtrahend.676/// \returns A 256-bit vector of [8 x float] containing the result.677static __inline__ __m256 __DEFAULT_FN_ATTRS256_CONSTEXPR678_mm256_fnmsub_ps(__m256 __A, __m256 __B, __m256 __C)679{680 return (__m256)__builtin_elementwise_fma(-(__v8sf)__A, (__v8sf)__B,681 -(__v8sf)__C);682}683 684/// Computes a negated multiply-subtract of 256-bit vectors of [4 x double].685/// For each element, computes <c> -(__A * __B) - __C </c>.686///687/// \headerfile <immintrin.h>688///689/// This intrinsic corresponds to the \c VFNMSUB213PD instruction.690///691/// \param __A692/// A 256-bit vector of [4 x double] containing the multiplicand.693/// \param __B694/// A 256-bit vector of [4 x double] containing the multiplier.695/// \param __C696/// A 256-bit vector of [4 x double] containing the subtrahend.697/// \returns A 256-bit vector of [4 x double] containing the result.698static __inline__ __m256d __DEFAULT_FN_ATTRS256_CONSTEXPR699_mm256_fnmsub_pd(__m256d __A, __m256d __B, __m256d __C)700{701 return (__m256d)__builtin_elementwise_fma(-(__v4df)__A, (__v4df)__B,702 -(__v4df)__C);703}704 705/// Computes a multiply with alternating add/subtract of 256-bit vectors of706/// [8 x float].707///708/// \code{.operation}709/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0]710/// result[63:32] = (__A[63:32] * __B[63:32]) + __C[63:32]711/// result[95:64] = (__A[95:64] * __B[95:64]) - __C[95:64]712/// result[127:96] = (__A[127:96] * __B[127:96]) + __C[127:96]713/// result[159:128] = (__A[159:128] * __B[159:128]) - __C[159:128]714/// result[191:160] = (__A[191:160] * __B[191:160]) + __C[191:160]715/// result[223:192] = (__A[223:192] * __B[223:192]) - __C[223:192]716/// result[255:224] = (__A[255:224] * __B[255:224]) + __C[255:224]717/// \endcode718///719/// \headerfile <immintrin.h>720///721/// This intrinsic corresponds to the \c VFMADDSUB213PS instruction.722///723/// \param __A724/// A 256-bit vector of [8 x float] containing the multiplicand.725/// \param __B726/// A 256-bit vector of [8 x float] containing the multiplier.727/// \param __C728/// A 256-bit vector of [8 x float] containing the addend/subtrahend.729/// \returns A 256-bit vector of [8 x float] containing the result.730static __inline__ __m256 __DEFAULT_FN_ATTRS256731_mm256_fmaddsub_ps(__m256 __A, __m256 __B, __m256 __C)732{733 return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);734}735 736/// Computes a multiply with alternating add/subtract of 256-bit vectors of737/// [4 x double].738///739/// \code{.operation}740/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0]741/// result[127:64] = (__A[127:64] * __B[127:64]) + __C[127:64]742/// result[191:128] = (__A[191:128] * __B[191:128]) - __C[191:128]743/// result[255:192] = (__A[255:192] * __B[255:192]) + __C[255:192]744/// \endcode745///746/// \headerfile <immintrin.h>747///748/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction.749///750/// \param __A751/// A 256-bit vector of [4 x double] containing the multiplicand.752/// \param __B753/// A 256-bit vector of [4 x double] containing the multiplier.754/// \param __C755/// A 256-bit vector of [4 x double] containing the addend/subtrahend.756/// \returns A 256-bit vector of [4 x double] containing the result.757static __inline__ __m256d __DEFAULT_FN_ATTRS256758_mm256_fmaddsub_pd(__m256d __A, __m256d __B, __m256d __C)759{760 return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, (__v4df)__C);761}762 763/// Computes a vector multiply with alternating add/subtract of 256-bit764/// vectors of [8 x float].765///766/// \code{.operation}767/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0]768/// result[63:32] = (__A[63:32] * __B[63:32]) - __C[63:32]769/// result[95:64] = (__A[95:64] * __B[95:64]) + __C[95:64]770/// result[127:96] = (__A[127:96] * __B[127:96]) - __C[127:96]771/// result[159:128] = (__A[159:128] * __B[159:128]) + __C[159:128]772/// result[191:160] = (__A[191:160] * __B[191:160]) - __C[191:160]773/// result[223:192] = (__A[223:192] * __B[223:192]) + __C[223:192]774/// result[255:224] = (__A[255:224] * __B[255:224]) - __C[255:224]775/// \endcode776///777/// \headerfile <immintrin.h>778///779/// This intrinsic corresponds to the \c VFMSUBADD213PS instruction.780///781/// \param __A782/// A 256-bit vector of [8 x float] containing the multiplicand.783/// \param __B784/// A 256-bit vector of [8 x float] containing the multiplier.785/// \param __C786/// A 256-bit vector of [8 x float] containing the addend/subtrahend.787/// \returns A 256-bit vector of [8 x float] containing the result.788static __inline__ __m256 __DEFAULT_FN_ATTRS256789_mm256_fmsubadd_ps(__m256 __A, __m256 __B, __m256 __C)790{791 return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);792}793 794/// Computes a vector multiply with alternating add/subtract of 256-bit795/// vectors of [4 x double].796///797/// \code{.operation}798/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0]799/// result[127:64] = (__A[127:64] * __B[127:64]) - __C[127:64]800/// result[191:128] = (__A[191:128] * __B[191:128]) + __C[191:128]801/// result[255:192] = (__A[255:192] * __B[255:192]) - __C[255:192]802/// \endcode803///804/// \headerfile <immintrin.h>805///806/// This intrinsic corresponds to the \c VFMSUBADD213PD instruction.807///808/// \param __A809/// A 256-bit vector of [4 x double] containing the multiplicand.810/// \param __B811/// A 256-bit vector of [4 x double] containing the multiplier.812/// \param __C813/// A 256-bit vector of [4 x double] containing the addend/subtrahend.814/// \returns A 256-bit vector of [4 x double] containing the result.815static __inline__ __m256d __DEFAULT_FN_ATTRS256816_mm256_fmsubadd_pd(__m256d __A, __m256d __B, __m256d __C)817{818 return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, -(__v4df)__C);819}820 821#undef __DEFAULT_FN_ATTRS128822#undef __DEFAULT_FN_ATTRS256823#undef __DEFAULT_FN_ATTRS128_CONSTEXPR824#undef __DEFAULT_FN_ATTRS256_CONSTEXPR825 826#endif /* __FMAINTRIN_H */827