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

            Bug ID: 112533
           Summary: missed optimization (~A & C) == (~B & C) => (A & C) ==
                    (B & C)
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vanyacpp at gmail dot com
  Target Milestone: ---

On this code

static bool is_even(unsigned a)
{
    return a % 2 == 0;
}

bool same_evenness(unsigned a, unsigned b)
{
    return is_even(a) == is_even(b);
}

GCC -02 currently produces

same_evenness:
        notl    %esi         // (1)
        notl    %edi         // (2)
        andl    $1, %esi
        andl    $1, %edi
        cmpb    %dil, %sil
        sete    %al
        ret

The NOTs (1) and (2) are redundant. It would be great if GCC could optimize
them out.

Reply via email to