From patchwork Wed Sep 20 19:29:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 142567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4375961vqi; Wed, 20 Sep 2023 12:30:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ3VoAvxs9mTAtM0KZ6JQekfPyWYkYldbMNO41ju+DdZE3z/zzMY/cJbAN7Ag8OZxw8Po6 X-Received: by 2002:aa7:c995:0:b0:52f:a42a:85a3 with SMTP id c21-20020aa7c995000000b0052fa42a85a3mr3208375edt.0.1695238237164; Wed, 20 Sep 2023 12:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695238237; cv=none; d=google.com; s=arc-20160816; b=cWedkVInJjySWmnogBH5VdwE8+F5pwrWk0dzMJSY2KMg5QI5Pp5tR8HCLVLPrKoEcm dTcSV6wASI776tBHohWawQfdqop4GVe33xzsLiidbdsojujZ607RftciM0A7h0QV4EtA jCKi0dMDcLqqXGYJdd5nj+T3I9MImNV3WQZ8imXdokceWmXBPhSVO1SCvfImzftfNo8e 7SojxfKAKfGpivpXQ7g5e/ZG4vnF+x33o5D79Q2ZjOmkupjq++ZfrVBdJe6+50ZiFEnp LddOWXqoVQJiHZngL0ARA9RpYrxoANNwmOSld+yO9xOcobvnsiofVdhEgaBsG54yEChm Y8Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:subject:from :cc:to:user-agent:mime-version:date:message-id:dkim-signature :dmarc-filter:delivered-to; bh=YuycxGGUT8d6TsRm/Yf/f02+MqwYoo3PzMCo8x/x84k=; fh=ZE6EPE2PZ3ED3Eq5R4AB8kSxxMSuW2qQfXnHfqWWl4c=; b=iNj6+cn/pPp/DPQ2nug7jTLE36yxxKuhd+4sHZHQOEXmy/DMpK74OtbAyQvNc5Bv86 B631JCrg12lwnHQmWkmtFGEuxK4Cg7mdIli/9dWZ9UsQ+/eELW5dWBbuBQNZxgWvxoV0 uotWg8hshZHgTPoUUH/cus5v7hjK8ZjGSmCx/A9ZqoyrqO7aMrQDXe7IM2VsYZ6Yaf2O Nco9Gn7KppJ+OUokB3Max4TWUHVPckMyVtYzDlGjNWGKVwO5wlMKXvp6PpxHej/rpnxU WH2G0US/MBztppVKezZjJtEjj7awUfNfuyf9WeeL+5ay8NJ7jQhbT4GCAEIcxPjIUVQF SY5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="YKfaFbd/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v23-20020aa7d9d7000000b00523cb27ebdesi12840381eds.237.2023.09.20.12.30.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:30:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="YKfaFbd/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D217385701D for ; Wed, 20 Sep 2023 19:30:24 +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 5C07D3858D1E for ; Wed, 20 Sep 2023 19:30:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C07D3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695238199; 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=YuycxGGUT8d6TsRm/Yf/f02+MqwYoo3PzMCo8x/x84k=; b=YKfaFbd/hTSz5gXp2XEXQ+EK0EsXCjcGdAmNrVebuj9BeN7YpyyC/Dd0Y43bF6OAb7hKOp /BeYQO3bDrb+gxreZr772EyCZDuOc5Pe0qbfO6GZyLK/WXm+iZtgVbprbXMKaCL/6Wihe8 jtuD/ATpuoSkpVYKHJRFIAka4AGAFJ4= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-Y0yEPcjJP8WQEimK-5GSKA-1; Wed, 20 Sep 2023 15:29:58 -0400 X-MC-Unique: Y0yEPcjJP8WQEimK-5GSKA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-773f7c8cbf8so60976785a.1 for ; Wed, 20 Sep 2023 12:29:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695238197; x=1695842997; 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=z+cVxmiZYf3DQLcn5hu3mDtKzT8mF4B77c9zlzJLt4U=; b=u+gCYfiH093iH/8/YNAB4nySPHgHHFlKILU5Pt84QiKPMcb5M+sBpKjXb0EyaYweV/ TBe3ySZS+qU5tCNXkXmhVvLS5g24L1Y1uEAGm40kSBlqVZlYnwh20fvBFRmrKS0/rlyD ljokp8VfW0tvVuzPnkBHgOfxo4+KUX9Kheq/VwsMGSAT/01RZ/A3DvuLD8CyAv1oPc3W Xh+plVG60Jj+BZC/h1tdL3+y9T1JpYsUhd2CD7eO2kvEkLCcD/QjP4eDVFzJ/9/osKvU wH9rjJrEryTuI1Q3z7xAAWhlwoMAWzw7QUGxKnMwrgkNHgNoH0KSkS4cCbBf3uGhTjw/ dRBg== X-Gm-Message-State: AOJu0Yw54JyPCSIkzHhNzs9TQqmWib3QY3HG5Gy262NejP2rI2jJEUrD 8PujnSHcX3Po/JK53sxaqgHEpncsux/0LAyRCzhFunCpXkS1+R9xyGQ7uTtiDbtM9qfeQlviqqH 1hd88S7TreoYLUJ9I1SCM2RFJ1qQC1Q2c350Fx1QOk3Mhc4TkANQSUjzaauWGnydvZdu+uQ42vn Xvuw== X-Received: by 2002:a0c:f051:0:b0:656:3045:5638 with SMTP id b17-20020a0cf051000000b0065630455638mr4827409qvl.16.1695238197064; Wed, 20 Sep 2023 12:29:57 -0700 (PDT) X-Received: by 2002:a0c:f051:0:b0:656:3045:5638 with SMTP id b17-20020a0cf051000000b0065630455638mr4827380qvl.16.1695238196654; Wed, 20 Sep 2023 12:29:56 -0700 (PDT) Received: from [192.168.0.174] ([104.219.124.252]) by smtp.gmail.com with ESMTPSA id n1-20020a0ce481000000b006563c0aa959sm4433127qvl.13.2023.09.20.12.29.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Sep 2023 12:29:56 -0700 (PDT) Message-ID: Date: Wed, 20 Sep 2023 15:29:57 -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" From: Andrew MacLeod Subject: [COMMITTED] Tweak ssa_cache::merge_range API. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.2 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777586129513704962 X-GMAIL-MSGID: 1777586129513704962 Merge_range use to return TRUE if there was already a range in the cache.   This patches change the meaning of the return value such that it returns TRUE if the range in the cache changes..  ie, it either set a range where there wasn't one before, or updates an existing range when the old one intersects with the new one results in a different range. It also tweaks the debug output for the cache to no longer output the header text "non-varying Global Ranges" in the class, as the class is now used for other purpoises as well.   The text is moved to when the dump is actually from a global table. Bootstraps on 86_64-pc-linux-gnu with no regressions.   Pushed. Andrew commit 0885e96272f1335c324f99fd2d1e9b0b3da9090c Author: Andrew MacLeod Date: Wed Sep 20 12:53:04 2023 -0400 Tweak merge_range API. merge_range use to return TRUE if ter was already a arange. Now it returns TRUE if it adds a new range, OR updates and existing range with a new value. FALSE is returned when the range already matches. * gimple-range-cache.cc (ssa_cache::merge_range): Change meaning of the return value. (ssa_cache::dump): Don't print GLOBAL RANGE header. (ssa_lazy_cache::merge_range): Adjust return value meaning. (ranger_cache::dump): Print GLOBAL RANGE header. diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 5b74681b61a..3c819933c4e 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -606,7 +606,7 @@ ssa_cache::set_range (tree name, const vrange &r) } // If NAME has a range, intersect it with R, otherwise set it to R. -// Return TRUE if there was already a range set, otherwise false. +// Return TRUE if the range is new or changes. bool ssa_cache::merge_range (tree name, const vrange &r) @@ -616,19 +616,23 @@ ssa_cache::merge_range (tree name, const vrange &r) m_tab.safe_grow_cleared (num_ssa_names + 1); vrange_storage *m = m_tab[v]; - if (m) + // Check if this is a new value. + if (!m) + m_tab[v] = m_range_allocator->clone (r); + else { Value_Range curr (TREE_TYPE (name)); m->get_vrange (curr, TREE_TYPE (name)); - curr.intersect (r); + // If there is no change, return false. + if (!curr.intersect (r)) + return false; + if (m->fits_p (curr)) m->set_vrange (curr); else m_tab[v] = m_range_allocator->clone (curr); } - else - m_tab[v] = m_range_allocator->clone (r); - return m != NULL; + return true; } // Set the range for NAME to R in the ssa cache. @@ -656,27 +660,14 @@ ssa_cache::clear () void ssa_cache::dump (FILE *f) { - /* Cleared after the table header has been printed. */ - bool print_header = true; for (unsigned x = 1; x < num_ssa_names; x++) { if (!gimple_range_ssa_p (ssa_name (x))) continue; Value_Range r (TREE_TYPE (ssa_name (x))); - // Invoke dump_range_query which is a private virtual version of - // get_range. This avoids performance impacts on general queries, - // but allows sharing of the dump routine. + // Dump all non-varying ranges. if (get_range (r, ssa_name (x)) && !r.varying_p ()) { - if (print_header) - { - /* Print the header only when there's something else - to print below. */ - fprintf (f, "Non-varying global ranges:\n"); - fprintf (f, "=========================:\n"); - print_header = false; - } - print_generic_expr (f, ssa_name (x), TDF_NONE); fprintf (f, " : "); r.dump (f); @@ -684,8 +675,6 @@ ssa_cache::dump (FILE *f) } } - if (!print_header) - fputc ('\n', f); } // Return true if NAME has an active range in the cache. @@ -716,7 +705,7 @@ ssa_lazy_cache::set_range (tree name, const vrange &r) } // If NAME has a range, intersect it with R, otherwise set it to R. -// Return TRUE if there was already a range set, otherwise false. +// Return TRUE if the range is new or changes. bool ssa_lazy_cache::merge_range (tree name, const vrange &r) @@ -731,7 +720,7 @@ ssa_lazy_cache::merge_range (tree name, const vrange &r) if (v >= m_tab.length ()) m_tab.safe_grow (num_ssa_names + 1); m_tab[v] = m_range_allocator->clone (r); - return false; + return true; } // Return TRUE if NAME has a range, and return it in R. @@ -996,6 +985,8 @@ ranger_cache::~ranger_cache () void ranger_cache::dump (FILE *f) { + fprintf (f, "Non-varying global ranges:\n"); + fprintf (f, "=========================:\n"); m_globals.dump (f); fprintf (f, "\n"); }