_mm_maccshi_epi32

Visual Studio 2010

Visual Studio 2010 SP1 is required.

Microsoft Specific

Generates the XOP instruction vpmacssdqh to perform a saturating integer multiply-add of its sources.

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

[in] src1

A 128-bit parameter that contains two 32-bit signed integers in its odd-indexed doublewords.

[in] src2

A 128-bit parameter that contains two 32-bit signed integers in its odd-indexed doublewords.

[in] src3

A 128-bit parameter that contains two 64-bit signed integers.

A 128-bit result r that contains two 64-bit signed integers.

r[0] := src1[1] * src2[1] + src3[0];
r[1] := src1[3] * src2[3] + src3[1];

Intrinsic

Architecture

_mm_maccshi_epi32

XOP

Header file <intrin.h>

Each odd-indexed 32-bit signed integer value in src1 is each multiplied by the corresponding 32-bit signed integer value in src2, each 64-bit signed integer product is added to the corresponding 64-bit signed integer value in src3, and the signed 64-bit integer result is stored as the corresponding value in the destination. The even-indexed doublewords in src1 and src2 are ignored.

If the result of the addition to the 64-bit product is greater than 9223372036854775807 (0x7FFFFFFFFFFFFFFF) or less than -9223372036854775808 (0x8000000000000000), the multiply-add saturates by setting the result value to 9223372036854775807 or -9223372036854775808, respectively.

The vpmacssdqh 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.

#include <stdio.h>
#include <intrin.h>
int main()
{
    __m128i a, b, c, d;
    int i;
    a.m128i_i32[1] = 2000000000;
    a.m128i_i32[3] = 2000000000;
    b.m128i_i32[1] = -2000000000;
    b.m128i_i32[3] = 2000000000;
    c.m128i_i64[0] = 9000000000000000000ll;
    c.m128i_i64[1] = 9000000000000000000ll;
    d = _mm_maccshi_epi32(a, b, c);
    for (i = 0; i < 2; i++)
        printf_s(" %20I64d (0x%I64x)\n",
            d.m128i_i64[i], d.m128i_i64[i]);
 }
5000000000000000000 (0x4563918244f40000)
 9223372036854775807 (0x7fffffffffffffff)

Community Additions

ADD
Show: