Microsoft Specific

Generates the movshdup instruction.

__m128 _mm_movehdup_ps( 
   __m128 source


  • [in] source
    The source data.





Intel SSE3

Header file <intrin.h>

Return Value

The return value represents an XMM register containing the duplicated elements as described in the Remarks section.


The _mm_movehdup_ps intrinsic duplicates the second and fourth 32-bit data elements in the source data and places the second into the first and second elements, and the fourth element into the third and fourth elements of the return value. Thus, if source is { A0, A1, A2, A3 }, the return value is { A1, A1, A3, A3 }.


// processor: x86 with SSE3
// Execute the movshdup instruction using the intrinsic
// _mm_movehdup_ps 

#include <stdio.h>
#include <intrin.h>

#pragma intrinsic ( _mm_movehdup_ps )

int main( )
    __m128 u, v;
    __declspec(align(16)) float f[4] = { 0.1, 0.2, 0.3, 0.4 };

    printf_s("Source data: %f %f %f %f\n", f[0], f[1], f[2], f[3]);

    // Load the array a into an XMM register.
    u = _mm_load_ps( f );
    printf_s("Calling _mm_movedup_ps to duplicate the values.\n");
    v = _mm_movehdup_ps ( u );

    printf_s("Result: %f %f %f %f\n", v.m128_f32[0], v.m128_f32[1],
           v.m128_f32[2], v.m128_f32[3] );

Source data: 0.100000 0.200000 0.300000 0.400000 Calling _mm_movedup_ps to duplicate the values. Result: 0.200000 0.200000 0.400000 0.400000

See Also


Compiler Intrinsics