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

            Bug ID: 127348
           Summary: [X86] (a & 1) == 0 not using test + sete
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kaelfandrew at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/dEeozoKxd

With -O2:

```
bool
src (unsigned int a)
{
  return (a & 1) == 0;
}

/* GCC trunk assembly
"src":
        mov     eax, edi
        not     eax
        and     eax, 1
        ret
*/

/* Clang trunk assembly
src:
        test    dil, 1
        sete    al
        ret
*/
```

As of r17-4177,
it shows up in GCC with some examples:

ada/gcc-interface/utils.cc:3646:      while ((mask & 1) == 0 && i <
HOST_BITS_PER_WIDE_INT)
ada/gcc-interface/utils2.cc:647:      if (mh != 0 && (d & 1) == 0)
ada/init.c:1523:  if ((status & 1) != 1)
c/c-parser.cc:22296:      if (((mask >> c_kind) & 1) == 0)

Reply via email to