From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24079 invoked by alias); 23 Sep 2009 23:16:35 -0000 Received: (qmail 24069 invoked by uid 22791); 23 Sep 2009 23:16:35 -0000 X-SWARE-Spam-Status: No, hits=1.1 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_38,SARE_MSGID_LONG40,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Sep 2009 23:16:30 +0000 Received: from wpaz13.hot.corp.google.com (wpaz13.hot.corp.google.com [172.24.198.77]) by smtp-out.google.com with ESMTP id n8NNGRuV007962 for ; Thu, 24 Sep 2009 00:16:28 +0100 Received: from pzk30 (pzk30.prod.google.com [10.243.19.158]) by wpaz13.hot.corp.google.com with ESMTP id n8NNGOR2028875 for ; Wed, 23 Sep 2009 16:16:25 -0700 Received: by pzk30 with SMTP id 30so871067pzk.24 for ; Wed, 23 Sep 2009 16:16:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.59.20 with SMTP id h20mr224039wfa.279.1253747784571; Wed, 23 Sep 2009 16:16:24 -0700 (PDT) In-Reply-To: <67ea2eb0909231610v5822cb20m1582821b5d399c81@mail.gmail.com> References: <863b0cbf0908081459u33e84018h2e2b6cf871d9be5c@mail.gmail.com> <84fc9c000908091415w7446de3di21b792d12b2fd783@mail.gmail.com> <863b0cbf0909231522v60c2910fta6dc1ee0c7d936ae@mail.gmail.com> <67ea2eb0909231610v5822cb20m1582821b5d399c81@mail.gmail.com> Date: Wed, 23 Sep 2009 23:16:00 -0000 Message-ID: <863b0cbf0909231616r7c52be9etc7baa04990778df4@mail.gmail.com> Subject: Re: Request for code review - (ZEE patch : Redundant Zero extension elimination) From: Sriraman Tallam To: Ramana Radhakrishnan Cc: Richard Guenther , gcc@gcc.gnu.org, Ian Lance Taylor , Diego Novillo Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg00487.txt.bz2 Sorry, it is the other way around. Total number of zero-extension instructions before : 5814 Total number of zero-extension instructions after : 1456 Thanks for pointing it. On Wed, Sep 23, 2009 at 4:10 PM, Ramana Radhakrishnan wrote: >> >> GCC bootstrap : >> >> Total number of zero-extension instructions before =A0: 1456 >> Total number of zero-extension instructions after =A0 =A0: =A05814 >> No impact on boot-strap time. > > > You sure you have these numbers the right way around ? Shouldn't the > number of zero-extension instructions after the patch be less than the > number of zero-extension instructions before or is this a regression > ? > > Thanks, > Ramana > >> >> >> I have attached the latest patch : >> >> >> On Sun, Aug 9, 2009 at 2:15 PM, Richard Guenther >> wrote: >>> On Sat, Aug 8, 2009 at 11:59 PM, Sriraman Tallam w= rote: >>>> Hi, >>>> >>>> =A0 =A0Here is a patch to eliminate redundant zero-extension instructi= ons >>>> on x86_64. >>>> >>>> Tested: Ran the gcc regresssion testsuite on x86_64-linux and verified >>>> that the results are the same with/without this patch. >>> >>> The patch misses testcases. =A0Why does zee run after register allocati= on? >>> Your examples suggest that it will free hard registers so doing it befo= re >>> regalloc looks odd. >>> >>> What is the compile-time impact of your patch on say, gcc bootstrap? >>> How many percent of instructions are removed as useless zero-extensions >>> during gcc bootstrap? =A0How much do CSiBE numbers improve? >>> >>> Thanks, >>> Richard. >>> >>>> >>>> Problem Description : >>>> --------------------------------- >>>> >>>> This pass is intended to be applicable only to targets that implicitly >>>> zero-extend 64-bit registers after writing to their lower 32-bit half. >>>> For instance, x86_64 zero-extends the upper bits of a register >>>> implicitly whenever an instruction writes to its lower 32-bit half. >>>> For example, the instruction *add edi,eax* also zero-extends the upper >>>> 32-bits of rax after doing the addition. =A0These zero extensions come >>>> for free and GCC does not always exploit this well. =A0That is, it has >>>> been observed that there are plenty of cases where GCC explicitly >>>> zero-extends registers for x86_64 that are actually useless because >>>> these registers were already implicitly zero-extended in a prior >>>> instruction. =A0This pass tries to eliminate such useless zero extensi= on >>>> instructions. >>>> >>>> Motivating Example I : >>>> ---------------------------------- >>>> For this program : >>>> ********************************************** >>>> bad_code.c >>>> >>>> int mask[1000]; >>>> >>>> int foo(unsigned x) >>>> { >>>> =A0if (x < 10) >>>> =A0 =A0x =3D x * 45; >>>> =A0else >>>> =A0 =A0x =3D x * 78; >>>> =A0return mask[x]; >>>> } >>>> ********************************************** >>>> >>>> $ gcc -O2 bad_code.c >>>> =A0........ >>>> =A0400315: =A0 =A0 =A0 b8 4e 00 00 00 =A0 =A0 =A0 =A0 =A0 =A0mov =A0 = =A0$0x4e,%eax >>>> =A040031a: =A0 =A0 =A0 0f af f8 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0imul =A0 %eax,%edi >>>> =A040031d: =A0 =A0 =A0 89 ff =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 mov =A0 =A0%edi,%edi >>>> ---> Useless zero extend. >>>> =A040031f: =A0 =A0 =A0 8b 04 bd 60 19 40 00 =A0 =A0mov =A0 =A00x401960= (,%rdi,4),%eax >>>> =A0400326: =A0 =A0 =A0 c3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 retq >>>> =A0...... >>>> =A0400330: =A0 =A0 =A0 ba 2d 00 00 00 =A0 =A0 =A0 =A0 =A0mov =A0 =A0$0= x2d,%edx >>>> =A0400335: =A0 =A0 =A0 0f af fa =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0imul =A0 %edx,%edi >>>> =A0400338: =A0 =A0 =A0 89 ff =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 mov =A0 =A0%edi,%edi =A0---> >>>> Useless zero extend. >>>> =A040033a: =A0 =A0 =A0 8b 04 bd 60 19 40 00 =A0 =A0mov =A0 =A00x401960= (,%rdi,4),%eax >>>> =A0400341: =A0 =A0 =A0 c3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r= etq >>>> >>>> $ gcc -O2 -fzee bad_code.c >>>> =A0...... >>>> =A0400315: =A0 =A0 =A0 6b ff 4e =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imul = =A0 $0x4e,%edi,%edi >>>> =A0400318: =A0 =A0 =A0 8b 04 bd 40 19 40 00 =A0 =A0mov =A0 =A00x401940= (,%rdi,4),%eax >>>> =A040031f: =A0 =A0 =A0 c3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r= etq >>>> =A0400320: =A0 =A0 =A0 6b ff 2d =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0imul = =A0 $0x2d,%edi,%edi >>>> =A0400323: =A0 =A0 =A0 8b 04 bd 40 19 40 00 =A0 =A0mov =A0 =A00x401940= (,%rdi,4),%eax >>>> =A040032a: =A0 =A0 =A0 c3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r= etq >>>> >>>> >>>> >>>> Thanks, >>>> >>>> Sriraman M Tallam. >>>> Google, Inc. >>>> tmsriram@google.com >>>> >>> >> >