From patchwork Tue Apr 30 21:23:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1929857 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=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KSAHJYSm; 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 4VTYB10lSkz23hd for ; Wed, 1 May 2024 07:24:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3249385828E for ; Tue, 30 Apr 2024 21:24:36 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 33E9B3858D20 for ; Tue, 30 Apr 2024 21:24:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33E9B3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33E9B3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714512248; cv=none; b=WBgLU4OAFm9oE8vlKuMIzXdjbWcHcl2tNoaBZJYRTSZE8OxG1ZRAa2BfugtHtStt1hM86RYAkUCBc8SVazcNIfy9fnh6u6sWbGlw+CriECrzxYbcqlcMPerXBmevJ8LRLIPf95QJvs1IzRMKPmEfNMsNrUUeeCai4m++cM0fWAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714512248; c=relaxed/simple; bh=uNSbJ/agTyOVKEXyeCURzmBpmfweJXoju63c9oxXR2c=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=e8vZk5VibULzwibIOEsynvdItzotBiWMrCAWjI783Wx7aNFho1YleqrZhYRr2r4/4GRvEVRMJ+WrlqFKJI50PiSiR7Op01oLbscZcOA9ZxkgtbwA0hi/d/gdtVciHOmBGMEbd2E3OCnys49n2GULt9FNqV9OH+3nymsaZaMUBWM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714512245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=pZdcIqUsRD2fLp96XKigg4lcSdZ2QkjpPcUDHcl0zrI=; b=KSAHJYSmlwddMc6LVJvnkbBRKlZYiEunuVtfTfGIz3ChsuVi56CMYZI+cEtBtVoMm6/lUj xSbG2T7a3Co9VRCPHAedGMJlLlzLNQZPftI9zQDi2sg2Pz0bNfeASx2LGvPZY8a1NPABx+ k1hwBJQB+T3kZotLIdTgHGEWPM7Mpi4= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-DTJIcWpGPg2loYW_7oMZRg-1; Tue, 30 Apr 2024 17:24:02 -0400 X-MC-Unique: DTJIcWpGPg2loYW_7oMZRg-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-61bbd6578f9so61936817b3.1 for ; Tue, 30 Apr 2024 14:24:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714512241; x=1715117041; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=enuSondabX/MvkIngLGJu8GVC2lNk2cHOwpxrX3kq1s=; b=vB02nThBDXwwMIfmEklInqMC08Q7j+VcA7h7k2htjL+oCgrV7xsNhHo+oFYJeinSu9 e+Dfk5OxxVt1T7Ui1cbHTrp8s1D25U8AO92Ev5HNnSNtARI22XJ6hi2zJX318Pv9O9qM hx78d3VZAHPQTBq2sJn8uydpkloVKQ1AO38kxIDRvNOaeh1Qg7gX6CTw7nYfnWu5Sxtt 1560qcoHg91mm7aqHB2+W9MGA5pMd8Zl1VK2J9S2QaoOB6dwpyYCqHwkhewR13cSOxQH ALHWIrVmt7c/p2luo5K6DzZ6SgzKn9cBKL/TkgEQtJZZY+4CFhd3p8wXIg7YzDhOBpfO QXyw== X-Gm-Message-State: AOJu0YzQSuCff4njYJTOUWcTjDdvZZXEEvIA+qOap4qc8+bcTWeRri/a hG2KrlTHGmEYF++K+sqWuwrvhGtfglfEbOJ85yMVSy/Vc1tvrMQt6GY9sXfj2vzAJIC++MwoCNU MkE5kKv0xUpBQ3GX7rjDoQoA1U67qwgd8Yl9+xeqVwFifyHLAy+S7IFZ21zfI7NSUDzZxa1aeSC SMmYJIjxZ/gPw1dNXlmx6n3m0wcOUMnG3MQ5dSMuU= X-Received: by 2002:a05:690c:6410:b0:615:1527:aa2 with SMTP id hr16-20020a05690c641000b0061515270aa2mr835425ywb.10.1714512241252; Tue, 30 Apr 2024 14:24:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYpXWZk1Y9tT5Zq3GqoXo8sQo8GUmjw58mii8NYdc+1rmEsa/R2U94xAR5vi6qUSA8mG1ySw== X-Received: by 2002:a05:690c:6410:b0:615:1527:aa2 with SMTP id hr16-20020a05690c641000b0061515270aa2mr835409ywb.10.1714512240629; Tue, 30 Apr 2024 14:24:00 -0700 (PDT) Received: from [192.168.0.174] ([104.219.121.64]) by smtp.gmail.com with ESMTPSA id h5-20020ac85485000000b00439cccb91b2sm7868097qtq.73.2024.04.30.14.23.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Apr 2024 14:24:00 -0700 (PDT) Message-ID: Date: Tue, 30 Apr 2024 17:23:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches Cc: "hernandez, aldy" From: Andrew MacLeod Subject: [COMMITTED 1/5] Remove wrapper around gimple_range_global. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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 This came up during stage 4 when someone noticed a comment that said when legacy EVRP was removed, the wrapper around accessing SSA_NAME_RANGES for initial values could be removed. To be clearer, the original discussion is here: https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html We couldn't prime ranger's initial use of an ssa-name before inlining, or we would end up removing builtin_unreachable calls. These conditions are no longer present, and its safe to simple always pick up whatever the best value we can find. It even provides a modest speedup with less condition checking on every access to a global. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  pushed. Andrew From f3571462b581e1b57d563268483207bc929de952 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 20 Feb 2024 12:27:51 -0500 Subject: [PATCH 1/9] Remove wrapper around gimple_range_global. Now that legacy EVRP has been removed, we can remove the wrapper which prevented us from using global names before inlining except under some specific conditions. See discussion: https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html * value-query.cc (get_range_global): Rename to gimple_range_global. (gimple_range_global): Remove wrapper function. (global_range_query::range_of_expr): Call gimple_range_global. --- gcc/value-query.cc | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 052b7511565..e88c8e25789 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -280,11 +280,15 @@ get_ssa_name_ptr_info_nonnull (const_tree name) // Update the global range for NAME into the SSA_RANGE_NAME_INFO and // Return the legacy global range for NAME if it has one, otherwise // return VARYING. +// See discussion here regarding why there use to be a wrapper function: +// https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html +// Legacy EVRP has been removed, leaving just this function. -static void -get_range_global (vrange &r, tree name, struct function *fun = cfun) +void +gimple_range_global (vrange &r, tree name, struct function *fun) { tree type = TREE_TYPE (name); + gcc_checking_assert (TREE_CODE (name) == SSA_NAME); if (SSA_NAME_IS_DEFAULT_DEF (name)) { @@ -332,36 +336,6 @@ get_range_global (vrange &r, tree name, struct function *fun = cfun) r.set_varying (type); } -// This is where the ranger picks up global info to seed initial -// requests. It is a slightly restricted version of -// get_range_global() above. -// -// The reason for the difference is that we can always pick the -// default definition of an SSA with no adverse effects, but for other -// SSAs, if we pick things up to early, we may prematurely eliminate -// builtin_unreachables. -// -// Without this restriction, the test in g++.dg/tree-ssa/pr61034.C has -// all of its unreachable calls removed too early. -// -// See discussion here: -// https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html - -void -gimple_range_global (vrange &r, tree name, struct function *fun) -{ - tree type = TREE_TYPE (name); - gcc_checking_assert (TREE_CODE (name) == SSA_NAME); - - if (SSA_NAME_IS_DEFAULT_DEF (name) || (fun && fun->after_inlining) - || is_a (SSA_NAME_DEF_STMT (name))) - { - get_range_global (r, name, fun); - return; - } - r.set_varying (type); -} - // ---------------------------------------------- // global_range_query implementation. @@ -373,7 +347,7 @@ global_range_query::range_of_expr (vrange &r, tree expr, gimple *stmt) if (!gimple_range_ssa_p (expr)) return get_tree_range (r, expr, stmt); - get_range_global (r, expr); + gimple_range_global (r, expr); return true; } -- 2.41.0