https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97503

--- Comment #5 from LIU Hao <lh_mouse at 126 dot com> ---
(In reply to LIU Hao from comment #4)
>         lzcnt   rax, rdx
>         test    rdx, rdx
>         mov     edx, 64
>         cmove   rax, rdx

There is actually another missed optimization here. LZCNT sets CF if the source
operand is zero. so the TEST instruction is totally unnecessary. We can do
this:

```
  ...
  xor eax, eax
  lzcnt rax, rdx
  mov edx, 64           # or something else, whatever
  cmovb eax, edx
```

Reply via email to