[Bug target/25671] test_bit() compilation does not expand to "bt" instruction

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Aug 19 20:46:58 GMT 2021


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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there is a bug in the original testcase.
It should be:

int test_bit(unsigned long *words, int bit)
{
    int wsize = (sizeof *words) * 8;
    return (words[bit / wsize] & (1ul << (bit % wsize))) != 0;
}

if int is 32bit and long is 64bit, you would have gotten the wrong result.


More information about the Gcc-bugs mailing list