From patchwork Wed Aug 23 18:47:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1824899 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=cnxK/7Ug; 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 4RWFbj6cgQz1ydy for ; Thu, 24 Aug 2023 04:48:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DF35385DC04 for ; Wed, 23 Aug 2023 18:48:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DF35385DC04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692816500; bh=13xJGHZY3WXSVUORsr1zeONZuR5ipr5UvsMf5/B1eZI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=cnxK/7UgK4csoqtoUPont0FrM68fOjH6YCGNVweUVQZGAmA4XEMu9Tq3OpfaeU3SO kN/jn6QKU+7WGAzAyoqQxeTDOmj26c6ahG1ou5apeM4hv+o5fBEbg0qRO1oejwqSlX 6g7eKSzm3Gp+3wQsiieW4LBjxT8LSuzdunvpC3wQ= 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 6FFE3385B524 for ; Wed, 23 Aug 2023 18:47:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FFE3385B524 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-rO6NKF1bNgCJd28ti1PnlA-1; Wed, 23 Aug 2023 14:47:56 -0400 X-MC-Unique: rO6NKF1bNgCJd28ti1PnlA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-64a459efdbcso74635316d6.3 for ; Wed, 23 Aug 2023 11:47:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692816475; x=1693421275; 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=2y4i5S9bxPXOhubhqNL6UKvrXVJTsCwb93tUyzjqc48=; b=B6wjDW1C4ry8Oyx8lCrXiAYUn6HFVaJjmnEkTZs4H+vuuhiS1w+HylBJm6MSg2wmb+ PpexqWPcKbaTupUuZmfGwEwoERzuy6k3SMl3ZsD+482+BgpXgxR3balJxZXlnKvroAR1 qi4EG/5R+rCkzTzmCh/QIDlWgvF47RPJozPpYQCK8EK0MKhF879KLaYZMtrz3QGiAPCe 2pUfqWSk3gtlOgrjnQJmrvtEbKv0LW43azvz+MOWIptXNzIp5ysz/4r/yx+CNooTupCh K99rNNiS8IihV8H2/nKRC5s+fyXo5L8X6U9L6NkOcBfylAw6NRKlXOdJ2q5QuniKqQCm PtOA== X-Gm-Message-State: AOJu0Yw+LJYKZkOc/wF3WrgYm3tHQPrQ5+nBjAWYWwZomxlNaxIBuECI 7rxEosMs2+VRXvNABiEdet1QCVkLq4WIQOrKJxs/1pFQfeqRc3OrKBYdIYY8ScXTyn4oxJ7OIO/ gEe7z++D6HVw9ZKXbKKHHl3guvHe77el0F6Dl6DIW/ox4v2wTaE3+FCNuVFwN+UzC/MBvQsupRm Jtxw== X-Received: by 2002:ad4:559c:0:b0:626:b17:3b97 with SMTP id f28-20020ad4559c000000b006260b173b97mr10904874qvx.65.1692816475502; Wed, 23 Aug 2023 11:47:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkMHQbV8giH2Fie1Qv5/mNRaf0hMM09Tut8KoWVbptSucNkn7hQmPSShxQUf3Oir1xJ1+LKA== X-Received: by 2002:ad4:559c:0:b0:626:b17:3b97 with SMTP id f28-20020ad4559c000000b006260b173b97mr10904862qvx.65.1692816475175; Wed, 23 Aug 2023 11:47:55 -0700 (PDT) Received: from ?IPV6:2607:fea8:51e3:8300::28f5? ([2607:fea8:51e3:8300::28f5]) by smtp.gmail.com with ESMTPSA id k8-20020a0cb248000000b006490a9946b6sm4812608qve.119.2023.08.23.11.47.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 11:47:54 -0700 (PDT) Message-ID: <921b7149-303a-bf0f-e550-864d5d4b5056@redhat.com> Date: Wed, 23 Aug 2023 14:47:53 -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] Phi analyzer - Do not create phi groups with a single phi. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.5 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.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" Rangers Phi Analyzer was creating a group consisting of a single PHI, which was problematic.  It didn't really help anything, and it prevented larger groups from including those PHIs and stopped some useful things from happening. Bootstrapped on x86_64-pc-linux-gnu  with no regressions. Pushed. Andrew From 9855b3f0a2869d456f0ee34a94a1231eb6d44c4a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 16 Aug 2023 13:23:06 -0400 Subject: [PATCH 1/4] Don't process phi groups with one phi. The phi analyzer should not create a phi group containing a single phi. * gimple-range-phi.cc (phi_analyzer::operator[]): Return NULL if no group was created. (phi_analyzer::process_phi): Do not create groups of one phi node. --- gcc/gimple-range-phi.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-range-phi.cc b/gcc/gimple-range-phi.cc index ffb4691d06b..a94b90a4660 100644 --- a/gcc/gimple-range-phi.cc +++ b/gcc/gimple-range-phi.cc @@ -344,9 +344,10 @@ phi_analyzer::operator[] (tree name) process_phi (as_a (SSA_NAME_DEF_STMT (name))); if (bitmap_bit_p (m_simple, v)) return NULL; - // If m_simple bit isn't set, then process_phi allocated the table - // and should have a group. - gcc_checking_assert (v < m_tab.length ()); + // If m_simple bit isn't set, and process_phi didn't allocated the table + // no group was created, so return NULL. + if (v >= m_tab.length ()) + return NULL; } return m_tab[v]; } @@ -363,6 +364,7 @@ phi_analyzer::process_phi (gphi *phi) unsigned x; m_work.truncate (0); m_work.safe_push (gimple_phi_result (phi)); + unsigned phi_count = 1; bitmap_clear (m_current); // We can only have 2 externals: an initial value and a modifier. @@ -407,6 +409,7 @@ phi_analyzer::process_phi (gphi *phi) gimple *arg_stmt = SSA_NAME_DEF_STMT (arg); if (arg_stmt && is_a (arg_stmt)) { + phi_count++; m_work.safe_push (arg); continue; } @@ -430,9 +433,12 @@ phi_analyzer::process_phi (gphi *phi) } } - // If there are no names in the group, we're done. - if (bitmap_empty_p (m_current)) + // If there are less than 2 names, just return. This PHI may be included + // by another PHI, making it simple or a group of one will prevent a larger + // group from being formed. + if (phi_count < 2) return; + gcc_checking_assert (!bitmap_empty_p (m_current)); phi_group *g = NULL; if (cycle_p) -- 2.41.0