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

            Bug ID: 95535
           Summary: Failure to optimize out cdqe after __bultin_ctz
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

long long f(int n)
{
    return __builtin_ctz(n);
}

With -O3, GCC outputs this :

f(int):
  xor eax, eax
  tzcnt eax, edi
  cdqe
  ret

LLVM outputs this :

f(int): # @f(int)
  tzcnt eax, edi
  ret

Looks like the cdqe can be omitted.

Reply via email to