在 2023/4/26 00:01, Andy via Gcc 写道:
I see it in godbolt
GCC compiles to:
movsx eax, BYTE PTR [rdi+2]
cmp al, 9
ja .L42
Clang:
movzx edx, byte ptr [rdi + 2]
cmp edx, 9
ja .LBB0_40


GCC extend with sign, Clang with zero.
cmp with 32 bit register is apparently faster than 8bit

As for extension, it seems to make a difference only if the result is ever written back to memory. And for comparison, it makes completely no difference whether the operand is 32-bit or 8-bit, except when the operand is an 8-bit ?H register. [1]


[1] https://uops.info/table.html


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to