From patchwork Fri May 13 13:58:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1630764 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=K7aEM7bT; 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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L09H36sYwz9sFk for ; Fri, 13 May 2022 23:58:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4E29396E05C for ; Fri, 13 May 2022 13:58:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4E29396E05C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652450333; bh=wcYWT4wF06fx5RauhuZ7aTaOLuXfek3iQNeeWIq8sjs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=K7aEM7bThpAWr0RIQHmMr109RIwcTCzMs5cZERbHF2V29d2kR/WR6+2UyKl/0DgF+ LlEPv7ci2DXmdksulUO2Ckc7sE/m2NMXinAiXm+j0U7wRf9RTB5b/ANG+8VGWXJAhQ Yl0ib2wqPmlpsm+IVmBiMuJGJVSxHfAry00at+w8= 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 77DBA3888816 for ; Fri, 13 May 2022 13:58:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77DBA3888816 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-360-TMLBr-MJO1CnGG3M3Y-3Dw-1; Fri, 13 May 2022 09:58:32 -0400 X-MC-Unique: TMLBr-MJO1CnGG3M3Y-3Dw-1 Received: by mail-qk1-f199.google.com with SMTP id x191-20020a3763c8000000b0069fb66f3901so6413501qkb.12 for ; Fri, 13 May 2022 06:58:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:from:subject; bh=qm4q+dUJlCDO85c1Bo1QMZwwnMNHJ483zWyYDbQ334I=; b=a5YhvY2mOWjn3WLYe7GNPtUQkepJ7DbE/XrkiU8yLw04fd38fRyvrVcV9ExSzAE7gw hyc7n171y3u6HgtsHwrKddjQoDXkNfVXesGMCzUegslePUZ8ubEXYubjbmnchhPOBClK oypFsAjsPOBGqdlzTSC6l5xYXk+H7YJLv8ehCUEP+AxyOrIKCJ3GTyEwCGtvcbYJjitn wie4gg86XJe5SGCcthnutuxCCEBuCCmOa1wfEm1ZpsAMSeYlmeLXALW1HbnUQfMdO05P qnbUfNtXb0dOSYAx0gAqUaCw/aQcqHoSYndcgeZYKSXzquGZ/7KKqYRIUvbIRUXacLbT FaRQ== X-Gm-Message-State: AOAM532DNIKzgO8Cuc4TEzEk6V7qovrT1/us8+2Oi9cnLXbtZJWHJ9xc zF4w1muPgj7yhtViVLgye0e4RzUW/Cr0t2lfiC0DhAKWG2v8XLNQ+WzKL7jZqcG/Jeem5Sxkk2w f5ZgDyiVfX2m+RHF5SyufKO0Io8glA6EjhkFE9Jv3+udntbKQoiE9tl7jq8mpe2iGj2kckw== X-Received: by 2002:ac8:59d6:0:b0:2f3:f521:ed4b with SMTP id f22-20020ac859d6000000b002f3f521ed4bmr4681555qtf.320.1652450311869; Fri, 13 May 2022 06:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXlY0mhvSkUlGPZ+EeH580NQkkaXbdNdxB5SAaIQd6H827uHGcyL3/5AR1Q1hoqsxd5EFI0A== X-Received: by 2002:ac8:59d6:0:b0:2f3:f521:ed4b with SMTP id f22-20020ac859d6000000b002f3f521ed4bmr4681534qtf.320.1652450311587; Fri, 13 May 2022 06:58:31 -0700 (PDT) Received: from ?IPV6:2607:fea8:a261:5e00::94b0? ([2607:fea8:a261:5e00::94b0]) by smtp.gmail.com with ESMTPSA id d29-20020a05620a205d00b0069fc13ce1fcsm1341181qka.45.2022.05.13.06.58.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 May 2022 06:58:30 -0700 (PDT) Message-ID: Date: Fri, 13 May 2022 09:58:29 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 To: gcc-patches Subject: [COMMITTED] Export global ranges during the VRP block walk. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.8 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, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" VRP currently searches the ssa_name list for globals to exported after it  finishes running.  This change simply exports globals as they are calculated for the final time during the DOM walk. This avoid the occasional awkwardness of determined what ssa-names in the list are important, as well as allowing forthcoming side-effect code to adjust what is currently known as a global value during the walk without affecting the values exported for the entire function. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew commit af34279921f4bb95b07c0be7fce9baeffafcb53d Author: Andrew MacLeod Date: Wed Feb 16 19:59:34 2022 -0500 Export global ranges during the VRP block walk. VRP currently searches the ssa_name list for globals to exported after it finishes running. Recent changes have VRP calling a side-effect routine for each stmt during the walk. This change simply exports globals as they are calculated the final time during the walk. * gimple-range.cc (gimple_ranger::register_side_effects): First check if the DEF should be exported as a global. * tree-vrp.cc (rvrp_folder::pre_fold_bb): Process PHI side effects, which will export globals. (execute_ranger_vrp): Remove call to export_global_ranges. diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index f0caefce2a3..1fdee026a4b 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -458,6 +458,28 @@ gimple_ranger::fold_stmt (gimple_stmt_iterator *gsi, tree (*valueize) (tree)) void gimple_ranger::register_side_effects (gimple *s) { + // First, export the LHS if it is a new global range. + tree lhs = gimple_get_lhs (s); + if (lhs) + { + int_range_max tmp; + if (range_of_stmt (tmp, s, lhs) && !tmp.varying_p () + && update_global_range (tmp, lhs) && dump_file) + { + value_range vr = tmp; + fprintf (dump_file, "Global Exported: "); + print_generic_expr (dump_file, lhs, TDF_SLIM); + fprintf (dump_file, " = "); + vr.dump (dump_file); + int_range_max same = vr; + if (same != tmp) + { + fprintf (dump_file, " ... irange was : "); + tmp.dump (dump_file); + } + fputc ('\n', dump_file); + } + } m_cache.block_apply_nonnull (s); } diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index 0cbd9d369ca..8ba9ca7328f 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -4302,6 +4302,9 @@ public: void pre_fold_bb (basic_block bb) OVERRIDE { m_pta->enter (bb); + for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + m_ranger->register_side_effects (gsi.phi ()); } void post_fold_bb (basic_block bb) OVERRIDE @@ -4345,7 +4348,6 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p) gimple_ranger *ranger = enable_ranger (fun); rvrp_folder folder (ranger); folder.substitute_and_fold (); - ranger->export_global_ranges (); if (dump_file && (dump_flags & TDF_DETAILS)) ranger->dump (dump_file);