https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107338
--- Comment #3 from avieira at gcc dot gnu.org --- Hi Kewen, I believe you are right. I was waiting for a powerpc machine in the board farm, but I suspect I can reproduce this with an aarch64 BE target and I should be able to confirm. But your reasoning seems valid to me. Because of the widening the shift_n becomes 32-shift_n-mask_width, but the start of the bitfield didn't move by widening the container, so it is still 16 - shift_n - mask_width bits away from the start of the container. Moving the calculation before the widening seems like the neatest solution to me, there's no point in keeping the old type around I think. Do you want to produce a patch for this, seeing you solved it?