https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36503
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
--- Comment #10 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #7)
> Created attachment 21972 [details]
> Patch that implements suggested optimization
>
> Attached patch compiles the test from comment #0 to the proposed code:
>
> int test (int a, int b)
> {
> return a >> (32 - b);
> }
>
> -O2 -m32:
>
> movl 8(%esp), %ecx
> movl 4(%esp), %eax
> negl %ecx
> sarl %cl, %eax
> ret
>
> -O2 -m64:
>
> negl %esi
> movl %edi, %eax
> movl %esi, %ecx
> sarl %cl, %eax
> ret
Please send the patch to the gcc-patches mailing list if it still applies and
works. And change the status to ASSIGNED if you're still working on it.