From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10813 invoked by alias); 17 Oct 2014 08:21:35 -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 10799 invoked by uid 89); 17 Oct 2014 08:21:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 17 Oct 2014 08:21:33 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EB378AC8E; Fri, 17 Oct 2014 08:21:29 +0000 (UTC) Date: Fri, 17 Oct 2014 08:24:00 -0000 From: Richard Biener To: ramrad01@arm.com cc: Kyrill Tkachov , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH][0/n] Merge from match-and-simplify In-Reply-To: Message-ID: References: <543EA0CE.5040705@arm.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2014-10/txt/msg01669.txt.bz2 On Fri, 17 Oct 2014, Ramana Radhakrishnan wrote: > On Wed, Oct 15, 2014 at 5:29 PM, Kyrill Tkachov wrote: > > > > On 15/10/14 14:00, Richard Biener wrote: > >> > >> > >> Any comments and reviews welcome (I don't think that > >> my maintainership covers enough to simply check this in > >> without approval). > >> > > Hi Richard, > > > > The match-and-simplify branch bootstrapped successfully on > > aarch64-none-linux-gnu FWIW. > > > > What about regression tests ? Note the branch isn't regression free on x86_64 either. The branch does more than I want to merge to trunk (and it also retains all folding code I added patterns for). I've gone farther there to explore whether it will end up working in the end and what kind of features the IL and the APIs need. I've pasted testsuite results on x86_64 below for rev. 216324 which is based on trunk rev. 216315 which unfortunately has lots of regressions on its own. This is why I want to restrict the effect of the machinery to fold (), fold_stmt () and tree-ssa-forwprop.c for the moment and merge individual patterns (well, maybe in small groups) separately to allow for easy bi-section. I suppose I should push the most visible change to trunk first, namely tree-ssa-forwprop.c folding all statements via fold_stmt after the merge. I suspect this alone can have some odd effects like the sub + cmp fusing. That would be sth like the patch attached below. Richard. Index: gcc/tree-ssa-forwprop.c =================================================================== --- gcc/tree-ssa-forwprop.c (revision 216258) +++ gcc/tree-ssa-forwprop.c (working copy) @@ -54,6 +54,8 @@ along with GCC; see the file COPYING3. #include "tree-ssa-propagate.h" #include "tree-ssa-dom.h" #include "builtins.h" +#include "tree-cfgcleanup.h" +#include "tree-into-ssa.h" /* This pass propagates the RHS of assignment statements into use sites of the LHS of the assignment. It's basically a specialized @@ -3586,6 +3588,8 @@ simplify_mult (gimple_stmt_iterator *gsi return false; } + + /* Main entry point for the forward propagation and statement combine optimizer. */ @@ -3626,6 +3630,40 @@ pass_forwprop::execute (function *fun) cfg_changed = false; + /* Combine stmts with the stmts defining their operands. Do that + in an order that guarantees visiting SSA defs before SSA uses. */ + int *postorder = XNEWVEC (int, n_basic_blocks_for_fn (fun)); + int postorder_num = inverted_post_order_compute (postorder); + for (int i = 0; i < postorder_num; ++i) + { + bb = BASIC_BLOCK_FOR_FN (fun, postorder[i]); + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); + !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + gimple orig_stmt = stmt; + + if (fold_stmt (&gsi)) + { + stmt = gsi_stmt (gsi); + if (maybe_clean_or_replace_eh_stmt (orig_stmt, stmt) + && gimple_purge_dead_eh_edges (bb)) + cfg_changed = true; + update_stmt (stmt); + } + } + } + free (postorder); + + /* ??? Code below doesn't expect non-renamed VOPs and the above + doesn't keep virtual operand form up-to-date. */ + if (cfg_changed) + { + cleanup_tree_cfg (); + cfg_changed = false; + } + update_ssa (TODO_update_ssa_only_virtuals); + FOR_EACH_BB_FN (bb, fun) { gimple_stmt_iterator gsi;