Share via


_mm_clmulepi64_si128

Microsoft Specific

Emits the instruction pclmulqdq. This instruction performs a multiplication of two 64-bit integers. The multiplication does not calculate a carry bit.

__m128i _mm_clmulepi64_si128 (
   __m128i v1,
   __m128i v2,
   const int imm8
);

Parameters

Parameter

Description

[in] v1

The first parameter to multiply.

[in] v2

The second parameter to multiply.

[in] imm8

A constant that indicates which halves of the input parameters to use as operands.

Return value

The product calculated by multiplying 64 bits of v1 and 64 bits of v2.

Requirements

Intrinsic

Architecture

_mm_clmulepi64_si128

x86, x64

Header file <wmmintrin.h>

Remarks

Use the following table to determine which halves of v1 and v2 are used to calculate the product.

Bit 4 of imm8

Bit 0 of imm8

Product

0

0

v1[63:0] * v2[63:0]

0

1

v1[127:64] * v2[63:0]

1

0

v1[63:0] * v2[127:64]

1

1

v1[127:64] * v2[127:64]

Example

#include <wmmintrin.h>
#include <stdio.h>

int main()
{
    __m128i a;
    __m128i b;

    a.m128i_i64[1] = 2;
    a.m128i_i64[0] = -1284;
    b.m128i_i64[1] = 25;
    b.m128i_i64[0] = 65535;

    // _mm_clmulepi64_si128 only looks at the least significant bit of each
    // hexadecimal integer
    const int product1 = 0x11;
    const int product2 = 0x00;
    const int product3 = 0xF2;

    int expect1 = int ( a.m128i_i64[1] * b.m128i_i64[1] );
    int expect2 = int ( a.m128i_i64[0] * b.m128i_i64[0] );
    int expect3 = int ( a.m128i_i64[0] * b.m128i_i64[1] );

    __m128i result1 = _mm_clmulepi64_si128( a, b, product1 );
    __m128i result2 = _mm_clmulepi64_si128( a, b, product2 );
    __m128i result3 = _mm_clmulepi64_si128( a, b, product3 );

    printf_s("%I64d times %I64d without a carry bit: %I64d\n", 
        a.m128i_i64[1], b.m128i_i64[1], result1.m128i_i64[0]);
    printf_s("%I64d times %I64d without a carry bit: %I64d\n", 
        a.m128i_i64[0], b.m128i_i64[0], result2.m128i_i64[0]);
    printf_s("%I64d times %I64d without a carry bit: %I64d\n", 
        a.m128i_i64[0], b.m128i_i64[1], result3.m128i_i64[0]);

    return 0;
}

2 times 25 without a carry bit: 50 -1284 times 65535 without a carry bit: 50419284 -1284 times 25 without a carry bit: -32036

See Also

Reference

Compiler Intrinsics

Change History

Date

History

Reason

July 2008

Added the documentation for this new feature.

SP1 feature change.