3 ms·
Good at autovectorizing? Eh, if you massage your code in godbolt until it kicks in. But just naively writing code often falls off the happy path. And even when
by the8472 1y ago
Good at autovectorizing? Eh, if you massage your code in godbolt until it kicks in. But just naively writing code often falls off the happy path. And even when it autovectorizes it can sometimes produce such gems as
vmovdqu xmm1, xmmword ptr [rdx]
vmovdqu xmm0, xmmword ptr [rdx + 16]
mov rax, rdi
vmovd ecx, xmm1
or byte ptr [rsi], cl
vpextrb ecx, xmm1, 1
or byte ptr [rsi + 1], cl
vpextrb ecx, xmm1, 2
or byte ptr [rsi + 2], cl
vpextrb ecx, xmm1, 3
or byte ptr [rsi + 3], cl
vpextrb ecx, xmm1, 4
or byte ptr [rsi + 4], cl
vpextrb ecx, xmm1, 5
or byte ptr [rsi + 5], cl
...
vpextrb ecx, xmm0, 15
or byte ptr [rsi + 31], cl
vmovups ymm0, ymmword ptr [rsi]
vmovups ymmword ptr [rdi], ymm0
instead of a vorps
- rerdavies 1y agoRight. That is a given. you massage your code in godbolt (or equivalent) until it kicks in. Not denying that. Compile but verify.
- rerdavies 1y agoDidn't require that much coaxing. -O3 --fast-math, i7-avx architecture. What did you do to break it?! xor eax, eax .L2: vmovdqu xmm1, XMMWORD PTR [rdx+rax] vinsertf128 ymm1, ymm1, XMMWORD PTR [rdx+16+rax], 0x1 vmovdqu xmm0, XMMWORD PTR [rsi+rax] vinsertf128 ymm0, ymm0, XMMWORD PTR [rsi+16+rax], 0x1 vorps ymm0, ymm0, ymm1 vmovdqu XMMWORD PTR [rdi+rax], xmm0 vextractf128 XMMWORD PTR [rdi+16+rax], ymm0, 0x1 add rax, 32 cmp rax, 4096 jne .L2 vzeroupper ret
- the8472 1y agoIt was an optimization bug in llvm. https://godbolt.org/z/GqdPGarsn https://godbolt.org/z/GqdPGarsn We filed an issue, this one is fixed now. https://github.com/llvm/llvm-project/issues/65763 https://github.com/llvm/llvm-project/issues/65763