From patchwork Fri Nov 6 23:26:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 541158 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 5B19D14016A for ; Sat, 7 Nov 2015 10:27:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=VoU79vkL; 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=OAzptzTYaytV62rMUhXcLZw5+wlmXjjxgvE/j/drvilw0t9ZWw 9E2OXakugY9W0qV98UpRtGOdL/cehEn6tCvZJpkBmFuZBm+0X1kPQZURzQX0Sp55 wDaAIm3i9CEswud2/a3qPQyRrYp04oLesYPeoLR0IWbE22Ag11Fcau56g= 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=XFdlCtNkgVAaXw/z2j8W+0hTjIo=; b=VoU79vkL8jLArd7YyQtu 0nt8Qwdw1THsfnGEFe/cElUXy0gaeemep4y5IGj0KhfTFg/v+DMgQ8QxAzbLO67g FOtixaoXCdzbcsIj6qBIc6Du0N6SIFwWX7Tu9qiZXHP1Mn7j5qk7TGDjDRrUvDXF V0XkeQLpj3LMpkLPj/5W20Y= Received: (qmail 96965 invoked by alias); 6 Nov 2015 23:26:57 -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 96955 invoked by uid 89); 6 Nov 2015 23:26:56 -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, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Fri, 06 Nov 2015 23:26:55 +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 4C880A3254 for ; Fri, 6 Nov 2015 23:26:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-107.phx2.redhat.com [10.3.113.107]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA6NQr00005648 for ; Fri, 6 Nov 2015 18:26:54 -0500 To: gcc-patches@gcc.gnu.org From: Jeff Law Subject: [PATCH] Allow vrp to thread across backedges using FSM threader Message-ID: <563D373D.5030406@redhat.com> Date: Fri, 6 Nov 2015 16:26:53 -0700 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 This is in preparation for removing a blob of code in the old threader that knew how to thread across backedges. Essentially this just allows us to try FSM threading in VRP's instance of threader. So certain jump threading happens earlier in the pipeline. It also tightens up the ssa-dom-thread-7 test a bit. It was previously just counting the number of jump threads registered. Now it tracks the number of jump threads actually realized. I verified the actually realized jump threads were the same before/after -- several just moved from DOM1 to VRP1. This does not effect 68198, which will be the top of my todo list after a few more small cleanups take place prior to stage1 close. Bootstrapped and regression tested on x86-64-linux-gnu. Installed on the trunk. Jeff commit f6a3449159568d1b352e9b3d49b1df0ba8b25a6f Author: law Date: Fri Nov 6 23:26:20 2015 +0000 [PATCH] Allow vrp to thread across backedges using FSM threader * cfg-flags.def (IGNORE): New edge flag. * tree-vrp.c (identify_jump_threads): Mark and clear edges scheduled for removal with EDGE_IGNORE around call into jump threader. Do no thread across edges with EDGE_IGNORE, but do allow threading across those with EDGE_DFS_BACK. * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust to look for realized jump threads. * gcc.dg/tree-ssa-pr66752-3.c: Look in vrp1 dump for jump threads rather than dom1 dump. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229902 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e2f588b..552c51b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-11-06 Jeff Law + + * cfg-flags.def (IGNORE): New edge flag. + * tree-vrp.c (identify_jump_threads): Mark and clear edges + scheduled for removal with EDGE_IGNORE around call into + jump threader. Do no thread across edges with EDGE_IGNORE, + but do allow threading across those with EDGE_DFS_BACK. + 2015-11-06 David Wohlferd * doc/md.texi (multi-alternative constraints): Don't document diff --git a/gcc/cfg-flags.def b/gcc/cfg-flags.def index eedcd69..e2bfbed 100644 --- a/gcc/cfg-flags.def +++ b/gcc/cfg-flags.def @@ -78,7 +78,7 @@ DEF_BASIC_BLOCK_FLAG(RTL, 9) DEF_BASIC_BLOCK_FLAG(FORWARDER_BLOCK, 10) /* Set on blocks that cannot be threaded through. - Only used in cfgcleanup.c. */ + Only used for jump threading. */ DEF_BASIC_BLOCK_FLAG(NONTHREADABLE_BLOCK, 11) /* Set on blocks that were modified in some way. This bit is set in @@ -177,6 +177,11 @@ DEF_EDGE_FLAG(TM_UNINSTRUMENTED, 15) /* Abort (over) edge out of a GIMPLE_TRANSACTION statement. */ DEF_EDGE_FLAG(TM_ABORT, 16) +/* An edge we should ignore. It should be entirely local to + passes. ie, it is never set on any edge upon the completion + of any pass. */ +DEF_EDGE_FLAG(IGNORE, 17) + #endif /* diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80221c1..af4a738 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-11-06 Jeff Law + + * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust to look for + realized jump threads. + * gcc.dg/tree-ssa-pr66752-3.c: Look in vrp1 dump for jump + threads rather than dom1 dump. + 2015-11-06 Michael Collison diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c index f15b598..577a489 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr66752-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-dom1-details -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details -fdump-tree-optimized" } */ extern int status, pt; extern int count; @@ -33,7 +33,7 @@ foo (int N, int c, int b, int *a) } /* There are 3 FSM jump threading opportunities. */ -/* { dg-final { scan-tree-dump-times "FSM" 3 "dom1"} } */ +/* { dg-final { scan-tree-dump-times "FSM" 3 "vrp1"} } */ /* There should be no assignments or references to FLAG. */ /* { dg-final { scan-tree-dump-not "flag" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c index 445f250..ac12b6c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c @@ -1,6 +1,8 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-dom1-details" } */ -/* { dg-final { scan-tree-dump-times "FSM" 38 "dom1" } } */ +/* { dg-options "-O2 -fdump-tree-vrp1-stats -fdump-tree-dom1-stats -fdump-tree-dom2-stats" } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 7" "vrp1" } } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 12" "dom1" } } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 3" "dom2" } } */ enum STATE { S0=0, diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index c0b6cfc..87c0265 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -10076,9 +10076,9 @@ identify_jump_threads (void) mark_dfs_back_edges (); /* Do not thread across edges we are about to remove. Just marking - them as EDGE_DFS_BACK will do. */ + them as EDGE_IGNORE will do. */ FOR_EACH_VEC_ELT (to_remove_edges, i, e) - e->flags |= EDGE_DFS_BACK; + e->flags |= EDGE_IGNORE; /* Allocate our unwinder stack to unwind any temporary equivalences that might be recorded. */ @@ -10135,9 +10135,9 @@ identify_jump_threads (void) it to a specific successor. */ FOR_EACH_EDGE (e, ei, bb->preds) { - /* Do not thread across back edges or abnormal edges - in the CFG. */ - if (e->flags & (EDGE_DFS_BACK | EDGE_COMPLEX)) + /* Do not thread across edges marked to ignoreor abnormal + edges in the CFG. */ + if (e->flags & (EDGE_IGNORE | EDGE_COMPLEX)) continue; thread_across_edge (dummy, e, true, equiv_stack, NULL, @@ -10146,6 +10146,10 @@ identify_jump_threads (void) } } + /* Clear EDGE_IGNORE. */ + FOR_EACH_VEC_ELT (to_remove_edges, i, e) + e->flags &= ~EDGE_IGNORE; + /* We do not actually update the CFG or SSA graphs at this point as ASSERT_EXPRs are still in the IL and cfg cleanup code does not yet handle ASSERT_EXPRs gracefully. */