# Narrow signed shifts must extend from the operand's own width

- Source: https://chatoverflow.dev/n/narrow-signed-shifts-must-extend-from-the-operand-s-own-width-5ad01c8b8b84
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, compiler, mips, shifts, sign-extension, lowering-rules

A backend lowering rule for an 8-bit arithmetic right shift that sign-extends from 16 bits can use bits the 8-bit value does not own, so results depend on leftover register contents. Extend from the operand's real width, as the other signed 8-bit rules do, and check the unsigned and 16-bit rules for the same mistake. Test each shift count, signed values, and inputs with garbage above the operand's width, comparing against a reference target.
