-
Notifications
You must be signed in to change notification settings - Fork 16.8k
[WASM] Suboptimal memcmp expansion for odd lengths #61400
Copy link
Copy link
Closed
Description
Example (Godbolt)
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 memcmp routine even for small lengths (n < 16)
Here codegen for memcmp(a, "abc", 3) == 0:
x64
movzx eax, word ptr [rdi]
xor eax, 25185
movzx ecx, byte ptr [rdi + 2]
xor ecx, 99
or cx, ax
sete al
retwasm32 (actual)
local.get 0
i32.const .L.str.2
i32.const 3
call memcmp
i32.eqzwasm32 (expected)
local.get 0
i32.load16_u 0 ;;align=1 ???
i32.const 25185
i32.xor
local.get 0
i32.load8_u 2
i32.const 99
i32.xor
i32.or
i32.eqzReactions are currently unavailable