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

--- Comment #11 from Piotr Siupa <piotrsiupa at gmail dot com> ---
Thanks! Now the generated assembly is one instruction shorter.

It works for:
bool foo(unsigned x)
{
    [[assume(x != 0)]];
    return std::has_single_bit(x);
}
and for:
bool foo(unsigned x)
{
    if (x == 0)
        std::unreachable();
    else
        return std::has_single_bit(x);
}

However, I've noticed that:
bool foo(unsigned x)
{
    if (x == 0)
        return true;
    else
        return std::has_single_bit(x);
}
still uses (X ^ (X - 1)) > (X - 1).

Reply via email to