From patchwork Mon Oct 26 15:36:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 536076 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 B74101402B6 for ; Tue, 27 Oct 2015 02:36:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xqIdr104; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=KeHZhKemSlZdu4ccwyIw+0Fb0wW0xDo4NvXVDWQVkII5qP9GnQ cHj9VBSby6lLGHPhwyoJEQ4BaJ328zuXOcVGwJIdZZc0G+g6lg3nb/ejtT66B4Y9 Nt56ZbSApqT71Nh6Pu+al/QqoSe5FEtBeYbtxnbtcvpZUJYT06My16wgA= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=3giE3NifeQfTqB6TeuLdF0Uwetk=; b=xqIdr104qzfTMyJFM4Bt gRfYzbxGjmIo2LaWqLJ7gzeOLQoaKCyK/mOBOmI8xILtuuXK6BcuYfsps8+3p150 Ule0sviAr1TkraOH19KGv5xPjqC8cRiu9t9NEgk2h55WtJvFvwzE/wcWT64+OG/K ORsMVew339Msi0o4bh2d+SQ= Received: (qmail 22268 invoked by alias); 26 Oct 2015 15:36:42 -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 22195 invoked by uid 89); 26 Oct 2015 15:36:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 26 Oct 2015 15:36:40 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7A4B4223 for ; Mon, 26 Oct 2015 15:36:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-196.phx2.redhat.com [10.3.113.196]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9QFadoc022213 for ; Mon, 26 Oct 2015 11:36:39 -0400 To: gcc-patches@gcc.gnu.org From: Jeff Law Subject: [PATCH] [PR tree-optimization/68013] Make sure first block in FSM path is in VISITED_BBs Message-ID: <562E4886.4060909@redhat.com> Date: Mon, 26 Oct 2015 09:36:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 X-IsSubscribed: yes The problem here is the first block in an FSM path may not be added to VISITED_BBs. That in turn results in the threader finding a path which passes through that initial block a second time, reaching a different destination the second time through. This is caught by the assertion (to avoid generating incorrect code). Fixing is simple. But... I'm not real happy with how the affected code is structured, but I'm at a loss right now how to reorganize it in the immediate term. I'm hoping to get some clarity as I continue to look to replace the EDGE_DFS_BACK support in the old threader with the FSM threader, fixing 67892 along the way). Anyway, bootstrapped and regression tested on x86_64-linux-gnu. Installed on the trunk. Jeff commit 803e64f4cf1221027844db60db0a480e64653664 Author: law Date: Mon Oct 26 15:36:04 2015 +0000 [PATCH] [PR tree-optimization/68013] Make sure first block in FSM path is in VISITED_BBs PR tree-optimization/68013 * tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths): Make sure the first block in the path is in VISITED_BBs. PR tree-optimization/68013 * gcc.c-torture/compile/pr68013.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229375 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95479f3..b5cfa1e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-10-26 Jeff Law + + PR tree-optimization/68013 + * tree-ssa-threadbackward.c + (fsm_find_control_statement_thread_paths): Make sure the first block + in the path is in VISITED_BBs. + 2015-10-26 Richard Biener Dominik Vogt diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd5ade4..688f745 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-26 Jeff Law + + PR tree-optimization/68013 + * gcc.c-torture/compile/pr68013.c: New test. + 2015-10-26 Richard Biener Dominik Vogt diff --git a/gcc/testsuite/gcc.c-torture/compile/pr68013.c b/gcc/testsuite/gcc.c-torture/compile/pr68013.c new file mode 100644 index 0000000..cc500da --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr68013.c @@ -0,0 +1,16 @@ +int a, b, c, d, e, f; + +void +fn1 () +{ + for (; e;) + { + e = f; + for (; b;) + { + b = a; + f = a || d ? 0 : c; + } + d = 0; + } +} diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 9128094..cfb4ace 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -136,6 +136,11 @@ fsm_find_control_statement_thread_paths (tree name, vec *next_path; vec_alloc (next_path, n_basic_blocks_for_fn (cfun)); + /* When VAR_BB == LAST_BB_IN_PATH, then the first block in the path + will already be in VISITED_BBS. When they are not equal, then we + must ensure that first block is accounted for to ensure we do not + create bogus jump threading paths. */ + visited_bbs->add ((*path)[0]); FOR_EACH_EDGE (e, ei, last_bb_in_path->preds) { hash_set *visited_bbs = new hash_set;