From patchwork Fri Sep 15 14:14:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1834922 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=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=nQz9bE/r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4RnGRd3NbRz1ypK for ; Sat, 16 Sep 2023 00:15:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70BC4385783F for ; Fri, 15 Sep 2023 14:15:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70BC4385783F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694787307; bh=AJ1hbCrQLbwoJoLQKnyvZfWTXT/441c68ruWx85K7+g=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nQz9bE/rmytdkiDo2uYf2ydRbq6UZU95HODsNHQZK3VdWkDq0mWW6Og1s5g2DH3dX 9HfisqyJg34lgFYyinvroUBycQUAms+OFhzHlBZZMZ7z1Lg0BREh47j+qA3uZQNScu 35vzYL6leY92j3oM9S52CLG6lhb2hTBE93P/IQ/Y= 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 DF6CF3858284 for ; Fri, 15 Sep 2023 14:14:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF6CF3858284 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-aspQ-O-FOvq5tI8_bDNWGA-1; Fri, 15 Sep 2023 10:14:14 -0400 X-MC-Unique: aspQ-O-FOvq5tI8_bDNWGA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6563873fef9so6606416d6.2 for ; Fri, 15 Sep 2023 07:14:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694787253; x=1695392053; 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=lmB3/UxCFQWsiVdCvtdtf96oI1CIq3rsDTu0ckr3WWY=; b=CxrX7al+HS9bjyLMD4sEKOTa8A0OxZxs6CPbJYJCD/mvPX1cgUCMGUYLo3zM1wPmz+ f0lY9ucwNl8ku2hOIKOPQWqCEIW+NJ7P5oe+Vmu/t9oXp8en9fT9A9pL3YOQMRfxTadq 033+5bNb3loKlWYZNbyvlZgrh94Wn6KVZlAurgO+cRJOeMfIs+IBXxgK1dbWYjJDYYg+ YqAjwsctF7D9O6oCmkgfSbli7m7Ga7INt2ect81ErVBFmZCdM+hwH4E2uXkj9FHxRqvw Ysc8ETTomhEPLCipV2htW17M6/VhzTzbB2xco6kJNd6e4dnxy11Slbg9nnDVKQdrTn6E agjg== X-Gm-Message-State: AOJu0YwbwzvtFnfiEorosu8Bqyl/OqWG7JEPGpleal2i95itlBrZzSkf hV6zhTPourrzpCxEPCp22HU5qitc8fJMa9PBdWw3tY4wPJwhRatikB+spl4F+Cla2slCm/DJY4K RlHbIPzeS0XM5HWvoionCWBwxoEkAstLB0zqm7GkfjDPgVakwy5e34iD5bnRXe/XtKpoYDknO1y 0yhw== X-Received: by 2002:a0c:e448:0:b0:64f:69a3:af3f with SMTP id d8-20020a0ce448000000b0064f69a3af3fmr1890621qvm.39.1694787253121; Fri, 15 Sep 2023 07:14:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+6IfdfjO65qFn0NPIOBVwkAtuD92rTvvX7q7zZUU02CMj92PO/bBvqtXZPi5ze6nGC3Fwtg== X-Received: by 2002:a0c:e448:0:b0:64f:69a3:af3f with SMTP id d8-20020a0ce448000000b0064f69a3af3fmr1890596qvm.39.1694787252797; Fri, 15 Sep 2023 07:14:12 -0700 (PDT) Received: from ?IPV6:2605:8d80:5e0:23ed:dc0e:d72:28b1:179f? ([2605:8d80:5e0:23ed:dc0e:d72:28b1:179f]) by smtp.gmail.com with ESMTPSA id o10-20020a05620a110a00b0076cbcf8ad3bsm1246909qkk.55.2023.09.15.07.14.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 07:14:12 -0700 (PDT) Message-ID: Date: Fri, 15 Sep 2023 10:14:11 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 2/2] Always do PHI analysis before loop analysis. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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_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: , 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" The original invocation of phi_analysis was only invoked if there was no loop information available.  I have found situations where phi analysis enhances existing loop information, and as such this patch moves the phi analysis block to before loop analysis is invoked (in case a query is made from within that area), and does it unconditionally.  There is minimal impact on compilation time. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 5d5f90ec3b4a939cae5ce4f33b76849f6b08e3a9 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 13 Sep 2023 10:09:16 -0400 Subject: [PATCH 2/3] Always do PHI analysis and before loop analysis. PHI analysis wasn't being done if loop analysis found a value. Always do the PHI analysis, and run it for an iniital value before invoking loop analysis. * gimple-range-fold.cc (fold_using_range::range_of_phi): Always run phi analysis, and do it before loop analysis. --- gcc/gimple-range-fold.cc | 53 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 03805d88d9b..d1945ccb554 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -939,7 +939,32 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) } } - bool loop_info_p = false; + // If PHI analysis is available, see if there is an iniital range. + if (phi_analysis_available_p () + && irange::supports_p (TREE_TYPE (phi_def))) + { + phi_group *g = (phi_analysis())[phi_def]; + if (g && !(g->range ().varying_p ())) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "PHI GROUP query for "); + print_generic_expr (dump_file, phi_def, TDF_SLIM); + fprintf (dump_file, " found : "); + g->range ().dump (dump_file); + fprintf (dump_file, " and adjusted original range from :"); + r.dump (dump_file); + } + r.intersect (g->range ()); + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, " to :"); + r.dump (dump_file); + fprintf (dump_file, "\n"); + } + } + } + // If SCEV is available, query if this PHI has any known values. if (scev_initialized_p () && !POINTER_TYPE_P (TREE_TYPE (phi_def))) @@ -962,32 +987,6 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) fprintf (dump_file, "\n"); } r.intersect (loop_range); - loop_info_p = true; - } - } - } - - if (!loop_info_p && phi_analysis_available_p () - && irange::supports_p (TREE_TYPE (phi_def))) - { - phi_group *g = (phi_analysis())[phi_def]; - if (g && !(g->range ().varying_p ())) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "PHI GROUP query for "); - print_generic_expr (dump_file, phi_def, TDF_SLIM); - fprintf (dump_file, " found : "); - g->range ().dump (dump_file); - fprintf (dump_file, " and adjusted original range from :"); - r.dump (dump_file); - } - r.intersect (g->range ()); - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, " to :"); - r.dump (dump_file); - fprintf (dump_file, "\n"); } } } -- 2.41.0