Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shifting a __m128i using _mm_slli_epi64

Tags:

c

sse

I am trying to use _mm_slli_epi64 to shift a _m128i by one position. What I don't understand is, that the following code does not give me an all-zeroes output as I expected, but rather prints 0x00010000000000000000000000000000. What might be wrong?

__m128i z = _mm_setr_epi8(0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
printblock("z = ", z);
z = _mm_slli_epi64(z, 1);
printblock("z = ", z);
return;
like image 213
Martin Lauridsen Avatar asked Mar 21 '23 17:03

Martin Lauridsen


1 Answers

_mm_slli_epi64 shifts each 64 bit integer left by the given number of bits. You have two 64 bit integers in your __m128i:

0x0000000000000000 0x0000000000000080

and so when you shift each one left by one bit you get:

0x0000000000000000 0x0000000000000100
like image 103
Paul R Avatar answered Apr 02 '23 10:04

Paul R