From patchwork Wed Feb 6 18:46:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 218716 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 B82492C02E9 for ; Thu, 7 Feb 2013 05:47:28 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1360781249; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=SwqylewJruXYiYFcZSZP3zJFvCI=; b=e+mf1Nw3t6QNiV1 GSKePKGnNMLXdkG9Rkq9kzCwCFe3K+nEoJhD10soOHSLXblvxYbqIM5NMF3UCzo2 q5P5SrR4nwa8EJmn92aZP5l8IbkL4xkcwmgLQmeE8atYwq8dKjra/jlfD68b4sHL TkJHVlHHb563NqcAfQf1jLKqexd0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=xYWIn9Uvr1ftlChKDGhPoKEA+XMpIpcjf2yvkgcrfcatV9pdf3VpP3ZxP27oBn SVan76MJpIGT0xiZORPBdRsQEImjEU8ROZKawsOtiSj/+2O0/y43gyy9LGjSW3Ew 9yzS9rzKWRmxDOQH8mVXUWO84Vp1GFFUZg3wz1CZmgRzQ=; Received: (qmail 21316 invoked by alias); 6 Feb 2013 18:47:10 -0000 Received: (qmail 21263 invoked by uid 22791); 6 Feb 2013 18:47:08 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Feb 2013 18:46:56 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r16Iku9G027323 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Feb 2013 13:46:56 -0500 Received: from redhat.com (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r16IkqLM017443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 6 Feb 2013 13:46:55 -0500 Date: Wed, 6 Feb 2013 19:46:52 +0100 From: Marek Polacek To: GCC Patches Cc: Richard Guenther Subject: [PATCH] Check headers in verify_loop_structure Message-ID: <20130206184651.GH7360@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This patch extends verify_loop_structure by checking that header's are really its own headers (this proved as useful in PR56181). The bulk of the code is taken from flow_loops_find. Bootstrapped on x86_64 linux. The only fallout now is (for C/C++): FAIL: gcc.dg/torture/pr54458.c -O3 -fomit-frame-pointer (internal compiler error) FAIL: gcc.dg/torture/pr54458.c -O3 -fomit-frame-pointer (test for excess errors) FAIL: gcc.dg/torture/pr54458.c -O3 -fomit-frame-pointer -funroll-loops (internal compiler error) FAIL: gcc.dg/torture/pr54458.c -O3 -fomit-frame-pointer -funroll-loops (test for excess errors) FAIL: gcc.dg/torture/pr54458.c -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions (internal compiler error) FAIL: gcc.dg/torture/pr54458.c -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions (test for excess errors) FAIL: gcc.dg/torture/pr54458.c -O3 -g (internal compiler error) FAIL: gcc.dg/torture/pr54458.c -O3 -g (test for excess errors) which is only because -O3 means -funswitch-loops as well. What happens here is quite interesting situation, we have three analogical loops which look like below. BB7 is marked as IRREDUCIBLE_LOOP. | +---------------+ | | | | | +---+-+-+ | | 6 | | +---+---+ | | ---| | | -----/ | | +-----/-+ | | | 7 | | | +-------+ | | / \ | | / \ | | +------+ +------+ | | | 9 | | 8 | | | +--+---+ +---+--+ | | | | | | | +-------+ | +-------+ | | 10 | | +---+---+ | | +-------+ Thus, we basically have two headers in a loop. So, shall I skip the BB_IRREDUCIBLE_LOOP blocks? (Although this leads to another crash: we get into the same situation in another pass, just the BB isn't marked as BB_IRREDUCIBLE_LOOP, so we don't skip it. Perhaps this could be sorted out by just calling mark_irreducible_loops somewhere.) Comments? 2013-02-06 Marek Polacek * cfgloop.c (verify_loop_structure): Check that header BBs are really its own headers. Marek --- gcc/cfgloop.c.mp 2013-02-06 12:08:01.536918761 +0100 +++ gcc/cfgloop.c 2013-02-06 18:32:59.957027313 +0100 @@ -1316,6 +1316,41 @@ verify_loop_structure (void) else verify_dominators (CDI_DOMINATORS); + /* Check the loop headers. */ + FOR_EACH_BB (bb) + { + edge_iterator ei; + + /* If we have an abnormal predecessor, do not consider the + loop (not worth the problems). */ + if (bb_has_abnormal_pred (bb)) + continue; + + if (bb->loop_father == current_loops->tree_root) + continue; + + FOR_EACH_EDGE (e, ei, bb->preds) + { + basic_block latch = e->src; + + gcc_assert (!(e->flags & EDGE_ABNORMAL)); + + /* Look for back edges where a predecessor is dominated + by this block. A natural loop has a single entry + node (header) that dominates all the nodes in the + loop. It also has single back edge to the header + from a latch node. */ + if (latch != ENTRY_BLOCK_PTR + && bb != latch + && dominated_by_p (CDI_DOMINATORS, latch, bb)) + if (bb->loop_father->header != bb) + { + error ("header %d is not its own header", bb->index); + err = 1; + } + } + } + /* Check sizes. */ sizes = XCNEWVEC (unsigned, num); sizes[0] = 2;