Issue 61400
Summary [WASM] Suboptimal `memcmp` expansion for odd lengths
Labels new issue
Assignees
Reporter MaxGraey
    # Example ([godbolt](https://godbolt.org/z/jMo4f9G18))
Calls to `memcmp(a, b, n) == 0`, where `n` is odd is suboptimal for `wasm32` target where such call didn't lower to expansion and calls `memcpy` routine even for small lengths (`n` <= 14)

Here codegen for  `memcmp(a, "abc", 3) == 0`:
### x64
```asm
movzx   eax, word ptr [rdi]
xor     eax, 25185
movzx ecx, byte ptr [rdi + 2]
xor     ecx, 99
or      cx, ax
sete al
ret
```
### wasm32
```wat
local.get  0
i32.const .L.str.2
i32.const  3
call       memcmp
i32.eqz
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to