https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124624
--- Comment #5 from Kang-Che Sung <Explorer09 at gmail dot com> --- (In reply to Shivam Gupta from comment #4) > Is this issue fixed on trunk, from godbolt - https://godbolt.org/z/3hjTTzb75: > > trunk - > .L5: > movl %esi, %ecx > movl $-1, %edx > shrl $16, %ecx > cmovne %edx, %eax > ret > > 15.1 - > .L6: > or eax, -1 > ret > .L5: > mov ecx, esi > shr ecx, 16 > je .L4 > jmp .L6 > ... > .L4: > ret I would argue it's no. The code looks worse in GCC 16.1. For a fairer comparison, you might use -Oz instead of -Os. -Oz *should* disable some CMOV transformations that are unhelpful in code size reduction, and in this case GCC's use of `mov edx, -1 /*...*/ cmovne eax, edx` increases the code size. See this link: <https://godbolt.org/z/1vsfxnPj4>
