From patchwork Thu Aug 14 11:49:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 379908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5383B1400AB for ; Thu, 14 Aug 2014 21:53:12 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=BZtKsDLQU3b1HY3Z0tZeOfAKBHk8tHZLEUWaurNhsWMfdxqIDCh14 6DkPRvwBla9ESvSID9UmhgAbwJBdAii4wH9ThpJjk19rC9JZjzT1jyvnPfyWHU3G NnmdcJz5MwGUIRROkTQLE7x0rCnbDN+yyYuPq+YpEMeCLXzD2ND1pg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=q137y6X4b1OGELU2leZSGJODExQ=; b=RsyMUIrGPkhYfyDIAB+N npIPhJiPYaclYsaPVim/3XWOioGPRXxnP6QQJEPqiUrvjr37UHR3xFKd6qVI4eAB 5xLy/acNbfWvAQ8NGDc8oSdMhRS4fe58uM5DcVzO9OqqYyT/6qir0sJ5Cc6/sSzK 2qL43p6czITAT67BgFeeZhk= Received: (qmail 31198 invoked by alias); 14 Aug 2014 11:53:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31187 invoked by uid 89); 14 Aug 2014 11:53:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 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; Thu, 14 Aug 2014 11:53:04 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F1547ABF3 for ; Thu, 14 Aug 2014 11:53:00 +0000 (UTC) Date: Thu, 14 Aug 2014 13:49:50 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR62081 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 The following fixes missing dominator computation before fixing loops. Rather than doing even more such weird stuff in a pass gate function this puts this into a new pass scheduled before the loop passes gate. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2014-08-14 Richard Biener PR tree-optimization/62081 * tree-ssa-loop.c (pass_fix_loops): New pass. (pass_tree_loop::gate): Do not fixup loops here. * tree-pass.h (make_pass_fix_loops): Declare. * passes.def: Schedule pass_fix_loops before GIMPLE loop passes. Index: gcc/tree-ssa-loop.c =================================================================== --- gcc/tree-ssa-loop.c (revision 213956) +++ gcc/tree-ssa-loop.c (working copy) @@ -43,6 +43,56 @@ along with GCC; see the file COPYING3. #include "tree-vectorizer.h" +/* A pass making sure loops are fixed up. */ + +namespace { + +const pass_data pass_data_fix_loops = +{ + GIMPLE_PASS, /* type */ + "fix_loops", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + TV_TREE_LOOP, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_fix_loops : public gimple_opt_pass +{ +public: + pass_fix_loops (gcc::context *ctxt) + : gimple_opt_pass (pass_data_fix_loops, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *) { return flag_tree_loop_optimize; } + + virtual unsigned int execute (function *fn); +}; // class pass_fix_loops + +unsigned int +pass_fix_loops::execute (function *) +{ + if (loops_state_satisfies_p (LOOPS_NEED_FIXUP)) + { + calculate_dominance_info (CDI_DOMINATORS); + fix_loop_structure (NULL); + } + return 0; +} + +} // anon namespace + +gimple_opt_pass * +make_pass_fix_loops (gcc::context *ctxt) +{ + return new pass_fix_loops (ctxt); +} + + /* Gate for loop pass group. The group is controlled by -ftree-loop-optimize but we also avoid running it when the IL doesn't contain any loop. */ @@ -57,9 +107,6 @@ gate_loop (function *fn) if (!loops_for_fn (fn)) return true; - /* Make sure to drop / re-discover loops when necessary. */ - if (loops_state_satisfies_p (LOOPS_NEED_FIXUP)) - fix_loop_structure (NULL); return number_of_loops (fn) > 1; } Index: gcc/passes.def =================================================================== --- gcc/passes.def (revision 213956) +++ gcc/passes.def (working copy) @@ -200,7 +200,10 @@ along with GCC; see the file COPYING3. NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); /* Pass group that runs when 1) enabled, 2) there are loops - in the function. */ + in the function. Make sure to run pass_fix_loops before + to discover/remove loops before running the gate function + of pass_tree_loop. */ + NEXT_PASS (pass_fix_loops); NEXT_PASS (pass_tree_loop); PUSH_INSERT_PASSES_WITHIN (pass_tree_loop) NEXT_PASS (pass_tree_loop_init); Index: gcc/tree-pass.h =================================================================== --- gcc/tree-pass.h (revision 213956) +++ gcc/tree-pass.h (working copy) @@ -349,6 +349,7 @@ extern gimple_opt_pass *make_pass_sra_ea extern gimple_opt_pass *make_pass_early_ipa_sra (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tail_recursion (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tail_calls (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_fix_loops (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tree_loop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tree_no_loop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tree_loop_init (gcc::context *ctxt);