[PATCH] [tree-optimization] Fix for PR96701

Eugene Rozenfeld Eugene.Rozenfeld@microsoft.com
Fri Oct 30 02:40:47 GMT 2020


This patch adds a pattern for folding 
                x >> x
to
              0
as described in PR96701.

Without this patch the x86_64-pc-linux-gnu code generated for this function

int
foo (int i)
{
  return i >> i;
}

is

mov    ecx,edi
sar    edi,cl
test   edi,edi
setne  al
ret

With the patch the code is 

xor    eax,eax
ret  

Tested on x86_64-pc-linux-gnu.

Eugene
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Optimize-self-right-shift-to-0.patch
Type: application/octet-stream
Size: 1426 bytes
Desc: 0001-Optimize-self-right-shift-to-0.patch
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201030/9d03b7fe/attachment.obj>


More information about the Gcc-patches mailing list