From patchwork Wed Jul 5 23:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1804098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=AI0f89Fj; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QxFhX1bLgz20bQ for ; Thu, 6 Jul 2023 09:08:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EAE56385DC18 for ; Wed, 5 Jul 2023 23:08:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAE56385DC18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598520; bh=EPkl7xEevOpAyF7lXDfjU8a6EV7Fq1IFQohado4Cb/0=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=AI0f89FjWP1qOtT91DQAJtuJSoEtrFoppB6wQMYyJfXHntNz6DW8dXCf0XnX99j7+ yOsFXqWhrqqNKRMJY+xqmaFvQD0SfHWV2Or0U9gnuxn/b9decQWFlc0SuTpV9wMssB jZo1Z+MVnVfPTQ8eaArLLAOmRee//yVl9UTxA93w= 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 850953856DDF for ; Wed, 5 Jul 2023 23:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 850953856DDF Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-9jkBaaQ3PEelQy3zxkPtng-1; Wed, 05 Jul 2023 19:08:08 -0400 X-MC-Unique: 9jkBaaQ3PEelQy3zxkPtng-1 Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-44503e194f8so654137.2 for ; Wed, 05 Jul 2023 16:08:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688598488; x=1691190488; 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=cHv14bFROOJbzTwhER7lnF1prgrolUlfJ+SVH9iRNQQ=; b=SZP79x2Fn1DR09+bWDBMoiqPTTNpPHHMPsPp+bBcHOwgwxBH68tSBqrQPAleBUJNZC BhSEFZnKmwAWysesl0euwLz/P8Kpju+df1V4B7MlueNetxuBxXrOkVe3Ov5muKf+ht7Z RQh282XACJzEuKf2Bhf5c4TQHIiQvjpwHR2JoPROXU8sHMwOq/Um0qcNAxJfohfFOQkO 4R3YbUZ7FDjK8toQciTRM7vHqdLr0/MLDcl4LdXxkJOPnpWyIevdV1DSyvNqKgPwWI9I m4kEB9j0mwS2U4J+4oA7FsCVvMzbi94wdyJfDgoCjUWoCl4F5QqafdvyrJgLpOBMYgxz lUJg== X-Gm-Message-State: ABy/qLYCI48PfqeP9DtN3N5L47hWeODGnO1u3ujxLmiSjVdkLfEKGp11 ciJPma/WL+Gku5oPPBxzEqkT5WFQqogweefFzWDcLz+oGYhqj8J1lgywLQOdccdXmWZDbv54SYF OiZVtLPN+4k8K3e9/23Z9s2YrUfcQ/+fWhf1F4ul9huvUJJ99R3ac02nZPZr2cbxmZdKeIFhR51 B0AA== X-Received: by 2002:a67:b14b:0:b0:443:6549:3e18 with SMTP id z11-20020a67b14b000000b0044365493e18mr62329vsl.18.1688598487741; Wed, 05 Jul 2023 16:08:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYYw21Kl30XERAjDnea04YbuKSOABlRFJROoz/NrH5/kAKV5yBF4kt+SbbOA3AhBKl+LIZXg== X-Received: by 2002:a67:b14b:0:b0:443:6549:3e18 with SMTP id z11-20020a67b14b000000b0044365493e18mr62320vsl.18.1688598487291; Wed, 05 Jul 2023 16:08:07 -0700 (PDT) Received: from [192.168.0.174] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id k11-20020a0cb24b000000b00626161ea7a3sm66575qve.2.2023.07.05.16.08.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 16:08:06 -0700 (PDT) Message-ID: <121a95b0-6ab7-5cbb-5a38-1819f0ebeefb@redhat.com> Date: Wed, 5 Jul 2023 19:08:05 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 1/5] Move relation discovery into compute_operand_range X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.8 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, T_SCC_BODY_TEXT_LINE 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" This is a set of 5 patches which cleans up GORIs compute_operand routines. This is the mechanism GORI uses to calculate ranges from the bottom of the routine back thru definitions in the block to the name that is requested. Currently, compute_operand_range() is called on a stmt, and it divides the work based on which operands are used to get back to the requested name.  It calls compute_operand1_range or compute_operand2_range or compute_operand1_and_operand2_range. If the specified name is not on this statement, then a call back to compute_operand_range on the definition statement is made. this means the call chain is recursive, but involves alternating functions.  This patch sets changes the compute_operand1_range and compute_operand2_range to be leaf functions, and then compute_operand_range is still recursive, but has a much smaller stack footprint, and is also becomes a tailcall. I tried removing the recursion, but at this point, removing the recursion is a performance hit :-P   stay tuned on that one. This patch moves some common code for relation discovery from compute_operand[12]range into compute_operand_range. Bootstraps on  x86_64-pc-linux-gnu  with no regressions.  Pushed. Andrew From 290798faef706c335bd346b13771f977ddedb415 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 4 Jul 2023 11:28:52 -0400 Subject: [PATCH 1/6] Move relation discovery into compute_operand_range compute_operand1_range and compute_operand2_range were both doing relation discovery between the 2 operands... move it into a common area. * gimple-range-gori.cc (compute_operand_range): Check for a relation between op1 and op2 and use that instead. (compute_operand1_range): Don't look for a relation override. (compute_operand2_range): Ditto. --- gcc/gimple-range-gori.cc | 42 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 4ee0ae36014..b0d13a8ac53 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -623,6 +623,18 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, tree op1 = gimple_range_ssa_p (handler.operand1 ()); tree op2 = gimple_range_ssa_p (handler.operand2 ()); + // If there is a relation betwen op1 and op2, use it instead as it is + // likely to be more applicable. + if (op1 && op2) + { + relation_kind k = handler.op1_op2_relation (lhs); + if (k != VREL_VARYING) + { + vrel.set_relation (k, op1, op2); + vrel_ptr = &vrel; + } + } + // Handle end of lookup first. if (op1 == name) return compute_operand1_range (r, handler, lhs, name, src, vrel_ptr); @@ -1079,7 +1091,6 @@ gori_compute::compute_operand1_range (vrange &r, const vrange &lhs, tree name, fur_source &src, value_relation *rel) { - value_relation local_rel; gimple *stmt = handler.stmt (); tree op1 = handler.operand1 (); tree op2 = handler.operand2 (); @@ -1088,7 +1099,6 @@ gori_compute::compute_operand1_range (vrange &r, relation_trio trio; if (rel) trio = rel->create_trio (lhs_name, op1, op2); - relation_kind op_op = trio.op1_op2 (); Value_Range op1_range (TREE_TYPE (op1)); Value_Range tmp (TREE_TYPE (op1)); @@ -1102,19 +1112,7 @@ gori_compute::compute_operand1_range (vrange &r, { src.get_operand (op2_range, op2); - // If there is a relation betwen op1 and op2, use it instead. - // This allows multiple relations to be processed in compound logicals. - if (gimple_range_ssa_p (op1) && gimple_range_ssa_p (op2)) - { - relation_kind k = handler.op1_op2_relation (lhs); - if (k != VREL_VARYING) - { - op_op = k; - local_rel.set_relation (op_op, op1, op2); - rel = &local_rel; - } - } - + relation_kind op_op = trio.op1_op2 (); if (op_op != VREL_VARYING) refine_using_relation (op1, op1_range, op2, op2_range, src, op_op); @@ -1189,7 +1187,6 @@ gori_compute::compute_operand2_range (vrange &r, const vrange &lhs, tree name, fur_source &src, value_relation *rel) { - value_relation local_rel; gimple *stmt = handler.stmt (); tree op1 = handler.operand1 (); tree op2 = handler.operand2 (); @@ -1207,19 +1204,6 @@ gori_compute::compute_operand2_range (vrange &r, trio = rel->create_trio (lhs_name, op1, op2); relation_kind op_op = trio.op1_op2 (); - // If there is a relation betwen op1 and op2, use it instead. - // This allows multiple relations to be processed in compound logicals. - if (gimple_range_ssa_p (op1) && gimple_range_ssa_p (op2)) - { - relation_kind k = handler.op1_op2_relation (lhs); - if (k != VREL_VARYING) - { - op_op = k; - local_rel.set_relation (op_op, op1, op2); - rel = &local_rel; - } - } - if (op_op != VREL_VARYING) refine_using_relation (op1, op1_range, op2, op2_range, src, op_op); -- 2.40.1