[Bug middle-end/94787] Failure to detect single bit popcount pattern

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Mar 4 16:42:37 GMT 2024


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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
And add:
```
int h(int a)
{
        if (a == 0) return 0;
        return __builtin_popcount(a) == 1;
}

int h1(int a)
{
        if (a == 0) return 1;
        return __builtin_popcount(a) == 1;
}
```

h should be just `__builtin_popcount(a) == 1`.
While h1 should be just `__builtin_popcount(a) <= 1`.


More information about the Gcc-bugs mailing list