From patchwork Fri Sep 15 14:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1834921 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=GhrRfLx5; 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 4RnGQZ5rNWz1ynD for ; Sat, 16 Sep 2023 00:14:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9A94E3857B9B for ; Fri, 15 Sep 2023 14:14:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A94E3857B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694787251; bh=DLKj+mHnQEM0uKU2bYW1fKHdZpjZkHirJYDhc6ktVNI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=GhrRfLx5qcvbVBVKdkvGqdIGh712gYECzrlWoIchMyihHt60/KCWBKIILJwDsRGbN nqQGcy9vurfGZpwCBbbpBq1fxcxEir9dGA3dr6tmDOSQSd42yaqOXto93B8/Mgs9I6 OHpsHyMhiz/RH9qSRRlCzMvk0Xej6bcILLPsVTn0= 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 5E1B93858C52 for ; Fri, 15 Sep 2023 14:13:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E1B93858C52 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-HLu07RC-PZC3ZmgQ5iqaZA-1; Fri, 15 Sep 2023 10:13:50 -0400 X-MC-Unique: HLu07RC-PZC3ZmgQ5iqaZA-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-76ef03effdcso278035685a.2 for ; Fri, 15 Sep 2023 07:13:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694787229; x=1695392029; 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=ye7+meZg9XVopUScXqev20sEVlAELQwLs6rR16gzmAY=; b=IzunNWiaYN561+pBClnkYr45EWw+E9lC2NYLwJuHsYDWateecBGfB8ZROBp01jwokl oDtJki6FhPpMak6t98UtQkeZ5JW9q1TZskyxRe5niL7c06k4z0RlBAn5o0q5HXms1jfE AWd5/Tb+2mKm27ZF1C4FOL2WW3ZioayVLJPnL7VteTE1OZysI9YG57EFqh87U7xEDcZv hMmNQpTUS1trgJ4pVGCWauZuV2eYCrwfG1EgUgqCOSg+AtvZ02SNDnJflNrTJ99HQnBm yC6PaadKJdMMR/orKVSqkaYK6490Bii6rUT7GkguXB8qH6LmD86zCP4qNaUV2XjZAZBb aP/w== X-Gm-Message-State: AOJu0YxtYw+FPQVtwNtxo8n1BulbnucCurX39LtIe/gveGJ7ts8KEMfI Yth/+ZFdp0Nzrj7XTccC8Po4CqVOWHa0XmsRWYvlvNjsiATmGLr8T17AWBgiZs5ZtIfHlS6hLoB 9POVSzk0jjSls7pSZUURvhqONoRyWzc7RDawuUEoG6oqcuxhrmpK27ZSLvVvV3u8rNYMGASr2Ar EKGQ== X-Received: by 2002:a05:620a:472c:b0:772:63b4:3804 with SMTP id bs44-20020a05620a472c00b0077263b43804mr1919882qkb.56.1694787229700; Fri, 15 Sep 2023 07:13:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFL6pAtWrjJOF3cBFzvyegIKHeFBRFfhEUYtUFRJBpctPcZhlmJa2nHlk1s5aplXOYk97QkKw== X-Received: by 2002:a05:620a:472c:b0:772:63b4:3804 with SMTP id bs44-20020a05620a472c00b0077263b43804mr1919856qkb.56.1694787229384; Fri, 15 Sep 2023 07:13:49 -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 i3-20020a37c203000000b00765aa3ffa07sm1250258qkm.98.2023.09.15.07.13.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 07:13:48 -0700 (PDT) Message-ID: <2e741213-66e4-fbc5-41ec-4b7e0c8b4844@redhat.com> Date: Fri, 15 Sep 2023 10:13:47 -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 1/2] Fix indentation in range_of_phi. 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_H3, 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" Somewhere along the way a large sequence of code in range_of_phi() ended up with the same indentation of the preceeding loop.. this simply fixes it. committed as obvious. Andrew From e35c3b5335879afb616c6ead0f41bf6c275ee941 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 13 Sep 2023 09:58:39 -0400 Subject: [PATCH 1/3] Fix indentation. No functio0nal change, indentation was incorrect. * gimple-range-fold.cc (fold_using_range::range_of_phi): Fix indentation. --- gcc/gimple-range-fold.cc | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 8ebff7f5980..03805d88d9b 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -898,46 +898,46 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) break; } - // If all arguments were equivalences, use the equivalence ranges as no - // arguments were processed. - if (r.undefined_p () && !equiv_range.undefined_p ()) - r = equiv_range; - - // If the PHI boils down to a single effective argument, look at it. - if (single_arg) - { - // Symbolic arguments can be equivalences. - if (gimple_range_ssa_p (single_arg)) - { - // Only allow the equivalence if the PHI definition does not - // dominate any incoming edge for SINGLE_ARG. - // See PR 108139 and 109462. - basic_block bb = gimple_bb (phi); - if (!dom_info_available_p (CDI_DOMINATORS)) - single_arg = NULL; - else - for (x = 0; x < gimple_phi_num_args (phi); x++) - if (gimple_phi_arg_def (phi, x) == single_arg - && dominated_by_p (CDI_DOMINATORS, - gimple_phi_arg_edge (phi, x)->src, - bb)) - { - single_arg = NULL; - break; - } - if (single_arg) - src.register_relation (phi, VREL_EQ, phi_def, single_arg); - } - else if (src.get_operand (arg_range, single_arg) - && arg_range.singleton_p ()) - { - // Numerical arguments that are a constant can be returned as - // the constant. This can help fold later cases where even this - // constant might have been UNDEFINED via an unreachable edge. - r = arg_range; - return true; - } - } + // If all arguments were equivalences, use the equivalence ranges as no + // arguments were processed. + if (r.undefined_p () && !equiv_range.undefined_p ()) + r = equiv_range; + + // If the PHI boils down to a single effective argument, look at it. + if (single_arg) + { + // Symbolic arguments can be equivalences. + if (gimple_range_ssa_p (single_arg)) + { + // Only allow the equivalence if the PHI definition does not + // dominate any incoming edge for SINGLE_ARG. + // See PR 108139 and 109462. + basic_block bb = gimple_bb (phi); + if (!dom_info_available_p (CDI_DOMINATORS)) + single_arg = NULL; + else + for (x = 0; x < gimple_phi_num_args (phi); x++) + if (gimple_phi_arg_def (phi, x) == single_arg + && dominated_by_p (CDI_DOMINATORS, + gimple_phi_arg_edge (phi, x)->src, + bb)) + { + single_arg = NULL; + break; + } + if (single_arg) + src.register_relation (phi, VREL_EQ, phi_def, single_arg); + } + else if (src.get_operand (arg_range, single_arg) + && arg_range.singleton_p ()) + { + // Numerical arguments that are a constant can be returned as + // the constant. This can help fold later cases where even this + // constant might have been UNDEFINED via an unreachable edge. + r = arg_range; + return true; + } + } bool loop_info_p = false; // If SCEV is available, query if this PHI has any known values. -- 2.41.0 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