From patchwork Sun Oct 30 08:27:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 122588 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]) by ozlabs.org (Postfix) with SMTP id 7811FB6F93 for ; Sun, 30 Oct 2011 19:28:33 +1100 (EST) Received: (qmail 22702 invoked by alias); 30 Oct 2011 08:28:30 -0000 Received: (qmail 22694 invoked by uid 22791); 30 Oct 2011 08:28:29 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,TW_CF X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 30 Oct 2011 08:28:15 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1RKQkY-0000VY-Tm from Tom_deVries@mentor.com ; Sun, 30 Oct 2011 01:28:14 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 30 Oct 2011 01:27:16 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Sun, 30 Oct 2011 08:28:13 +0000 Message-ID: <4EAD0A8C.4050603@mentor.com> Date: Sun, 30 Oct 2011 09:27:56 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15 MIME-Version: 1.0 To: Richard Guenther CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PR50878, PATCH] Fix for verify_dominators in -ftree-tail-merge References: <4EAD08B6.2020607@mentor.com> In-Reply-To: <4EAD08B6.2020607@mentor.com> 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 On 10/30/2011 09:20 AM, Tom de Vries wrote: > Richard, > > I have a fix for PR50878. Sorry, with patch this time. Thanks, - Tom > > A simplified form of the problem from the test-case of the PR is shown in this > cfg. Block 12 has as direct dominator block 5. > > 5 > / \ > / \ > * * > 6 7 > | | > | | > * * > 8 9 > \ / > \ / > * > 12 > > tail_merge_optimize finds that blocks 6 and 7 are duplicates. After replacing > block 7 by block 6, the cfg looks like this: > > 5 > | > | > * > 6 > / \ > / \ > * * > 8 9 > \ / > \ / > * > 12 > > The new direct dominator of block 12 is block 6, but the current algorithm only > recalculates dominator info for blocks 6, 8 and 9. > > The patch fixes this by additionally recalculating the dominator info for blocks > immediately dominated by bb2 (block 6 in the example), if bb2 has a single > predecessor after replacement. > > Bootstapped and reg-tested on x86_64 and i686. Build and reg-tested on MIPS and ARM. > > Ok for trunk? > > Thanks, > - Tom > > 2011-10-30 Tom de Vries > > PR tree-optimization/50878 > * tree-ssa-tail-merge.c (replace_block_by): Recalculate dominator info > for blocks immediately dominated by bb2, if bb2 has a single predecessor > after replacement. Index: gcc/tree-ssa-tail-merge.c =================================================================== --- gcc/tree-ssa-tail-merge.c (revision 180562) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -1604,7 +1604,10 @@ replace_block_by (basic_block bb1, basic same_succ_flush_bb (bb1); delete_basic_block (bb1); - fix_dom_bb = VEC_alloc (basic_block, heap, 2); + if (single_pred_p (bb2)) + fix_dom_bb = get_dominated_by (CDI_DOMINATORS, single_pred (bb2)); + else + fix_dom_bb = VEC_alloc (basic_block, heap, 2); VEC_safe_push (basic_block, heap, fix_dom_bb, bb2); FOR_EACH_EDGE (e, ei, bb2->succs) VEC_safe_push (basic_block, heap, fix_dom_bb, e->dest);