On 10/29/20 8:36 PM, Eugene Rozenfeld via Gcc-patches wrote: > 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 > > 0001-Optimize-self-right-shift-to-0.patch > > From 2e952db4925e34674afabd2fed2330d91289a398 Mon Sep 17 00:00:00 2001 > From: Eugene Rozenfeld <ero...@microsoft.com> > Date: Thu, 29 Oct 2020 19:23:46 -0700 > Subject: [PATCH] Optimize self right-shift to 0. > > Simplify x >> x to 0. This fixes PR96701.
Thanks. Installed on the trunk. jeff