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

LIU Hao <lh_mouse at 126 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lh_mouse at 126 dot com

--- Comment #4 from LIU Hao <lh_mouse at 126 dot com> ---
Are there any reasons why this was not done for 64?
(https://gcc.godbolt.org/z/7vddPdxaP)


```
using int32_t = int;
using int64_t = long long;
using uint32_t = unsigned int;
using uint64_t = unsigned long long;

void
xlzcnt32(int32_t& val)
  {
    val = val ? (__builtin_clz(val) & 31) : 32;
  }

void
xlzcnt64(int64_t& val)
  {
    val = val ? (__builtin_clzll(val) & 63) : 64;
  }
```

results in
```
xlzcnt32(int&):
        xor     eax, eax
        lzcnt   eax, DWORD PTR [rdi]
        mov     DWORD PTR [rdi], eax
        ret
xlzcnt64(long long&):
        mov     rdx, QWORD PTR [rdi]
        xor     eax, eax
        lzcnt   rax, rdx
        test    rdx, rdx
        mov     edx, 64
        cmove   rax, rdx
        mov     QWORD PTR [rdi], rax
        ret
```

Reply via email to