Created
April 14, 2015 02:29
-
-
Save jbarczak/04e4ab898edf2e335917 to your computer and use it in GitHub Desktop.
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
Microsoft compiler appears to ignore prefetches inside a loop. | |
Tested this on MSVC 2013 express edition. Microsoft's connect site says I am not authorized to submit feedback for who knows what reason, or else I'd send it there directly...... | |
Code I used: | |
void Foo( char* p, int* q ) | |
{ | |
for( size_t i=0; i<8; i++ ) | |
_mm_prefetch(p+q[i], _MM_HINT_T0 ); | |
} | |
ASM I got: | |
movsxd rax, DWORD PTR [rdx] | |
prefetcht0 BYTE PTR [rax+rcx] | |
ret 0 | |
Hmmm, not quite what I wanted.... Tweaking the loop makes it even more obvious. | |
code: | |
int Foo( char* p, int* q ) | |
{ | |
int j=0; | |
for( size_t i=0; i<8; i++ ) | |
{ | |
_mm_prefetch(p+q[i], _MM_HINT_T0 ); | |
j += q[i]; | |
} | |
return j; | |
} | |
asm: | |
movsxd rax, DWORD PTR [rdx] | |
prefetcht0 BYTE PTR [rax+rcx] | |
add eax, DWORD PTR [rdx+4] | |
add eax, DWORD PTR [rdx+8] | |
add eax, DWORD PTR [rdx+12] | |
add eax, DWORD PTR [rdx+16] | |
add eax, DWORD PTR [rdx+20] | |
add eax, DWORD PTR [rdx+24] | |
add eax, DWORD PTR [rdx+28] | |
ret 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment