Last active
January 1, 2016 08:58
-
-
Save lydonchandra/8121320 to your computer and use it in GitHub Desktop.
test_vinsertps.cpp
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
void test_vinsertps() { | |
__m128i m128_1; | |
unsigned long long allOneLL = 0x2222222211111111LL; | |
unsigned long long allTwoLL = 0x4444444433333333LL; | |
((unsigned long long*)&m128_1)[0] = allOneLL; | |
((unsigned long long*)&m128_1)[1] = allTwoLL; | |
__asm { | |
pxor xmm5, xmm5 | |
vpshufd xmm5, m128_1, 228 | |
//11 10 01 00 == 228, copy m128_1 into xmm5 | |
pxor xmm4, xmm4 | |
//vinsertps xmm4, xmm5, m128_1, 144 | |
//144 == 10 01 00 00 | |
//source 10 = 2, because m128_1 is a memory location, source is set to 0 | |
//dest 01 = 1, xmm4[63:32] | |
//insert m128_1[31:0] into xmm4[63:32], and copy other bits of xmm5 into xmm4 | |
//xmm4 == 0x4444_4444_3333_3333_1111_1111_1111_1111 | |
//vinsertps xmm4, xmm5, xmm5, 144 | |
//144 == 10 01 00 00 | |
//source 10 = 2, xmm5[95:64] | |
//dest 01 = 1, xmm4[63:32] | |
//insert xmm5[95:64] into xmm4[63:32], and copy other bits from xmm5 into xmm4 | |
//xmm4 == 0x4444_4444_3333_3333_3333_3333_1111_1111 | |
//vinsertps xmm4, xmm5, xmm5, 192 | |
//192 == 11 00 00 00 | |
//source 11 == 3, xmm5[127:96] | |
//dest 00 == 1, xmm4[31:0] | |
//insert xmm5[127:96] into xmm4[31:0], and copy other bits from xmm5 into xmm4 | |
//xmm4 == 0x4444_4444_3333_3333_2222_2222_4444_4444 | |
vinsertps xmm4, xmm5, xmm5, 195 | |
//195 == 11 00 00 11 | |
//source 11 == 3, xmm5[127:96] | |
//dest 00 == 1, xmm4[31:0] | |
//mask 0011 == xmm4[63:32] == xmm4[31:0] == 0 | |
//xmm4 == 0x4444_4444_3333_3333_0000_0000_0000_0000 | |
vmovapd m128_1, xmm4 | |
} | |
unsigned long long LL1, LL2; | |
LL1 = 0LL; | |
LL2 = 0LL; | |
LL1 = ((unsigned long long*)&m128_1)[0]; | |
LL2 = ((unsigned long long*)&m128_1)[1]; | |
printf("LL1=%llx \nLL2=%llx\n", LL1, LL2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment