-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
Description
Bugzilla Link | 51978 |
Version | trunk |
OS | Linux |
CC | @alexey-bataev,@anton-afanasyev,@fhahn,@kamleshbhalui,@RKSimon,@rotateright |
Extended Description
void foo_notvectorized(unsigned char *p, unsigned char *t) {
char sum = 0;
for (int i = 0; i != 4; i++)
sum += p[i];
*t = sum;
}
char foo_vectorized(char *p) {
char sum = 0;
for (int i = 0; i != 4; i++)
sum += p[i];
return sum;
}
foo_notvectorized:
mov al, byte ptr [rdi + 1]
add al, byte ptr [rdi]
add al, byte ptr [rdi + 2]
add al, byte ptr [rdi + 3]
mov byte ptr [rsi], al
ret
foo_vectorized:
movd xmm0, dword ptr [rdi] # xmm0 = mem[0],zero,zero,zero
pxor xmm1, xmm1
psadbw xmm1, xmm0
movd eax, xmm1
ret