Share via


_mm_maddd_epi16

Visual Studio 2010 SP1 is required.

Microsoft Specific

Generates the XOP instruction vpmadcswd to perform an integer multiply-add-accumulate of its sources.

__m128i _mm_maddd_epi16 (
   __m128i src1,
   __m128i src2,
   __m128i src3
);

Parameters

  • [in] src1
    A 128-bit parameter that contains eight 16-bit signed integers.

  • [in] src2
    A 128-bit parameter that contains eight 16-bit signed integers.

  • [in] src3
    A 128-bit parameter that contains four 32-bit signed integers.

Return value

A 128-bit result r that contains four 32-bit signed integers.

tempeven[i] := src1[2*i] * src2[2*i]; // 16*16->32
tempodd[i] := src1[2*i+1] * src2[2*i+1]; // 16*16->32
r[i] = tempeven[i] + tempodd[i] + src3[i];

Requirements

Intrinsic

Architecture

_mm_maddd_epi16

XOP

Header file <intrin.h>

Remarks

Each even-indexed 16-bit signed integer value in src1 is multiplied by the corresponding 16-bit signed integer value in src2. The next (odd-indexed) 16-bit signed integer value in src1 is multiplied by its corresponding 16-bit signed integer value in src2. The 32-bit signed integer products are added, their sum is added to the corresponding 32-bit signed integer value in src3, and the signed 32-bit integer result is stored as the corresponding value in the destination.

Overflow is ignored.

The vpmadcswd instruction is part of the XOP family of instructions. Before you use this intrinsic, you must ensure that the processor supports this instruction. To determine hardware support for this instruction, call the __cpuid intrinsic with InfoType = 0x80000001 and check bit 11 of CPUInfo[2] (ECX). This bit is 1 when the instruction is supported, and 0 otherwise.

Example

#include <stdio.h>
#include <intrin.h>
int main()
{
    __m128i a, b, c, d;
    int i;
    for (i = 0; i < 8; i++) {
        a.m128i_i16[i] = 8000*(i-4);
        b.m128i_i16[i] = 10000;
    }
    for (i = 0; i < 4; i++) {
        c.m128i_i32[i] = -1900000000;
    }
    d = _mm_maddd_epi16(a, b, c);
    for (i = 0; i < 4; i++) printf_s(" %d", d.m128i_i32[i]);
    printf_s("\n");
}
1834967296 -2140000000 -1820000000 -1500000000

See Also

Reference

_mm_maddsd_epi16

__cpuid, __cpuidex

XOP Intrinsics Added for Visual Studio 2010 SP1