[Bug target/84431] Suboptimal code for masked shifts (x86/x86-64)
nruslan_devel at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Sat Feb 24 20:25:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84431
--- Comment #6 from Ruslan Nikolaev <nruslan_devel at yahoo dot com> ---
(In reply to Uroš Bizjak from comment #5)
> (In reply to Ruslan Nikolaev from comment #4)
> > Thanks! I was wondering if the patch also fixes the same thing for x86-64
> > (i.e., -m64); in which case we would have something like this:
> >
> > __uint128_t func(__uint128_t a, unsigned shift)
> > {
> > return a << (shift & 63);
> > }
>
> Yes, the patch also handles __int128.
Great! Also, another interesting case (with the same idea for -m64 and
__uint128_t) would be this:
gcc -m32 -Wall -O2 -S test.c
unsigned func(unsigned long long a, unsigned shift)
{
return (unsigned) (a >> (shift & 31));
}
In this case, clang generates just a single 'shrd' instruction.
More information about the Gcc-bugs
mailing list