From patchwork Mon Mar 10 09:29:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Cheng X-Patchwork-Id: 328523 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 737B12C00A2 for ; Mon, 10 Mar 2014 20:30:22 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=d+1FkrhDrt849BT+AOYu5aPwrZuMJrASOSzWRmtyCKwkD2Xkv6RsJ p9FkdwdyrRfNCrArL8tPjn6iuCUoH7Hz2FUq7PXV/B1JJX1u2jMtth/kax2hIaPA L99iIdpchZCuKYNMEYteurC7hlCpIkBPJXmMKA1aVvJdQAl5HSeZNA= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=8ukxhq/DAX96s/dDrAiuecF4V1g=; b=hOoalIeSQxuRz9ksbzGj AQ0G+CdgYPJ7WSVukuyjo9FO5NVJ62hyffngrGedzM5R1eQuIygI15/rczJmzTiH 5XQHYbilliGmo5BpZZRzOiAHwpp5TAdRomvamSFBtsTne8ghmBXGus89aeufjayk 6FWGXBjEDz43FCKZ7YO5rCY= Received: (qmail 8235 invoked by alias); 10 Mar 2014 09:30:14 -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 8224 invoked by uid 89); 10 Mar 2014 09:30:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Mar 2014 09:30:12 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 10 Mar 2014 09:30:08 +0000 Received: from SHAWIN162 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 10 Mar 2014 09:30:14 +0000 From: "bin.cheng" To: Subject: [PATCH GCC]Fix a latent bug in cfgcleanup by updating loop's latch info if necessary Date: Mon, 10 Mar 2014 17:29:58 +0800 Message-ID: <005101cf3c43$4f50e250$edf2a6f0$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114031009300803801 X-IsSubscribed: yes Hi, When I investigating PR60363 which is caused by previous patch for PR60280, I found there is a latent bug in remove_forwarder_block_with_phi because GCC doesn't update loop's latch information. Without this patch, cfgcleanup facility will remove and rebuild the loop structure, resulting in loss of loop meta information. This patch is just an obvious pickup, but it isn't intended to fix pr60363. Test on cortex-m3 Bootstrap and test on x86_64 Is it OK? 2014-03-10 Bin Cheng * tree-cfgcleanup.c (remove_forwarder_block_with_phi): Record bb's single pred and update the father loop's latch info later. Index: gcc/tree-cfgcleanup.c =================================================================== --- gcc/tree-cfgcleanup.c (revision 208447) +++ gcc/tree-cfgcleanup.c (working copy) @@ -820,6 +820,12 @@ remove_forwarder_block_with_phi (basic_block bb) && DECL_NONLOCAL (gimple_label_label (label))) return false; + /* Record bb's single pred in case we need to update the father + loop's latch information later. */ + basic_block pred = NULL; + if (single_pred_p (bb)) + pred = single_pred (bb); + /* Redirect each incoming edge to BB to DEST. */ while (EDGE_COUNT (bb->preds) > 0) { @@ -904,6 +910,11 @@ remove_forwarder_block_with_phi (basic_block bb) set_immediate_dominator (CDI_DOMINATORS, dest, dom); + /* Adjust latch infomation of BB's parent loop as otherwise + the cfg hook has a hard time not to kill the loop. */ + if (current_loops && bb->loop_father->latch == bb) + bb->loop_father->latch = pred; + /* Remove BB since all of BB's incoming edges have been redirected to DEST. */ delete_basic_block (bb);