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

            Bug ID: 101821
           Summary: Redundant xor eax eax
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: llvm at rifkin dot dev
  Target Milestone: ---

Gcc is generating an unnecessary and redundant xor eax eax in the following
code

#include <bit>
#include <stdint.h>
uint32_t pop(uint32_t n) {
    return std::popcount(n);
}


pop(unsigned int):
        xor     eax, eax
        popcnt  eax, edi
        ret

https://godbolt.org/z/81o1Y6T5x

Reply via email to