This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/84431] Suboptimal code for masked shifts (x86/x86-64)


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]