http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50223
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
CC| |gjl at gcc dot gnu.org
--- Comment #1 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-08-31
20:23:25 UTC ---
This is just a missed optimization. Thus, you won't see a fix before gcc 4.7.
For gcc 4.7, notice that there are optimized versions of builtins that perform
your arithmetic like
__builtin_clz/clzl/clzll (count leading zeros)
__builtin_ctz/ctzl/ctzll (count trailing zeros)
__builtin_ffs/ffsl/ffsll (find first (lowest) set bit)
...