From patchwork Thu Nov 11 17:24:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1554060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=nH2tZEl4; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HqpXN73CBz9s5P for ; Fri, 12 Nov 2021 04:25:55 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D37A13857C7F for ; Thu, 11 Nov 2021 17:25:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D37A13857C7F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636651552; bh=mwYlmnf5AM2rvm9QFLVakSQcrwNP24XGPt+au8erIaA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=nH2tZEl488JmKryifmBWbQ+JLKT461/fT6S4hA7pq9j9tTX57rpXBHm85jAYN+4o7 QB17KQyBO5BsDy1oJF23JoDi/ZbpCuV9/ZuU5w//riKk5Z4O5mOJ97S7XXeHe5V91D eFE0cEVuKITiykUjsU9Q8ZklD3DpAUteqN5e+JxI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 98D90385782C for ; Thu, 11 Nov 2021 17:24:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 98D90385782C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-148-sZK97C3NPdyalysBPdYnhA-1; Thu, 11 Nov 2021 12:24:42 -0500 X-MC-Unique: sZK97C3NPdyalysBPdYnhA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63E0A1922041; Thu, 11 Nov 2021 17:24:41 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.226]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 071AA5DA60; Thu, 11 Nov 2021 17:24:40 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 1ABHOcxB893095 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 11 Nov 2021 18:24:38 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1ABHObER893094; Thu, 11 Nov 2021 18:24:37 +0100 To: GCC patches Subject: [PATCH] Remove loop crossing restriction from the backward threader. Date: Thu, 11 Nov 2021 18:24:31 +0100 Message-Id: <20211111172432.893034-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" We have much more thorough restrictions, that are shared between both threader implementations, in the registry. I've been meaning to remove the backward threader one, since it's only purpose was reducing the search space. Previously there was a small time penalty for its removal, but with the various patches in the past month, it looks like the removal is a wash performance wise. This catches 8 more jump threads in the backward threader in my suite. Presumably, because we disallowed all loop crossing, whereas the registry restrictions allow some crossing (if we exit the loop, etc). OK pending tests on x86-64 Linux? gcc/ChangeLog: * tree-ssa-threadbackward.c (back_threader_profitability::profitable_path_p): Remove loop crossing restriction. --- gcc/tree-ssa-threadbackward.c | 36 ++++++----------------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index d067c470c38..61aee25d236 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -615,7 +615,6 @@ back_threader_profitability::profitable_path_p (const vec &m_path, int n_insns = 0; gimple_stmt_iterator gsi; loop_p loop = m_path[0]->loop_father; - bool path_crosses_loops = false; bool threaded_through_latch = false; bool multiway_branch_in_path = false; bool threaded_multiway_branch = false; @@ -634,30 +633,15 @@ back_threader_profitability::profitable_path_p (const vec &m_path, if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " bb:%i", bb->index); - /* Remember, blocks in the path are stored in opposite order - in the PATH array. The last entry in the array represents - the block with an outgoing edge that we will redirect to the - jump threading path. Thus we don't care about that block's - loop father, nor how many statements are in that block because - it will not be copied or whether or not it ends in a multiway - branch. */ + /* Remember, blocks in the path are stored in opposite order in + the PATH array. The last entry in the array represents the + block with an outgoing edge that we will redirect to the jump + threading path. Thus we don't care how many statements are + in that block because it will not be copied or whether or not + it ends in a multiway branch. */ if (j < m_path.length () - 1) { int orig_n_insns = n_insns; - if (bb->loop_father != loop) - { - path_crosses_loops = true; - - // Dump rest of blocks. - if (dump_file && (dump_flags & TDF_DETAILS)) - for (j++; j < m_path.length (); j++) - { - bb = m_path[j]; - fprintf (dump_file, " bb:%i", bb->index); - } - break; - } - /* PHIs in the path will create degenerate PHIS in the copied path which will then get propagated away, so looking at just the duplicate path the PHIs would @@ -776,14 +760,6 @@ back_threader_profitability::profitable_path_p (const vec &m_path, *creates_irreducible_loop = true; } - if (path_crosses_loops) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " FAIL: Jump-thread path not considered: " - "the path crosses loops.\n"); - return false; - } - /* Threading is profitable if the path duplicated is hot but also in a case we separate cold path from hot path and permit optimization of the hot path later. Be on the agressive side here. In some testcases,