From patchwork Tue Dec 5 08:27:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1871875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=eNZNkeBz; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=M8pmIYD2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SktzY0Mn3z1ySd for ; Tue, 5 Dec 2023 19:31:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00754385782B for ; Tue, 5 Dec 2023 08:31:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 0BC313858403 for ; Tue, 5 Dec 2023 08:31:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BC313858403 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0BC313858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701765065; cv=none; b=rE8Ntfi7ZUr5eHcH/IVAExPJulL5w9nZMAdOboN/2t0SgG7ZRL9Z7aqyhIb6WfgDXsKRa8tD/7O2i4eCspTXIzPHZWLRMOwk/FE3F+Z7kDSjAEik8Impweip4m4atMIqCQ7Vr09U6UuzM+r0GmgvkamRKxhTtvxbr+Keh+9x1sI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701765065; c=relaxed/simple; bh=3lKcEjQy3cRpfSSNPeuiWJ3ZVH/1veyTNVUbxdUVqeI=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version; b=grnisFNKYp1J8sPXX7hFWAJIaDdaHEtpb8JVY38af+KJ25gC0K1LlOD5EgPRw8PJt1cj71CSameEXUEOB+3Y1hhxgZ2li1TpnSZWLtQtYlSDh2nloZjo7Xp++SuVMw9wcHTjErvLKhwphEmEY0nYt063JTee9EigxNgQXwJVtU8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 3039A21DC6; Tue, 5 Dec 2023 08:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701765062; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=iGgHXYTDmEne+du53pLiM0+QYoMzwsUVGHITvPY9Pq8=; b=eNZNkeBz4y+Eboab4xnalut453fC//9x0b5Wm3eh5URyk7pdFEfJQK+YcT212hy8j/V+FM nmyZ56vIuVXL6vAU56ksiKlG36U9xmIvikFNmGouFpdXYffoeWGAPmxV72YDwfO0DhePxg Y4EMjNe4JFOQyq2NCvXUFXSoQku85Ks= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701765062; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=iGgHXYTDmEne+du53pLiM0+QYoMzwsUVGHITvPY9Pq8=; b=M8pmIYD2QvVXT5x8wj3tMKycq+/rQdHCXu9HlnlKASsLT7GEcQXGe3ccuZOsFGFbHhkjfl CWLNBkXku74Nw9Dw== Date: Tue, 5 Dec 2023 09:27:18 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: amacleod@redhat.com Subject: [PATCH] tree-optimization/112843 - update_stmt doing wrong things MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 2.75 X-Spamd-Result: default: False [2.75 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.15)[-0.761]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(3.50)[1.000]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20231205083119.00754385782B@sourceware.org> The following removes range_query::update_stmt and its single invocation from update_stmt_operands. That function is not supposed to look beyond the raw stmt contents of the passed stmt since there's no guarantee about the rest of the IL. I've successfully bootstrapped & tested the update_stmt_operands hunk, now testing removal of the actual routine as well. The testcase that was added when introducing range_query::update_stmt still passes. OK to remove the implementation? I don't see any way around removing the call though. Thanks, Richard. PR tree-optimization/112843 * tree-ssa-operands.cc (update_stmt_operands): Do not call update_stmt from ranger. * value-query.h (range_query::update_stmt): Remove. * gimple-range.h (gimple_ranger::update_stmt): Likewise. * gimple-range.cc (gimple_ranger::update_stmt): Likewise. --- gcc/gimple-range.cc | 34 ---------------------------------- gcc/gimple-range.h | 1 - gcc/tree-ssa-operands.cc | 3 --- gcc/value-query.h | 3 --- 4 files changed, 41 deletions(-) diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 5e9bb397a20..84d2c7516e6 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -544,40 +544,6 @@ gimple_ranger::register_transitive_inferred_ranges (basic_block bb) } } -// When a statement S has changed since the result was cached, re-evaluate -// and update the global cache. - -void -gimple_ranger::update_stmt (gimple *s) -{ - tree lhs = gimple_get_lhs (s); - if (!lhs || !gimple_range_ssa_p (lhs)) - return; - Value_Range r (TREE_TYPE (lhs)); - // Only update if it already had a value. - if (m_cache.get_global_range (r, lhs)) - { - // Re-calculate a new value using just cache values. - Value_Range tmp (TREE_TYPE (lhs)); - fold_using_range f; - fur_stmt src (s, &m_cache); - f.fold_stmt (tmp, s, src, lhs); - - // Combine the new value with the old value to check for a change. - if (r.intersect (tmp)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - print_generic_expr (dump_file, lhs, TDF_SLIM); - fprintf (dump_file, " : global value re-evaluated to "); - r.dump (dump_file); - fputc ('\n', dump_file); - } - m_cache.set_global_range (lhs, r); - } - } -} - // This routine will export whatever global ranges are known to GCC // SSA_RANGE_NAME_INFO and SSA_NAME_PTR_INFO fields. diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h index 5807a2b80e5..6b0835c4ca1 100644 --- a/gcc/gimple-range.h +++ b/gcc/gimple-range.h @@ -52,7 +52,6 @@ public: virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override; virtual bool range_of_expr (vrange &r, tree name, gimple * = NULL) override; virtual bool range_on_edge (vrange &r, edge e, tree name) override; - virtual void update_stmt (gimple *) override; void range_on_entry (vrange &r, basic_block bb, tree name); void range_on_exit (vrange &r, basic_block bb, tree name); void export_global_ranges (); diff --git a/gcc/tree-ssa-operands.cc b/gcc/tree-ssa-operands.cc index 57e393ae164..b0516a00d64 100644 --- a/gcc/tree-ssa-operands.cc +++ b/gcc/tree-ssa-operands.cc @@ -30,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "stmt.h" #include "print-tree.h" #include "dumpfile.h" -#include "value-query.h" /* This file contains the code required to manage the operands cache of the @@ -1146,8 +1145,6 @@ update_stmt_operands (struct function *fn, gimple *stmt) gcc_assert (gimple_modified_p (stmt)); operands_scanner (fn, stmt).build_ssa_operands (); gimple_set_modified (stmt, false); - // Inform the active range query an update has happened. - get_range_query (fn)->update_stmt (stmt); timevar_pop (TV_TREE_OPS); } diff --git a/gcc/value-query.h b/gcc/value-query.h index 429446b32eb..0a6f18b03f6 100644 --- a/gcc/value-query.h +++ b/gcc/value-query.h @@ -71,9 +71,6 @@ public: virtual bool range_on_edge (vrange &r, edge, tree expr); virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL); - // When the IL in a stmt is changed, call this for better results. - virtual void update_stmt (gimple *) { } - // Query if there is any relation between SSA1 and SSA2. relation_kind query_relation (gimple *s, tree ssa1, tree ssa2, bool get_range = true);