[Bug target/29776] result of ffs/clz/ctz/popcount/parity are already sign-extended

sgunderson at bigfoot dot com gcc-bugzilla@gcc.gnu.org
Wed Jul 3 22:39:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29776

sgunderson at bigfoot dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sgunderson at bigfoot dot com

--- Comment #6 from sgunderson at bigfoot dot com ---
Without knowing anything about the GCC internals here, I could perhaps also
point out that GCC should know that these have limited range. As a trivial
example:

int foo(int x)
{
        int z = __builtin_ctz(x);
        if (z > 2000) {
                return 1;
        } else {
                return 0;
        }
}

There's no way this function can return anything but 0, and VRP should probably
be taught that. (I wonder if this would fix the unneccessary sign extension
too?)



More information about the Gcc-bugs mailing list