다음을 통해 공유


_mm_cvtepi8_epi16

Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction pmovsxbw. This instruction performs a conversion of signed integers from 8-bit to 16-bit.

__m128i _mm_cvtepi8_epi16( 
   __m128i a
);

Parameters

  • [in] a
    A 128-bit parameter that contains eight signed 8-bit integers in the lower 64 bits.

Return value

A 128-bit parameter that contains eight 16-bit integers. These integers are sign-extended representations of the 8-bit integers that are supplied by a.

The result is defined as follows:

r0 := a0
r1 := (a0 < 0) ? 0xff : 0
r2 := a1
r3 := (a1 < 0) ? 0xff : 0
...
r14 := a7
r15 := (a7 < 0) ? 0xff : 0

Requirements

Intrinsic

Architecture

_mm_cvtepi8_epi16

x86, x64

Header file <smmintrin.h>

Remarks

r0-r15 and a0-a15 are the sequentially ordered 8-bit components of return value r and parameter a, respectively. r0 and a0 are the least significant 8 bits.

Before you use this intrinsic, software must ensure that the processor supports the instruction.

Example

#include <stdio.h>
#include <smmintrin.h>

int main ()
{
    __m128i a;

    a.m128i_i8[0] = 1;
    a.m128i_i8[1] = -1;
    a.m128i_i8[2] = -100;
    a.m128i_i8[3] = 100;
    a.m128i_i8[4] = -128;
    a.m128i_i8[5] = 127;
    a.m128i_i8[6] = 0;
    a.m128i_i8[7] = 12;

    __m128i res = _mm_cvtepi8_epi16(a);

    printf_s("Original lowest 8 bit integers:\n%4i, %4i\n%4i, %4i\n%4i, %4i\n%4i, %4i\n\n",
        a.m128i_i8[7], a.m128i_i8[6], a.m128i_i8[5], a.m128i_i8[4],
        a.m128i_i8[3], a.m128i_i8[2], a.m128i_i8[1], a.m128i_i8[0]);

    printf_s("Resulting 16 bit integers:\n%4i, %4i\n%4i, %4i\n%4i, %4i\n%4i, %4i\n",
        res.m128i_i16[7], res.m128i_i16[6], res.m128i_i16[5], res.m128i_i16[4],
        res.m128i_i16[3], res.m128i_i16[2], res.m128i_i16[1], res.m128i_i16[0]);

    return 0;
}
Original lowest 8 bit integers:
  12,    0
 127, -128
 100, -100
  -1,    1

Resulting 16 bit integers:
  12,    0
 127, -128
 100, -100
  -1,    1

See Also

Reference

Compiler Intrinsics