3 ms·
Actually, I just tried it: float[] floats = new float[1000]; float factor = 1.01f; int index = 0; while (index
by jj10 11y ago
Actually, I just tried it:
float[] floats = new float[1000];
float factor = 1.01f;
int index = 0;
while (index < 1000)
{
floats[index++] *= factor;
}
...becomes...
00007ff8`80a804a9 488d549010 lea rdx,[rax+rdx*4+10h]
00007ff8`80a804ae c4e17a1002 vmovss xmm0,dword ptr [rdx]
00007ff8`80a804b3 c4e17a590524000000 vmulss xmm0,xmm0,dword ptr [00007ff8`80a804e0]
00007ff8`80a804bc c4e17a1102 vmovss dword ptr [rdx],xmm0
This is in VS 2013, compiled with DEBUG off, prefer x86 off, and 'any cpu' as the target.
- tbirdz 11y agoThose are scalar instructions, not the SIMD instructions. With x86_64 the fpu stack operations are basically for legacy purposes only, and normal floating point operations are expected to be done with the SSE/AVX scalar instructions. SIMD instruction used the packed variants of the commands allowing you to multiple say 4 floats in a single instruction.