This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/84431] Suboptimal code for masked shifts (x86/x86-64)
- From: "nruslan_devel at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 24 Feb 2018 20:06:37 +0000
- Subject: [Bug target/84431] Suboptimal code for masked shifts (x86/x86-64)
- Auto-submitted: auto-generated
- References: <bug-84431-4@http.gcc.gnu.org/bugzilla/>
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.