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

            Bug ID: 98567
           Summary: Failure to optimize using ZF flag from blsi
           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: ---

bool f(__UINT64_TYPE__ x)
{
    return (-x & x) == 0;
}

With -O3 -mbmi, LLVM compiles this to:

f:
  blsi rax, rdi
  sete al
  ret

GCC compiles this to:

f:
  blsi rdi, rdi
  test rdi, rdi
  sete al
  ret

The usage of `test` can be entirely removed, as `blsi` already sets ZF
accordingly.

Reply via email to