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

Attachment: 0001-Optimize-self-right-shift-to-0.patch
Description: 0001-Optimize-self-right-shift-to-0.patch

Reply via email to