How to prepare data for use with MMX/SSE intrinsics for shifting 16bit values?

67 views Asked by At

No matter what I do with {0,8,16,0}(16bit vector, representation for copying into a big endian 64bit value) I am unable to properly bit shift a test value of { 0x00, 0x01, (...) 0x07 };
The result I get in the debugger is always 0x0.

I tried to convert the value in a couple of different ways, but I am unable to get this right.

Executed on a little endian:

#include <mmintrin.h>
#include <stdint.h>

int main(int argc, char** argv) {
    __m64 input;
    __m64 vectors;
    __m64 output;

    _Alignas(8) uint16_t bit16Vectors[1*4] = {
        0x0000,0x0008,0x0010,0x0000
        // Intent: {0,8,16,0} 16 bit array
        // Convert for copy: {0,16,8,0} 64bit one item
        // 8bit data, Bytes need to rotate: {0,8,16,0}
    };
    _Alignas(8) uint8_t in[8] = {
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
    };

    input = _m_from_int64(*((long long*)in) );
    vectors = _m_from_int64 (*((long long*)bit16Vectors));
    output = _mm_sll_pi16(input, vectors);
    __asm__("int3");
}

I wrote down a simple MMX-only RGB24 plane separation pseudoAssembly[which processes 8x1 values], but I am unable to convert all the 16+32bit bit shift vectors to "real world", or I do something wrong with the intrinsics.

I am unable to pin it down exactly, I just know it fails at the very first bit shift and returns the value of 0x0.

0

There are 0 answers