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: 116459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2191492vqx; Wed, 5 Jul 2023 16:09:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGUBzQHJToYRWzAZqw5lg6jqct72C3bNnqRkHXdqIUMjE/kuwTNS1kxeMskBX2vyxpXDd5J X-Received: by 2002:a17:906:779d:b0:993:28eb:fc04 with SMTP id s29-20020a170906779d00b0099328ebfc04mr142953ejm.20.1688598580893; Wed, 05 Jul 2023 16:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688598580; cv=none; d=google.com; s=arc-20160816; b=lscK2UTrCfAyeW3sQ+08Uj4ksV0PkKLAiLF57E0ouf1hzjMIb/LW4BrRzrH3Jva/i2 rbmABAxHrI8HZvchaNHBthdErg1itxrtfsOiTikDaUXbZK55dkiYO1rgwkpT8HHvXY3M ilcf4eg+ZbphQXQJ7u0MPU8kQd/ZSALWBHRsMklAsHdlulk1BqhOXbnYOhfLqftFxsh3 0lw8UvCvaXEGH6QvDGpLFq9pqPcsQA1fDoGhiAFXLWnmuaxFLVADUISHoGIqN1oRCSfX P86rDz6ZOO+PB+IgncXkhsQXXy++qBnrePOOSL06WSnadN4uBYmgYxXnAUHckh2pAaJq eRog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=EPkl7xEevOpAyF7lXDfjU8a6EV7Fq1IFQohado4Cb/0=; fh=gclC9oA2esmCBAay1qQbUaUwD9iqJFz6H0IpB4Uz3uA=; b=cLvq4yIfulnE4FW3EM+w1rOYCcnRtPuKGV3Nwygw+0Jb0F9S5QLq4g5cfA4n9dLRv5 4CLA+ZsVMAlKyff2hqz/44gSGRV2UVj2lw0h+nOtA54CFUQTKwEVtveKxS+CJ0c+2Eko rqABNQzqOlpOfHgrFT4QCPonjkIMI/RCiyjTW/P1nmfSvllvrs2/g6+W0kcse0S52WSH xfaBJQv3px3Q0z/OkMVq7ZmUmXAIFbSDOiD4l7VJRzLqPKln8ddVFoDshgikhx7Yq5ka fOo9/G5XMZ+DXlF3mCbs0+BNZ/0eKO6M2r/Y4Mfzrulno4qVUMzUfgiDp3ww+mo5Sxa/ 9OmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BSa4Sw2l; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g14-20020a1709064e4e00b00992f309cfe9si72471ejw.598.2023.07.05.16.09.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 16:09:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BSa4Sw2l; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0583F385DC1A for ; Wed, 5 Jul 2023 23:09:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0583F385DC1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598545; 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=BSa4Sw2lPFocNFtn8Hoipjl4p524on+ZTVmUvrTUCYwMKVxwdYgRC+vBRMxBhRTR4 hczXnckSctoPjeneYPIyhozhRp95HmVoDntnN+xtOA2LT/xgNyd/Ku5fEeSQJeS+IK xoYIbQyPfetbUa+F62zqSnPaYCK14OQC1+XsFgjg= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770623945428148628?= X-GMAIL-MSGID: =?utf-8?q?1770623945428148628?= 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