Last active
November 23, 2024 01:05
-
-
Save lydonchandra/8108925 to your computer and use it in GitHub Desktop.
How to use pshufd instruction (pack shuffle) //0x00 set all elems to 1st elem, 0000 0000 //0x55 set all elems to 2nd elem, 0101 0101 //0xAA set all elems to 3rd elem, 1010 1010 //0xFF set all elems to 4th elem, 1111 1111 //0x1B reverse order, 0001 1011
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf("m128i.m128_u32[0] = %04X _ before\n", m128i.m128_u32[0]); | |
printf("m128i.m128_u32[1] = %04X _ before\n", m128i.m128_u32[1]); | |
printf("m128i.m128_u32[2] = %04X _ before\n", m128i.m128_u32[2]); | |
printf("m128i.m128_u32[3] = %04X _ before\n", m128i.m128_u32[3]); | |
__asm { | |
pxor xmm5, xmm5 | |
//vpshufd xmm5, m128i, 0xAA | |
vpshufd xmm5, m128i, 0x55 | |
//0x00 set all elems to 1st elem, 0000 0000 | |
//0x55 set all elems to 2nd elem, 0101 0101 | |
//0xAA set all elems to 3rd elem, 1010 1010 | |
//0xFF set all elems to 4th elem, 1111 1111 | |
//0x1B reverse order, 0001 1011 | |
vmovupd m128i, xmm5 | |
} | |
printf("m128i.m128_u32[0] = %04X _ after\n", m128i.m128_u32[0]); | |
printf("m128i.m128_u32[1] = %04X _ after\n", m128i.m128_u32[1]); | |
printf("m128i.m128_u32[2] = %04X _ after\n", m128i.m128_u32[2]); | |
printf("m128i.m128_u32[3] = %04X _ after\n", m128i.m128_u32[3]); | |
//Output: | |
//m128i.m128_u32[0] = 11111111 _ before | |
//m128i.m128_u32[1] = 22222222 _ before | |
//m128i.m128_u32[2] = 33333333 _ before | |
//m128i.m128_u32[3] = 44444444 _ before | |
//m128i.m128_u32[0] = 11111111 _ after | |
//m128i.m128_u32[1] = 22222222 _ after | |
//m128i.m128_u32[2] = 11111111 _ after | |
//m128i.m128_u32[3] = 11111111 _ after |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment