On Fri, Jan 30, 2026 at 12:04 AM Maciej W. Rozycki <[email protected]> wrote:
>
> On Wed, 28 Jan 2026, Uros Bizjak wrote:
>
> > x86 targets mask 32-bit shifts with a 5-bit mask (and 64-bit with 6-bit 
> > mask),
> > so they can use x >> ~y instead of x >> 31-y.
>
>  Not the original 8086 though (which "x86" might imply to include), which
> didn't have a barrel shifter and just microcoded the operation.  For the
> record only, as we have no support for anything below the 80386 anyway,
> not even with (obviously) `-m16'.

Please note that the patch converts only SImode and DImode (on x86_64 targets).

FYI: 5-bit mask applies also to 16-bit and 8-bit values, so x >> 31 -
y would also apply to HImode and QImode values. But in my testing, it
never triggered, so I left this conversion out.

BTW: during defconfig linux build, x >> ~y conversion triggers 11
times, while x >> -y conversion triggers ~80 times.

Uros.

Reply via email to