https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104914
--- Comment #19 from Roger Sayle <roger at nextmovesoftware dot com> --- Created attachment 56930 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56930&action=edit proposed patch And now for a patch that does (or should) work. This even contains an optimization, we middle-end knows we don't need to sign or zero extend if a insv doesn't modify the sign-bit. Testing on MIPS would be much appreciated. TIA.