Posts

Showing posts with the label x86

Compiler choice of not using REP MOVSB instruction for a byte array move

Image
Compiler choice of not using REP MOVSB instruction for a byte array move I'm checking the Release build of my project done with the latest version of the VS 2017 C++ compiler. And I'm curious why did compiler choose to build the following code snippet: //ncbSzBuffDataUsed of type INT32 UINT8* pDst = (UINT8*)(pMXB + 1); UINT8* pSrc = (UINT8*)pDPE; for(size_t i = 0; i < (size_t)ncbSzBuffDataUsed; i++) { pDst[i] = pSrc[i]; } as such: UINT8* pDst = (UINT8*)(pMXB + 1); UINT8* pSrc = (UINT8*)pDPE; for(size_t i = 0; i < (size_t)ncbSzBuffDataUsed; i++) 00007FF66441251E 4C 63 C2 movsxd r8,edx 00007FF664412521 4C 2B D1 sub r10,rcx 00007FF664412524 0F 1F 40 00 nop dword ptr [rax] 00007FF664412528 0F 1F 84 00 00 00 00 00 nop dword ptr [rax+rax] 00007FF664412530 41 0F B6 04 0A movzx eax,byte ptr [r10+rcx] { pDst[i] = pSrc[i]; 00007FF664412535 88 01 ...