From patchwork Tue Jun 25 02:16:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1951855 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=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X39lHIkJ; 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 4W7T4R3F77z20X6 for ; Tue, 25 Jun 2024 12:17:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 915A9384AB7D for ; Tue, 25 Jun 2024 02:17:23 +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.133.124]) by sourceware.org (Postfix) with ESMTPS id A7463384AB52 for ; Tue, 25 Jun 2024 02:16:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7463384AB52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A7463384AB52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719281818; cv=none; b=E3S6qKeyHhU3o2hHnYh9BI/VKyMdVA8F5SjyDagf/4qJd4N2F9k765izOo72Nc1bIh7j+be6W1IiAj/uETl3NI7EKpCEzQ2RGduQR7TU700wfSHkTs2xxmxcLrI9Km1pimMHYMJ0ctUCiFT1PeiFae1JC+9gPfMHXigx5szZZG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719281818; c=relaxed/simple; bh=ZmMRaM3SqWKj9UCo2UVe/J9SluUSMtCCRNRnBkXRcOw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=s/srrZ3ugWUOxZT4s5XOZItId1voDIDeXhyizPieUtsQVhzBosVbyxqQOj9KPJqAL1Bur4G6Z+xBQFSOughjHlKEMqBWOSRe4MSKSaSVw4iXjMwKt0WwN3u7ZuYEL23+SlUj0xZXCiVaMeiHhQbc+fV0iS5je1lrV/UQGQOzHEQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719281816; 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=7hnS6MifldKBoH30oqUK0ZzQTpbgVV5cgnvYYVm5qcM=; b=X39lHIkJ1upjSsx8mWTIbBWHuKvONB55tRkIKrZ8QOpqgC0didMOa71fF4vbk0ZbTVAJCW MbgYxPCd7uOicDWISlEJ0tBKgGK5fL0/xNuiLmMcovsL/5qwutR2/D1mI/YfJYIruaGzaD 17t7ZoMw4gC7J4sckw7rByO2YOErq7s= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-qv3sFexsP6GrSEiWhZpAww-1; Mon, 24 Jun 2024 22:16:48 -0400 X-MC-Unique: qv3sFexsP6GrSEiWhZpAww-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-444ab7d5202so81155831cf.1 for ; Mon, 24 Jun 2024 19:16:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719281807; x=1719886607; 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=GERoYJjWSRrpNZjyOs7SAKBRDu0553zfPHZ7Mf4VogU=; b=dCsisK9G8t4qDUm+CPuFA96BXj5FPjmxLpwAviI+AmRpUDG44RI6/kFiPJ3NJaXQY8 Q388dIElgmkY+eFkJ23NM88nkSHc09jmKXr88C9qnqErhNYr7B2V6O9Tz4lyl5MmN91l wGbjrJQFvnLLK9gPATSooU9VRr4bjx3aY5KZ0tVKLoh03Q3iT/GxR7fZO4Mczl/5jtXo 9MGfIJftlyfnOk5GQh+9GLtqqCW3wPusCzJgjS2zVYFe8u9QN7ZPql6RZtsQtcl3uzhZ PnUwbuQGULqWJQeeZzSzlhDfJWXwI1k9dG1Uazp4gIklqYUknPyNMk7Vv6WntxhNPxcf OB8Q== X-Gm-Message-State: AOJu0Yx3xKBUA51zOoofz8H+2UVa3pFUmG72Bujv8NuBcVRJvW5KIwjL S6G/uHm06dNUFtEcJXDUq0sVDY1it0H1d4POC/GtGomOmN8pUTXsCuFzokDNJq8rkhfC6dpzSsR 2O5IOr6FoV8xGNBbq37fhH1ZBMDDUcFmPH18BoWgFWVNFVgjNkQLPRYbODU6uojt/G0wIwmP1UX W87J2A6ehK4YXuJF78PhTKKnCVCmzJs6F6p6Tb4SE= X-Received: by 2002:a05:622a:1108:b0:440:5561:3c4f with SMTP id d75a77b69052e-444d936c562mr74985131cf.48.1719281807531; Mon, 24 Jun 2024 19:16:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0fQ2fg/nTE5Mi/aOh0wPxjw+7/QeHJ4SVj/n1+BFbYW5ACmkUB2qbJ3/kfWoXskU6ZG2wbQ== X-Received: by 2002:a05:622a:1108:b0:440:5561:3c4f with SMTP id d75a77b69052e-444d936c562mr74985031cf.48.1719281807124; Mon, 24 Jun 2024 19:16:47 -0700 (PDT) Received: from ?IPV6:2607:fea8:51de:a700::8e40? ([2607:fea8:51de:a700::8e40]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-444c2b84599sm49506181cf.39.2024.06.24.19.16.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jun 2024 19:16:46 -0700 (PDT) Message-ID: Date: Mon, 24 Jun 2024 22:16:45 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches Cc: "hernandez, aldy" From: Andrew MacLeod Subject: [COMMITTED] Make transitive relations an oracle option X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.6 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Transitive relations can add  processing time to the relation oracle as they need to look up previous relations. This  that may not be desired, especially for something like fast VRP.   This patch adds a flag at oracle creation time which makes processing them optional. Bootstraps on x86_64-pc-linux-gnu with no regressions.   Pushed. Andrew From d3088bf565afcad410ce4fd3ebf6c993f63703b6 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Mon, 24 Jun 2024 10:29:06 -0400 Subject: [PATCH 1/2] Make transitive relations an oracle option This patch makes processing of transitive relations configurable at dom_oracle creation. * tree-vrp.cc (execute_fast_vrp): Do not use transitive relations. * value-query.cc (range_query::create_relation_oracle): Add parameter to enable transitive relations. * value-query.h (range_query::create_relation_oracle): Likewise. * value-relation.h (dom_oracle::dom_oracle): Likewise. * value-relation.cc (dom_oracle::dom_oracle): Likewise. (dom_oracle::register_transitives): Check transitive flag. --- gcc/tree-vrp.cc | 3 ++- gcc/value-query.cc | 7 ++++--- gcc/value-query.h | 2 +- gcc/value-relation.cc | 6 +++++- gcc/value-relation.h | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index 4fc33e63e7d..26979b706e5 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -1258,7 +1258,8 @@ execute_fast_vrp (struct function *fun, bool final_p) gcc_checking_assert (!fun->x_range_query); fun->x_range_query = &dr; - get_range_query (fun)->create_relation_oracle (); + // Create a relation oracle without transitives. + get_range_query (fun)->create_relation_oracle (false); folder.substitute_and_fold (); if (folder.m_unreachable) diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 0a280be580b..cac2cb5b2bc 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -223,17 +223,18 @@ range_query::destroy_infer_oracle () } // Create dominance based range oracle for the current query if dom info is -// available. +// available. DO_TRANS_P indicates whether transitive relations should +// be created. This can cost more in compile time. void -range_query::create_relation_oracle () +range_query::create_relation_oracle (bool do_trans_p) { gcc_checking_assert (this != &global_ranges); gcc_checking_assert (m_relation == &default_relation_oracle); if (!dom_info_available_p (CDI_DOMINATORS)) return; - m_relation = new dom_oracle (); + m_relation = new dom_oracle (do_trans_p); gcc_checking_assert (m_relation); } diff --git a/gcc/value-query.h b/gcc/value-query.h index 2572a03095d..78840fd7a78 100644 --- a/gcc/value-query.h +++ b/gcc/value-query.h @@ -76,7 +76,7 @@ public: virtual bool range_on_exit (vrange &r, basic_block bb, tree expr); inline class relation_oracle &relation () const { return *m_relation; } - void create_relation_oracle (); + void create_relation_oracle (bool do_trans_p = true); void destroy_relation_oracle (); inline class infer_range_oracle &infer_oracle () const { return *m_infer; } diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index d7bc1b72558..9293d9ed65b 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -978,8 +978,9 @@ relation_chain_head::find_relation (const_bitmap b1, const_bitmap b2) const // Instantiate a relation oracle. -dom_oracle::dom_oracle () +dom_oracle::dom_oracle (bool do_trans_p) { + m_do_trans_p = do_trans_p; m_relations.create (0); m_relations.safe_grow_cleared (last_basic_block_for_fn (cfun) + 1); m_relation_set = BITMAP_ALLOC (&m_bitmaps); @@ -1179,6 +1180,9 @@ void dom_oracle::register_transitives (basic_block root_bb, const value_relation &relation) { + // Only register transitives if they are requested. + if (!m_do_trans_p) + return; basic_block bb; // Only apply transitives to certain kinds of operations. switch (relation.kind ()) diff --git a/gcc/value-relation.h b/gcc/value-relation.h index cf009e6aa19..f168fd9ed41 100644 --- a/gcc/value-relation.h +++ b/gcc/value-relation.h @@ -216,7 +216,7 @@ public: class dom_oracle : public equiv_oracle { public: - dom_oracle (); + dom_oracle (bool do_trans_p = true); ~dom_oracle (); void record (basic_block bb, relation_kind k, tree op1, tree op2) @@ -229,6 +229,7 @@ public: void dump (FILE *f, basic_block bb) const final override; void dump (FILE *f) const final override; private: + bool m_do_trans_p; bitmap m_tmp, m_tmp2; bitmap m_relation_set; // Index by ssa-name. True if a relation exists vec m_relations; // Index by BB, list of relations. -- 2.45.0