From patchwork Fri Jun 3 05:24:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 629608 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 3rLXbr3G0Tz9t4Z for ; Fri, 3 Jun 2016 15:25:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ufCoZuqh; 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=tmLvhk4VNJi0GVPQWwIJwFVCHbOv9v5gdCIOcQBZJPg9H6WokM 87nSn8kv62FMTlEePqnvV2hh/6a6m0InyxnpQr+qKvM4+gmiIqu3uzxPhTp1ZRKu 114OHSYbk13ssdOLQjbiKKL6XnEuNhVWB+q84lHEZFObwF5eeojLF2r00= 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=6396VPKuu9K30AX1kK72QX5HO+o=; b=ufCoZuqh4MnF7yxtZ36c BOCcxw9o35W6cik/fYxCpkjzuhJCsMKVd75d1jn6yBHfF3JQsBL0Iaq7J6VERuvB 9wRZk9xhml7joKz5K2V8+Rpq7bngw2JV5hXVXtiL+4fuIzGFmdlXh0KSFfzkT/Dq m6uJI0NYIFlVebAcjDOx0i8= Received: (qmail 74790 invoked by alias); 3 Jun 2016 05:25:03 -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 74378 invoked by uid 89); 3 Jun 2016 05:25:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Fri, 03 Jun 2016 05:24:51 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB6C03B71B for ; Fri, 3 Jun 2016 05:24:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u535OnWU021774 for ; Fri, 3 Jun 2016 01:24:49 -0400 To: gcc-patches From: Jeff Law Subject: [PR tree-optimization/71328] Fix off-by-one error in CFG/SSA updates for backward threading Message-ID: Date: Thu, 2 Jun 2016 23:24:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 X-IsSubscribed: yes This bug has actually been around since the introduction of the FSM/backwards threader a few years ago. It was just latent. Essentially we need to look at the copied path for branches back into the path -- due to an off-by-one error, we missed the case where the last block in the path branches back to itself. This results in the verification failure reported in pr71328. I'd already had this in my tree as I'd run into it dealing with one of the other regressions from my recent changes. Given it's a totally independent issue it seemed wise to extract and fix this one independently. Bootstrapped on x86_64 linux and installed on the trunk. Jeff commit 96a568909e429b0f24d61c8a2f3dd3c183d720d7 Author: law Date: Fri Jun 3 05:20:16 2016 +0000 PR tree-optimization/71328 * tree-ssa-threadupdate.c (duplicate_thread_path): Fix off-by-one error when checking for a jump back onto the copied path. */ PR tree-optimization/71328 * gcc.c-torture/compile/pr71328.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237052 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a0951b..2c6f6b1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-02 Jeff Law + + PR tree-optimization/71328 + * tree-ssa-threadupdate.c (duplicate_thread_path): Fix off-by-one + error when checking for a jump back onto the copied path. */ + 2016-06-02 David Malcolm * config/microblaze/microblaze.c (get_branch_target): Add return diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f7da16..263d91b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-02 Jeff Law + + PR tree-optimization/71328 + * gcc.c-torture/compile/pr71328.c: New test. + 2016-06-02 Jerry DeLisle PR fortran/52393 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr71328.c b/gcc/testsuite/gcc.c-torture/compile/pr71328.c new file mode 100644 index 0000000..aa384e8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr71328.c @@ -0,0 +1,16 @@ + + +int a, b, c; +void fn1() { + unsigned char d = 3; + if (d > 11) + lbl_596: + c = 0; + while (!d) + b = b; + unsigned char e = e || d; + d = e; + if (a) + d = d || a; + goto lbl_596; +} diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 620948c..1ff007a 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -2298,11 +2298,11 @@ duplicate_thread_path (edge entry, edge exit, } /* Special case the last block on the path: make sure that it does not - jump back on the copied path. */ + jump back on the copied path, including back to itself. */ if (i + 1 == n_region) { FOR_EACH_EDGE (e, ei, bb->succs) - if (bb_in_bbs (e->dest, region_copy, n_region - 1)) + if (bb_in_bbs (e->dest, region_copy, n_region)) { basic_block orig = get_bb_original (e->dest); if (orig)