From patchwork Fri Aug 5 10:39:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 656156 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 3s5Nbv3Zszz9srY for ; Fri, 5 Aug 2016 20:39:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CCrjEI+X; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=Y8Brrq0+zyV9aJiUryTAJ/ygLZWto/YKbeDrxNY7FkV4qEnthx8QU i2ZnQ0wZ5s0gF/D8RbkRlj6slmpugDNmqZQ9T3V5zkkKBXMh43dJCQx65KsqZTYo 0+1b8eucj6oUsC7vjJIN3+IADB1CmkQAMWXfoRwqVxZ1Lp3xQw0bxM= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=y1GK6d18OgVBVtoZ0vymt1H0MhU=; b=CCrjEI+XVsAVSTCgw4iY KVdhXs+jH0Sr9MQPRwmGCzhFmygRYnizXWjCJNIBcuhfeltlCPmQmicwTBR4tcow jkRwtchcvEdE+5jFroFxBtUo9zsN05nNhRqoVW753xT/fQLHe+w+hFSwzkKmzxT3 na96IZ/FSHhDZdCUrle7p+o= Received: (qmail 49696 invoked by alias); 5 Aug 2016 10:39:46 -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 49683 invoked by uid 89); 5 Aug 2016 10:39:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=enters, anonymous X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 05 Aug 2016 10:39:35 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F21DBAB1E for ; Fri, 5 Aug 2016 10:39:32 +0000 (UTC) Date: Fri, 5 Aug 2016 12:39:32 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve backwards threading Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This avoids regressing gcc.dg/tree-ssa/pr21417.c with the fix for PR72772 where after it a forwarder block no longer is present. It's easy to simply create it when FSM threading faces the situation that the edge ending the path enters a loop. I also fixed the costs for obviously related anon SSA names (when they are the same). Bootstrap and regtest running on x86_64-unknown-linux-gnu, I'll apply if that finishes successfully. Richard. 2016-08-05 Richard Biener * tree-ssa-threadbackward.c: Include cfghooks.h. (profitable_jump_thread_path): Treat same SSA names related. (fsm_find_control_statement_thread_paths): When the taken edge enters a loop split it instead of giving up. Index: gcc/tree-ssa-threadbackward.c =================================================================== --- gcc/tree-ssa-threadbackward.c (revision 239164) +++ gcc/tree-ssa-threadbackward.c (working copy) @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. #include "tree-pass.h" #include "gimple-ssa.h" #include "tree-phinodes.h" +#include "cfghooks.h" static int max_threaded_paths; @@ -206,8 +207,9 @@ profitable_jump_thread_path (vecsrc) - >= bb_loop_depth (taken_edge->dest)) - convert_and_register_jump_thread_path (path, taken_edge); + < bb_loop_depth (taken_edge->dest)) + split_edge (taken_edge); + convert_and_register_jump_thread_path (path, taken_edge); path->pop (); } } @@ -586,9 +592,13 @@ fsm_find_control_statement_thread_paths name, arg); if (taken_edge) { + /* If the taken edge is a loop entry avoid mashing two + loops into one with multiple latches by splitting + the edge. */ if (bb_loop_depth (taken_edge->src) - >= bb_loop_depth (taken_edge->dest)) - convert_and_register_jump_thread_path (path, taken_edge); + < bb_loop_depth (taken_edge->dest)) + split_edge (taken_edge); + convert_and_register_jump_thread_path (path, taken_edge); path->pop (); }