https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110557
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- It looks like if !UNSIGNED_TYPE (TREE_TYPE (bf_ref)), we need to generate something like: masked = (the signed variant of the wider type in {type_out, type_container}) container << (bitpos + bitsize); result = (type_out) >> bitpos;