From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15640 invoked by alias); 11 Oct 2014 08:23:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 15627 invoked by uid 89); 11 Oct 2014 08:23:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 11 Oct 2014 08:23:11 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 1FDF2543E51; Sat, 11 Oct 2014 10:23:08 +0200 (CEST) Date: Sat, 11 Oct 2014 08:26:00 -0000 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH 3/5] IPA ICF pass Message-ID: <20141011082307.GE5172@kam.mff.cuni.cz> References: <20140620073156.GC12633@tsaunders-iceball.corp.tor1.mozilla.com> <20140705225351.GK16837@kam.mff.cuni.cz> <53C7E626.8080400@suse.cz> <54255A09.1090305@suse.cz> <20140926204654.GD26922@atrey.karlin.mff.cuni.cz> <54387443.1010105@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54387443.1010105@suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-10/txt/msg01046.txt.bz2 > > +/* Verifies for given GIMPLEs S1 and S2 that > > + goto statements are semantically equivalent. */ > > + > > +bool > > +func_checker::compare_gimple_goto (gimple g1, gimple g2) > > +{ > > + tree dest1, dest2; > > + > > + dest1 = gimple_goto_dest (g1); > > + dest2 = gimple_goto_dest (g2); > > + > > + if (TREE_CODE (dest1) != TREE_CODE (dest2) || TREE_CODE (dest1) != SSA_NAME) > > + return false; > > + > > + return compare_operand (dest1, dest2); > > > > You probably need to care only about indirect gotos, the direct ones are checked by > > CFG compare. So is the condtional jump. > > It looks that this code is visited quite rare. Hmm, perhaps it is called only for indirect calls, because all others are not represented as statements. > > > + > > +/* Verifies for given GIMPLEs S1 and S2 that ASM statements are equivalent. > > + For the beginning, the pass only supports equality for > > + '__asm__ __volatile__ ("", "", "", "memory")'. */ > > + > > +bool > > +func_checker::compare_gimple_asm (gimple g1, gimple g2) > > +{ > > + if (gimple_asm_volatile_p (g1) != gimple_asm_volatile_p (g2)) > > + return false; > > + > > + if (gimple_asm_ninputs (g1) || gimple_asm_ninputs (g2)) > > + return false; > > + > > + if (gimple_asm_noutputs (g1) || gimple_asm_noutputs (g2)) > > + return false; > > + > > + if (gimple_asm_nlabels (g1) || gimple_asm_nlabels (g2)) > > + return false; > > + > > + if (gimple_asm_nclobbers (g1) != gimple_asm_nclobbers (g2)) > > + return false; > > + > > + for (unsigned i = 0; i < gimple_asm_nclobbers (g1); i++) > > + { > > + tree clobber1 = TREE_VALUE (gimple_asm_clobber_op (g1, i)); > > + tree clobber2 = TREE_VALUE (gimple_asm_clobber_op (g2, i)); > > + > > + if (!operand_equal_p (clobber1, clobber2, OEP_ONLY_CONST)) > > + return false; > > + } > > + > > > > Even asm statements with no inputs or outputs can differ by the actual > > asm statement. Compare it too. > > > > Comparing inputs/outputs/labels should be very easy to do. > > > > Compare all gimple_asm_n* for equivalency. > > This makes fully sense, but I don't understand what kind of operands do you mean? You can look some other code dealing with gimple asm statements. You can just compare gimple_op for 0.... gimple_num_ops and be ready to deal with TREE_LIST as described bellow. Honza > > > At the end walk operands and watch the case they are TREE_LIST. > > THen compare TREE_VALUE (op) of the list for operand_equal_p > > and TREE_VALUE (TREE_PURPOSE (op)) for equivalency > > (those are the constraints) > > > > If they are not (clobbers are not, those are just strings), operand_equal_p > > should do. > > > > + return true; > > +} > > + > > +} // ipa_icf namespace > > > > Otherwise I think ipa-gimple-icf is quite fine now. > > Please send updated version and I think it can go to mainline before the actual ipa-icf. > > I renamed both files and put them to a newly created namespace ipa_icf_gimple. > > Thank you, > Martin