factorize upper_bits_clean and use in sparc+ia32