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 From patchwork Wed Jul 5 23:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 116458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2191481vqx; Wed, 5 Jul 2023 16:09:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEKDAI9NDJpvipv2p+OU5vyY5M3SHQhHxKlxrk3FIKDhzEtpbRn+EjDUbIheg4uwhMJAFbn X-Received: by 2002:a2e:3206:0:b0:2b6:e159:2c3e with SMTP id y6-20020a2e3206000000b002b6e1592c3emr94845ljy.33.1688598578694; Wed, 05 Jul 2023 16:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688598578; cv=none; d=google.com; s=arc-20160816; b=lPp7xd0p32Qqgj4AxcE59qf+z6BGXr5k5EMtVLDh8bBIdNSuTC3zXLWVFGjtKydK5n a4bXfYBimo2i+fBWrh/MMu7+fpqUtAG2mymsVeZR1e1DuSERYO8TKmqy5/eB74o8MVYx wx483Nj4/0WIMQSrx3oTprySrC8tWy4IKPpGz8KQjvCaGE+kQH+P9UkPbtohMr3qiF39 kjnOINkdP4LPmQqyMScFKNhXjC3WBQPFW4YXm1Zt/Zlx9m5MPa5+F9KkQV4c4zJ1ovAq CpxEETU3p9dJiEdr//QW2/FgeyJhMHpgnPjTMf5WRSx3ieD6cueFa6kWNmwoLv3O3mcw pCeQ== 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=INy+ORYWLhSi1lXdYTgN9NGeC2DsFafks3m5Zo0Ewho=; fh=gclC9oA2esmCBAay1qQbUaUwD9iqJFz6H0IpB4Uz3uA=; b=Mg2cKFMW+65gF3TLbGE28deLYlWDs6tDDTLIRPBtojg6ydaccwOat6Ugw0sNqqGcM1 Lbl8rr2RhC92CDwZAtUc/oyNXTFKAaGmHhTWNADY00T1oepgaxo5YUL8327Be5/Nfss7 kuzS3fR3ALZzs2jWXTM1JLMHKUha6QW5+t+fxfHfdcy5Xpdd8td2xUuzXCIOCWAb7gzL KCsR82wZVN240KMpbp739+vaUqRvkMDBzJrlPT7RDtEkS/5u13Bt3PVIJW9DcSOOQr6C TWcToNTIaW7l13+6EnzsM6PGRcdny1rEnVQb7x1FpDbI9FL9r+4+uRDuowMEQDIF573A rnXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=L9ed0jux; 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 j13-20020a170906094d00b009931cbba978si93851ejd.6.2023.07.05.16.09.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 16:09:38 -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=L9ed0jux; 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 2CD703850216 for ; Wed, 5 Jul 2023 23:09:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CD703850216 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598544; bh=INy+ORYWLhSi1lXdYTgN9NGeC2DsFafks3m5Zo0Ewho=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=L9ed0juxrzf45b3yhJCMD3t0EjlRXwDaU2MFs1ieYXwJhmhoMJ8Xrwoubu/3ZMAI1 ilR+FT8DklJPwaPm9TkERkM235sYYkXBW4vezigKUpt0O+efawM0wWvOJfr3+nOdDS Mzw9lEmD3W7M6/nBjAOvJlvjErfo8F/xYBuwpc9Y= 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 D7F603856951 for ; Wed, 5 Jul 2023 23:08:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7F603856951 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-_uLUdtd9MUGKV41WzrZgcA-1; Wed, 05 Jul 2023 19:08:17 -0400 X-MC-Unique: _uLUdtd9MUGKV41WzrZgcA-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6b754fb0220so49236a34.2 for ; Wed, 05 Jul 2023 16:08:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688598496; x=1691190496; 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=EFRxYldvzk/yNEcnw6nSgOO/dO+b5mRGRDcnCLnuxzY=; b=gQReU8yfvEPZYg7dEb5+MMU5zwAH7x+bedWBtMtE3h+bhxuete+TJkm8IuRoHoPwJ3 5txg5m6jf//QgRqOKf7D/8JBSx9+887fBwvVofm+LNJui+qPTECT/PScR00e9wh+tFDg 3q6gjMeT4ZkQ3VTMDYwDpgbDtZNwAzv+UhiGV09t34bV8tDFY6PfltjLLQ2ks0IL9uN9 gMcX8NbOz7zzQatx2MI3FfnqF5vxXR9JYPHUAOQiiRr9YC8+S96yynoSBVUO6Wf/c2ZQ fRbOlj03dfCpgeXkuN4q/fYO9067lBDc35FzN1aqOv261i5ZUA1nK6egprcJss7KvHQf 3hkA== X-Gm-Message-State: ABy/qLaETo0qUyaHK1Xay5nlyqfggC8Njmvx73HHW28MHNuVAwdOf3YC OkUVbUiPUHSYWTvUF4BnhKwmGx8Nzu4qpqsG0fSpVMmysPtfZUfiqwyGxD57aqFH9SG45Jf1t6j DDMODhmke28fETREPpJiQORkiQPu6CV7P/ASZ6u2B+6rogzFUbYh2xyKDGx+7m82TK51cMi7RML Tnmw== X-Received: by 2002:a05:6358:706:b0:134:d4c3:c47d with SMTP id e6-20020a056358070600b00134d4c3c47dmr255881rwj.6.1688598495840; Wed, 05 Jul 2023 16:08:15 -0700 (PDT) X-Received: by 2002:a05:6358:706:b0:134:d4c3:c47d with SMTP id e6-20020a056358070600b00134d4c3c47dmr255866rwj.6.1688598495462; Wed, 05 Jul 2023 16:08:15 -0700 (PDT) Received: from [192.168.0.174] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id d26-20020a05620a137a00b0076719d9baeesm128641qkl.113.2023.07.05.16.08.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 16:08:15 -0700 (PDT) Message-ID: Date: Wed, 5 Jul 2023 19:08:14 -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 2/5] Simplify compute_operand_range for op1 and op2 case. 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?1770623942885504859?= X-GMAIL-MSGID: =?utf-8?q?1770623942885504859?= This patch simplifies compute_operand1_and_operand2() such that it only calls each routine one. This will simplify the next couple of patches. It also allows moves the determination that op1 and op2 have an interdependence to  compute_operand_range(). Bootstraps on  x86_64-pc-linux-gnu  with no regressions.  Pushed. Andrew From 7276248946d3eae83e5e08fc023163614c9ea9ab Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 5 Jul 2023 13:36:27 -0400 Subject: [PATCH 2/6] Simplify compute_operand_range for op1 and op2 case. Move the check for co-dependency between 2 operands into compute_operand_range, resulting in a much cleaner compute_operand1_and_operand2_range routine. * gimple-range-gori.cc (compute_operand_range): Check for operand interdependence when both op1 and op2 are computed. (compute_operand1_and_operand2_range): No checks required now. --- gcc/gimple-range-gori.cc | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index b0d13a8ac53..5429c6e3c1a 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -650,6 +650,17 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, if (!op1_in_chain && !op2_in_chain) return false; + // If either operand is in the def chain of the other (or they are equal), it + // will be evaluated twice and can result in an exponential time calculation. + // Instead just evaluate the one operand. + if (op1_in_chain && op2_in_chain) + { + if (in_chain_p (op1, op2) || op1 == op2) + op1_in_chain = false; + else if (in_chain_p (op2, op1)) + op2_in_chain = false; + } + bool res = false; // If the lhs doesn't tell us anything only a relation can possibly enhance // the result. @@ -1275,24 +1286,10 @@ gori_compute::compute_operand1_and_operand2_range (vrange &r, { Value_Range op_range (TREE_TYPE (name)); - // If op1 is in the def chain of op2, we'll do the work twice to evalaute - // op1. This can result in an exponential time calculation. - // Instead just evaluate op2, which will eventualy get to op1. - if (in_chain_p (handler.operand1 (), handler.operand2 ())) - return compute_operand2_range (r, handler, lhs, name, src, rel); - - // Likewise if op2 is in the def chain of op1. - if (in_chain_p (handler.operand2 (), handler.operand1 ())) - return compute_operand1_range (r, handler, lhs, name, src, rel); - // Calculate a good a range through op2. if (!compute_operand2_range (r, handler, lhs, name, src, rel)) return false; - // If op1 == op2 there is again no need to go further. - if (handler.operand1 () == handler.operand2 ()) - return true; - // Now get the range thru op1. if (!compute_operand1_range (op_range, handler, lhs, name, src, rel)) return false; -- 2.40.1 From patchwork Wed Jul 5 23:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 116460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2191651vqx; Wed, 5 Jul 2023 16:09:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlF0AajM/Ib3t2LJMHANFr+5WSKs+29x6yd+QgUah9Jz4fXVRQkfDiQx0nN3Z6ODjwJL6ZoY X-Received: by 2002:a17:907:2916:b0:991:d9cb:247d with SMTP id eq22-20020a170907291600b00991d9cb247dmr56878ejc.57.1688598597013; Wed, 05 Jul 2023 16:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688598597; cv=none; d=google.com; s=arc-20160816; b=tdizXOJzIWRCe5aRf100aKpklUVYcW5GH0y4PyrqDNCkxzrrM+eWd5jabbkRALvZkQ RCEKgUlcX+crLZ4l90p2tINyu6kduhC4ZO3ef4AzM3A8bIc30KaTMv7nOJPj52+++Kbw DRbeWCkvLB4EiHWhuvzcnaflYCBGCDpx+iavyPEtMhkSq539Rk9iqkL7o1LeibePhtIq nPUVjLfTHLLuzsJIrT6eDmaGCNgbzxkSCZLuKxSuOJk5zptaX5C5aKIPCuhQzDwCZI7s 0e3IOvSFyRtrw8W2W3pHb1QfOQNpscATIJM+Bnqj31dxYKHQsjzD0pVyLb6KwbUlGx6i p3wA== 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=zqvod4wm82WLLcILuxy03DymOd6MxSpXSljKZQBVR4U=; fh=gclC9oA2esmCBAay1qQbUaUwD9iqJFz6H0IpB4Uz3uA=; b=fe6yfXgRbgMnPg9KR5DR63naY24dtnnh7RBIaiqhMo4CDCVXOyDCLWje+IYQ7L44u+ gipOlaiGIwRyuSOQUwnG2ySpaPkSbzKIscY4qd8Yv9Hm1ol0aS+NXn1F+YPWXwElbXhX eeW5qGW3ncm9lhTYyNHXsO+5vseCaUFwWo7YhwKHfWYqgDi1/JxXT4ONB3IeC2NFQVkU NGsPfjO0a9rRk3PRn+TPUNCPPLmng6Y3DzI3tHQwfkg5gXQRdvDOAle1gUHj9NkanHnJ acVe17SSiUYTdiKk9e3340owjQApGiKcLRK9TG0yoET1fqMjt8/FNUi4ezVWIuye5kJu Bz9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="tV7/nWpE"; 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 y12-20020a1709063a8c00b00992ee6da875si86601ejd.218.2023.07.05.16.09.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 16:09:57 -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="tV7/nWpE"; 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 A7AB5386CE47 for ; Wed, 5 Jul 2023 23:09:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7AB5386CE47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598551; bh=zqvod4wm82WLLcILuxy03DymOd6MxSpXSljKZQBVR4U=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=tV7/nWpEgsvSrIyI7r0tvOKx6Ni+mY1tV/FpjqdDrC6vzgYv9B5m9GOGokZwu6wUz A+TUaYU2f1rgGNGd+hd5r+JNisIn0+ScOrcb9fYtAK822BbRXPdN08gS/Tl5Pxy2rV RowgP+ctKlOhthIhe/QYDNY4zSXXMx5liXdv1p/U= 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 93F0F385559E for ; Wed, 5 Jul 2023 23:08:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93F0F385559E Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-218-j57-KMlkMv2B-_0TiFtLUA-1; Wed, 05 Jul 2023 19:08:24 -0400 X-MC-Unique: j57-KMlkMv2B-_0TiFtLUA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-635f12395b5so1854176d6.3 for ; Wed, 05 Jul 2023 16:08:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688598503; x=1691190503; 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=tR900KqOYrJcWGW1CHoWgGSfgJbKW5cm7EsI4p6IiNo=; b=VjJ+fnRxJOKnpTgSHObyqj6PGgLgYHRNguLk534gms11Mx6cEUEBcdCOEJMgHTztKp CMkTa85Eo5TkajySzVNyI/B8Xv/AjKi4unHCSvMqaoG6cXx0cr4r54tHhsiLWePJo4Od hkq4lWcZpzOuE5RqOroVxstSwuycrCr575Hmz2TQWLZduKThhAMObVGGoPhlQZDIJw7/ 1LmBplfd9n35d9mvZwWXe0cTMwFKgdPs9PD+Lr8M88TqYmKLtARi1YUuiEbYo9E1V7R5 p11AHVgMRto3cmh7MhbGJ3Gs6movzAoCMG7tuZCkx5qIKPTqI0p66aePV2Fd+QX3OoOC nGaw== X-Gm-Message-State: ABy/qLbY5Dj/QEPQz7z6LelwaRqp9WlYCpEQ4SLnX1AGmvqyI1J4NEBw oVFOT3kgRZ995Ez7b+Kbx1UDcTyr3N9w6Yw3BQanVVSuFxgYow+IpEWu4HKVdmJUUJtPT93V+GX CDWu/pZ5CAXPb/StR78yCxJHdaFieezfK5g8l2SEAP3KeZaLz2AuMYk6VQtdXofkqOfz9IIphF5 fKYA== X-Received: by 2002:a0c:ac0e:0:b0:619:4232:aa87 with SMTP id l14-20020a0cac0e000000b006194232aa87mr32596qvb.24.1688598503793; Wed, 05 Jul 2023 16:08:23 -0700 (PDT) X-Received: by 2002:a0c:ac0e:0:b0:619:4232:aa87 with SMTP id l14-20020a0cac0e000000b006194232aa87mr32581qvb.24.1688598503444; Wed, 05 Jul 2023 16:08:23 -0700 (PDT) Received: from [192.168.0.174] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id i4-20020a0cf484000000b0063013c621fasm53245qvm.68.2023.07.05.16.08.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 16:08:23 -0700 (PDT) Message-ID: <74df7fe5-ddc7-f200-78e9-8ce72f17b88b@redhat.com> Date: Wed, 5 Jul 2023 19:08:21 -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 3/5] Make compute_operand1_range a leaf call. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.9 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?1770623962542294556?= X-GMAIL-MSGID: =?utf-8?q?1770623962542294556?= now operand1 alone is resolved, and returned as the result.  much cleaner, and removes it from the recursion stack. compute_operand_range() will decide if further evaluation is required. Bootstraps on  x86_64-pc-linux-gnu  with no regressions.  Pushed. Andrew From 912b5ac49677160aada7a2d862273251406dfca5 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 5 Jul 2023 13:41:50 -0400 Subject: [PATCH 3/6] Make compute_operand1_range a leaf call. Rather than creating long call chains, put the onus for finishing the evlaution on the caller. * gimple-range-gori.cc (compute_operand_range): After calling compute_operand1_range, recursively call self if needed. (compute_operand1_range): Turn into a leaf function. (gori_compute::compute_operand1_and_operand2_range): Finish operand1 calculation. * gimple-range-gori.h (compute_operand1_range): Remove name param. --- gcc/gimple-range-gori.cc | 49 ++++++++++++++++++++-------------------- gcc/gimple-range-gori.h | 2 +- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 5429c6e3c1a..b66b9b0398c 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -637,7 +637,7 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, // Handle end of lookup first. if (op1 == name) - return compute_operand1_range (r, handler, lhs, name, src, vrel_ptr); + return compute_operand1_range (r, handler, lhs, src, vrel_ptr); if (op2 == name) return compute_operand2_range (r, handler, lhs, name, src, vrel_ptr); @@ -731,7 +731,15 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, res = compute_operand1_and_operand2_range (r, handler, lhs, name, src, vrel_ptr); else if (op1_in_chain) - res = compute_operand1_range (r, handler, lhs, name, src, vrel_ptr); + { + Value_Range vr (TREE_TYPE (op1)); + if (!compute_operand1_range (vr, handler, lhs, src, vrel_ptr)) + return false; + gimple *src_stmt = SSA_NAME_DEF_STMT (op1); + gcc_checking_assert (src_stmt); + // Then feed this range back as the LHS of the defining statement. + return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); + } else if (op2_in_chain) res = compute_operand2_range (r, handler, lhs, name, src, vrel_ptr); else @@ -1099,7 +1107,7 @@ gori_compute::refine_using_relation (tree op1, vrange &op1_range, bool gori_compute::compute_operand1_range (vrange &r, gimple_range_op_handler &handler, - const vrange &lhs, tree name, + const vrange &lhs, fur_source &src, value_relation *rel) { gimple *stmt = handler.stmt (); @@ -1112,7 +1120,6 @@ gori_compute::compute_operand1_range (vrange &r, trio = rel->create_trio (lhs_name, op1, op2); Value_Range op1_range (TREE_TYPE (op1)); - Value_Range tmp (TREE_TYPE (op1)); Value_Range op2_range (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1)); // Fetch the known range for op1 in this block. @@ -1130,7 +1137,7 @@ gori_compute::compute_operand1_range (vrange &r, // If op1 == op2, create a new trio for just this call. if (op1 == op2 && gimple_range_ssa_p (op1)) trio = relation_trio (trio.lhs_op1 (), trio.lhs_op2 (), VREL_EQ); - if (!handler.calc_op1 (tmp, lhs, op2_range, trio)) + if (!handler.calc_op1 (r, lhs, op2_range, trio)) return false; } else @@ -1138,7 +1145,7 @@ gori_compute::compute_operand1_range (vrange &r, // We pass op1_range to the unary operation. Normally it's a // hidden range_for_type parameter, but sometimes having the // actual range can result in better information. - if (!handler.calc_op1 (tmp, lhs, op1_range, trio)) + if (!handler.calc_op1 (r, lhs, op1_range, trio)) return false; } @@ -1161,30 +1168,16 @@ gori_compute::compute_operand1_range (vrange &r, tracer.print (idx, "Computes "); print_generic_expr (dump_file, op1, TDF_SLIM); fprintf (dump_file, " = "); - tmp.dump (dump_file); + r.dump (dump_file); fprintf (dump_file, " intersect Known range : "); op1_range.dump (dump_file); fputc ('\n', dump_file); } - // Intersect the calculated result with the known result and return if done. - if (op1 == name) - { - tmp.intersect (op1_range); - r = tmp; - if (idx) - tracer.trailer (idx, "produces ", true, name, r); - return true; - } - // If the calculation continues, we're using op1_range as the new LHS. - op1_range.intersect (tmp); + r.intersect (op1_range); if (idx) - tracer.trailer (idx, "produces ", true, op1, op1_range); - gimple *src_stmt = SSA_NAME_DEF_STMT (op1); - gcc_checking_assert (src_stmt); - - // Then feed this range back as the LHS of the defining statement. - return compute_operand_range (r, src_stmt, op1_range, name, src, rel); + tracer.trailer (idx, "produces ", true, op1, r); + return true; } @@ -1291,7 +1284,13 @@ gori_compute::compute_operand1_and_operand2_range (vrange &r, return false; // Now get the range thru op1. - if (!compute_operand1_range (op_range, handler, lhs, name, src, rel)) + Value_Range vr (TREE_TYPE (handler.operand1 ())); + if (!compute_operand1_range (vr, handler, lhs, src, rel)) + return false; + gimple *src_stmt = SSA_NAME_DEF_STMT (handler.operand1 ()); + gcc_checking_assert (src_stmt); + // Then feed this range back as the LHS of the defining statement. + if (!compute_operand_range (op_range, src_stmt, vr, name, src, rel)) return false; // Both operands have to be simultaneously true, so perform an intersection. diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h index 526edc24b53..1d451fa7e9a 100644 --- a/gcc/gimple-range-gori.h +++ b/gcc/gimple-range-gori.h @@ -183,7 +183,7 @@ private: bool compute_operand_range_switch (vrange &r, gswitch *s, const vrange &lhs, tree name, fur_source &src); bool compute_operand1_range (vrange &r, gimple_range_op_handler &handler, - const vrange &lhs, tree name, fur_source &src, + const vrange &lhs, fur_source &src, value_relation *rel = NULL); bool compute_operand2_range (vrange &r, gimple_range_op_handler &handler, const vrange &lhs, tree name, fur_source &src, -- 2.40.1 From patchwork Wed Jul 5 23:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 116461 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2192148vqx; Wed, 5 Jul 2023 16:10:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlE7HL+ZbDxifByHmVOLyfnvoki+WajBwzj63BCbvRHkC6ulPIFDam2P7ijLuur47KCPM8VX X-Received: by 2002:a05:6402:710:b0:51d:ad2b:3700 with SMTP id w16-20020a056402071000b0051dad2b3700mr333518edx.26.1688598659127; Wed, 05 Jul 2023 16:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688598659; cv=none; d=google.com; s=arc-20160816; b=DrQwdgr7oq+nGwKvwS/5cBORKDq8PJ1TGVMLefgjhSKVYnOnEoWGv6MPP45c4Godsn GKqX6jRy3z8Fp8eDxdwTRkBanQur708kYC+i9ebcxBKR/dbbsMOhJoj49ZeS/q3C1hlf 7np4kBHHPEjtWkOP8rFx0SLMlipIQEY4EpAa5IFgIc/JgQ4Vc/zQH3TXaHzKOqoQW6Ds gi4xCsSA4+Ikn5YTI/W1KqLKA6oswaoV5bMBtIr0avjLdrXOasfwV6wDRWd6kirA05Kq KYl0nplHiMVQsu2TlasSXSQcj4GWn7oB5uGvRAmYn8hbGw+0uVjL3SUpnxUxverxwWYk U7KA== 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=PTPnEV+N8O6JdBVxKlJlzBh4t+qx6seP0+it3YRkFAE=; fh=gclC9oA2esmCBAay1qQbUaUwD9iqJFz6H0IpB4Uz3uA=; b=ngKXG+VMt16GW+/E8VjehPcEfnUI52MEmGUSDqeFf6OXmNf2Ozcff5AdIvGPniJ0ZR 5xtA0p7jSvNLMqxHmTErIxSMzhr+elDc9QBUsba5FJyTh2mYM1nn8zHBpPNWY8I+cKeJ 1iMqgh7VY+Ub9WpHPvAiwTV8H+oyUojat/5pmGFzEyXx1LuHox933CK2q9ASD4jsajWD 6gvrbLshwTSHGsaCFPQRImrv+jZgx7+8iWyh4dRmYDhCCmoH53pBknlmPDUE/U8Vy/s9 Pzy27D5LWYC0VWCYktym4kc7hkUluSlYMox/Ki2+BzmpEo3eD/sXm8DFFrXg7mzfmkIq ifUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mu9luSA1; 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=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o13-20020aa7c50d000000b00518c6e070f8si107818edq.663.2023.07.05.16.10.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 16:10:59 -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=@gcc.gnu.org header.s=default header.b=mu9luSA1; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5C36386EC0F for ; Wed, 5 Jul 2023 23:10:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5C36386EC0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598607; bh=PTPnEV+N8O6JdBVxKlJlzBh4t+qx6seP0+it3YRkFAE=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=mu9luSA1sml0uNNrNyv+rr2mI6kfgBBVrV0sB6HgMA4dcgxGccw2Z4f3nYrf9gRFx kwA0kn+t6B0yRxkjeYlIPnRi5EiOO8YPD9r7T5jga++hgA2wVxfWwLgRXnK2yz9yZ5 014bnNBUJDdZoNGHxUwrI46qnKvFtlEACp8dSuUk= 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 09D3F385C8B1 for ; Wed, 5 Jul 2023 23:08:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09D3F385C8B1 Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-209-EEehNrJhPgG3xULLZoIH0Q-1; Wed, 05 Jul 2023 19:08:32 -0400 X-MC-Unique: EEehNrJhPgG3xULLZoIH0Q-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-791ba72ab57so26922241.1 for ; Wed, 05 Jul 2023 16:08:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688598511; x=1691190511; 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=6PNAvqI1q1ZoEOKlHwGxg/0JuwqNgkcFJZRkx78Yk8w=; b=aTqPdrADIdp2gjmZPZhvC+SqsoxYCkfjGXoCCdoLEHYtLDu9/xAvotZcmyfBkOKH2t CwzrpKuBoSXcBcOMu31jzxjbxecL8icvTWLBa0JZhfb+Az08JQSo+GRvw+dAA1PDOiqD jnL/XgfgKTYq7IfS/R88HGXJ1NPfoPRh2kpoA6FsfuaWKgjZbbNnNwc7FUIq4SziQQTk 2NTsqDcBlzPeOzZIVtAZfw4UQ3JdE6ZudVaBsCvcVisw2D+tckYKJJoWq2bM9DUczpuk H00vCr7xHS8TJl4LqFzKWh+dUcFexeSaVTrXxUn+sIEj5M8PPhXk7b6CPeXSf0+7fo1u gm4Q== X-Gm-Message-State: ABy/qLZLOak7Pl1B9/WXgVQfFchcPempWfWLWih+9IhalawKjg7KVJ4v beXtSvgHHLj55lWQyK1vu/ycHdv/0mAPQCvYSQeYd9UGVgmdPEmgKymocEUWsk6T+kW0fuqNkVP 7yTo2JuaupH/j79BZnEgoNpu7XeWi4Frl9TpTZVvUyJDZ2RJQXyOZnQ78Ljfqn5fvQOmmqHRbIr jltQ== X-Received: by 2002:a05:6102:300c:b0:440:c0dd:e7f7 with SMTP id s12-20020a056102300c00b00440c0dde7f7mr436578vsa.4.1688598510974; Wed, 05 Jul 2023 16:08:30 -0700 (PDT) X-Received: by 2002:a05:6102:300c:b0:440:c0dd:e7f7 with SMTP id s12-20020a056102300c00b00440c0dde7f7mr436567vsa.4.1688598510695; Wed, 05 Jul 2023 16:08:30 -0700 (PDT) Received: from [192.168.0.174] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id m20-20020a0cdb94000000b00636e767d445sm53721qvk.62.2023.07.05.16.08.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 16:08:30 -0700 (PDT) Message-ID: Date: Wed, 5 Jul 2023 19:08:29 -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 4/5] Make compute_operand2_range a leaf call. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.9 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?1770624027788945024?= X-GMAIL-MSGID: =?utf-8?q?1770624027788945024?= now operand2 alone is resolved, and returned as the result.  much cleaner, and removes it from the recursion stack. compute_operand_range() will decide if further evaluation is required. Bootstraps on  x86_64-pc-linux-gnu  with no regressions.  Pushed. Andrew From 298952bcf05d298892e99adba1f4a75af17bc65a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 5 Jul 2023 13:52:21 -0400 Subject: [PATCH 4/6] Make compute_operand2_range a leaf call. Rather than creating long call chains, put the onus for finishing the evlaution on the caller. * gimple-range-gori.cc (compute_operand_range): After calling compute_operand2_range, recursively call self if needed. (compute_operand2_range): Turn into a leaf function. (gori_compute::compute_operand1_and_operand2_range): Finish operand2 calculation. * gimple-range-gori.h (compute_operand2_range): Remove name param. --- gcc/gimple-range-gori.cc | 52 +++++++++++++++++++--------------------- gcc/gimple-range-gori.h | 2 +- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index b66b9b0398c..b036ed56f02 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -639,7 +639,7 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, if (op1 == name) return compute_operand1_range (r, handler, lhs, src, vrel_ptr); if (op2 == name) - return compute_operand2_range (r, handler, lhs, name, src, vrel_ptr); + return compute_operand2_range (r, handler, lhs, src, vrel_ptr); // NAME is not in this stmt, but one of the names in it ought to be // derived from it. @@ -741,7 +741,15 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); } else if (op2_in_chain) - res = compute_operand2_range (r, handler, lhs, name, src, vrel_ptr); + { + Value_Range vr (TREE_TYPE (op2)); + if (!compute_operand2_range (vr, handler, lhs, src, vrel_ptr)) + return false; + gimple *src_stmt = SSA_NAME_DEF_STMT (op2); + gcc_checking_assert (src_stmt); + // Then feed this range back as the LHS of the defining statement. + return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); + } else gcc_unreachable (); @@ -1188,7 +1196,7 @@ gori_compute::compute_operand1_range (vrange &r, bool gori_compute::compute_operand2_range (vrange &r, gimple_range_op_handler &handler, - const vrange &lhs, tree name, + const vrange &lhs, fur_source &src, value_relation *rel) { gimple *stmt = handler.stmt (); @@ -1198,7 +1206,6 @@ gori_compute::compute_operand2_range (vrange &r, Value_Range op1_range (TREE_TYPE (op1)); Value_Range op2_range (TREE_TYPE (op2)); - Value_Range tmp (TREE_TYPE (op2)); src.get_operand (op1_range, op1); src.get_operand (op2_range, op2); @@ -1215,7 +1222,7 @@ gori_compute::compute_operand2_range (vrange &r, if (op1 == op2 && gimple_range_ssa_p (op1)) trio = relation_trio (trio.lhs_op1 (), trio.lhs_op2 (), VREL_EQ); // Intersect with range for op2 based on lhs and op1. - if (!handler.calc_op2 (tmp, lhs, op1_range, trio)) + if (!handler.calc_op2 (r, lhs, op1_range, trio)) return false; unsigned idx; @@ -1237,31 +1244,16 @@ gori_compute::compute_operand2_range (vrange &r, tracer.print (idx, "Computes "); print_generic_expr (dump_file, op2, TDF_SLIM); fprintf (dump_file, " = "); - tmp.dump (dump_file); + r.dump (dump_file); fprintf (dump_file, " intersect Known range : "); op2_range.dump (dump_file); fputc ('\n', dump_file); } // Intersect the calculated result with the known result and return if done. - if (op2 == name) - { - tmp.intersect (op2_range); - r = tmp; - if (idx) - tracer.trailer (idx, " produces ", true, NULL_TREE, r); - return true; - } - // If the calculation continues, we're using op2_range as the new LHS. - op2_range.intersect (tmp); - + r.intersect (op2_range); if (idx) - tracer.trailer (idx, " produces ", true, op2, op2_range); - gimple *src_stmt = SSA_NAME_DEF_STMT (op2); - gcc_checking_assert (src_stmt); -// gcc_checking_assert (!is_import_p (op2, find.bb)); - - // Then feed this range back as the LHS of the defining statement. - return compute_operand_range (r, src_stmt, op2_range, name, src, rel); + tracer.trailer (idx, " produces ", true, op2, r); + return true; } // Calculate a range for NAME from both operand positions of S @@ -1279,15 +1271,21 @@ gori_compute::compute_operand1_and_operand2_range (vrange &r, { Value_Range op_range (TREE_TYPE (name)); + Value_Range vr (TREE_TYPE (handler.operand2 ())); // Calculate a good a range through op2. - if (!compute_operand2_range (r, handler, lhs, name, src, rel)) + if (!compute_operand2_range (vr, handler, lhs, src, rel)) + return false; + gimple *src_stmt = SSA_NAME_DEF_STMT (handler.operand2 ()); + gcc_checking_assert (src_stmt); + // Then feed this range back as the LHS of the defining statement. + if (!compute_operand_range (r, src_stmt, vr, name, src, rel)) return false; // Now get the range thru op1. - Value_Range vr (TREE_TYPE (handler.operand1 ())); + vr.set_type (TREE_TYPE (handler.operand1 ())); if (!compute_operand1_range (vr, handler, lhs, src, rel)) return false; - gimple *src_stmt = SSA_NAME_DEF_STMT (handler.operand1 ()); + src_stmt = SSA_NAME_DEF_STMT (handler.operand1 ()); gcc_checking_assert (src_stmt); // Then feed this range back as the LHS of the defining statement. if (!compute_operand_range (op_range, src_stmt, vr, name, src, rel)) diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h index 1d451fa7e9a..b8d97d1dd72 100644 --- a/gcc/gimple-range-gori.h +++ b/gcc/gimple-range-gori.h @@ -186,7 +186,7 @@ private: const vrange &lhs, fur_source &src, value_relation *rel = NULL); bool compute_operand2_range (vrange &r, gimple_range_op_handler &handler, - const vrange &lhs, tree name, fur_source &src, + const vrange &lhs, fur_source &src, value_relation *rel = NULL); bool compute_operand1_and_operand2_range (vrange &r, gimple_range_op_handler &handler, -- 2.40.1 From patchwork Wed Jul 5 23:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 116462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2192516vqx; Wed, 5 Jul 2023 16:11:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHQALbUESJ01SmKH9dRGLgjmh2fO0qcS7W7i3j9lCSDm3EIjPdjpsQtLVTqJf7rVjmjqHpj X-Received: by 2002:a17:906:5a72:b0:98e:4b2:2e83 with SMTP id my50-20020a1709065a7200b0098e04b22e83mr71527ejc.50.1688598703892; Wed, 05 Jul 2023 16:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688598703; cv=none; d=google.com; s=arc-20160816; b=oceAXlMPehKZJa86FepgGPj+D78x0JIx60U1bTIak5ADjb5yIl83NoaWIMxarR4BrJ 9gTbzEWi8ugiU5stBM8XqMq7MGMXV8GAKoJO8YRQS08QbGdw4q19Mpj7CtFKrZKhWEUw VZyMcwzhxiFVvdchJGlgXcL3UlEu+sxVmyUsNwcryLQNQv1f085QmgJFvzrIDstTq70i Bkg1kKOoxLd4tirlLiKt1z/UoRHVSTmwsTZFjk8J7wl4IW4uwm2h+vnt7lP8Q5YvIEYm Rq+89BDHvRlfTqaM161r5UNeN6LknafxhFofv9qfiSAHoS04dJeVRjN1Si3ssF3HFFuY e8cg== 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=esF9O8z4LPAAWNT0rezDuNTdTHcpuX/V8Lott8uid4U=; fh=gclC9oA2esmCBAay1qQbUaUwD9iqJFz6H0IpB4Uz3uA=; b=ws4pu3ERY7UZ6qejE6EUtMp9niUvf7pyTM9ozKYU5a2WUeywk/XaJZ7bvNK1zBzIU0 b6gz08fuYg5BVSCWPP/r9EnzifOkNUFLQWEz/ifCu6Rehq5adKaUDooXOToBucGBRvLL fPqSfzR5mHVjkWMaiOY2cW1ZzCWLcNwdkDDHG9n8UwicelxlqrFwLnBspJRg9f3T9o7V jSRBILQUij/wrWeBrdq09lTKTFdUaTXoLy40JU6m00rhVd6eGK5E9SKBgRZqZjiewWso bFxQSLbfOf4vvtxm4iw60Y0TTutVdQFyUy6gJNxa/k/9OaYs++6rJ8FaF+1KlBELrs1Q et0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="nMmh+lZ/"; 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=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dk5-20020a170906f0c500b0098e3e818952si82893ejb.326.2023.07.05.16.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 16:11:43 -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=@gcc.gnu.org header.s=default header.b="nMmh+lZ/"; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE6F53850212 for ; Wed, 5 Jul 2023 23:11:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE6F53850212 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598663; bh=esF9O8z4LPAAWNT0rezDuNTdTHcpuX/V8Lott8uid4U=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nMmh+lZ/QmJyh8ZBswJWqAjxJeXaN1hWawuHFIPObteJ81B1jvSDiTFloZ4QGof/o Ny2LcUEEsGt3Q/GKtkIxPSZnMBjV0q4l8OvcFVBnRe835JBNEr0UvL9QWYDaNQMEZk GxQap2DCXWncUW+PffRAb3q/z6jFLN+RQFA8v0+I= 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 CE277385C8B1 for ; Wed, 5 Jul 2023 23:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE277385C8B1 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-372OkTFIORKOOPHCkyHNyg-1; Wed, 05 Jul 2023 19:08:38 -0400 X-MC-Unique: 372OkTFIORKOOPHCkyHNyg-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-5662c368572so17057eaf.2 for ; Wed, 05 Jul 2023 16:08:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688598516; x=1691190516; 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=k4Jh7CStJJSSZqegirhVH0DugDEpzuXDYP8qZjP5t+0=; b=MJ1Jen+i+m/O5ZDbeHf13P0rNEj9KUlyRAGtPh9gkdxtkqWsmS7PnzySqduIB6k3Sk m6uDgSZLjoDQWhgB+H8mQ0CzjTuv15zVNAnmzFjt/vpNvh38Bx2i+2Ewev9oDkrIvezd x8sdVrlMYQ9AhavEKnFJuCNGA6mBAG0wlsCDeXem8Zvhxsy0dmNJUOEg9eac5LfNnxjM oe9IQxUeNH7BYoiL6uE7qZM+L7q9rba1b/RhVdr855i6mtOc8F3Me8L3VwzJNw0qcbJf 4QeN59RfQyUaOnGSmMQRh2j1jV4OdIbANDCHo7Sdqp/EvVSYCpWKGk7VQ2Fsucght/+Y G9Sw== X-Gm-Message-State: ABy/qLb8gxB6HHmMDG8KKfLwzyUY3FX0JmJ2aIuFBvYwrM1PSqWZhuGP PN9r2rVUmVBXH/xeTKxpbxGWtIZY0gd8sItHtrht0vfLW0rUk5ZJrefbLwccE24TCtQSBSenCWW zTkdlh9x4Ikky0GAr7tdGVGCsfWzeLnGaKuiC3a36pIjIGXtDR7jni4ZrPuTSldz4+ltATzZSfq sP4Q== X-Received: by 2002:a05:6808:1490:b0:39e:c651:b2f1 with SMTP id e16-20020a056808149000b0039ec651b2f1mr40558oiw.2.1688598516815; Wed, 05 Jul 2023 16:08:36 -0700 (PDT) X-Received: by 2002:a05:6808:1490:b0:39e:c651:b2f1 with SMTP id e16-20020a056808149000b0039ec651b2f1mr40540oiw.2.1688598516534; Wed, 05 Jul 2023 16:08:36 -0700 (PDT) Received: from [192.168.0.174] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id s9-20020a0ca609000000b0062de1ed9d15sm45374qva.102.2023.07.05.16.08.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 16:08:36 -0700 (PDT) Message-ID: Date: Wed, 5 Jul 2023 19:08:35 -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 5/5] Make compute_operand_range a tail call. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.9 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?1770624074494768463?= X-GMAIL-MSGID: =?utf-8?q?1770624074494768463?= This simply tweaks cmpute_operand_range a little so the recursion is a tail call. With this, the patchset produces a modest speedup of 0.2% in VRP and 0.4% in threading.  It will also have a much smaller stack profile. Bootstraps on  x86_64-pc-linux-gnu  with no regressions.  Pushed. Andrew From 51ed3a6ce432e7e6226bb62125ef8a09b2ebf60c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 5 Jul 2023 14:26:00 -0400 Subject: [PATCH 5/6] Make compute_operand_range a tail call. Tweak the routine so it is making a tail call. * gimple-range-gori.cc (compute_operand_range): Convert to a tail call. --- gcc/gimple-range-gori.cc | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index b036ed56f02..6dc15a0ce3f 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -725,36 +725,34 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, op1_trange, op1_frange, op2_trange, op2_frange); if (idx) tracer.trailer (idx, "compute_operand", res, name, r); + return res; } // Follow the appropriate operands now. - else if (op1_in_chain && op2_in_chain) - res = compute_operand1_and_operand2_range (r, handler, lhs, name, src, - vrel_ptr); - else if (op1_in_chain) + if (op1_in_chain && op2_in_chain) + return compute_operand1_and_operand2_range (r, handler, lhs, name, src, + vrel_ptr); + Value_Range vr; + gimple *src_stmt; + if (op1_in_chain) { - Value_Range vr (TREE_TYPE (op1)); + vr.set_type (TREE_TYPE (op1)); if (!compute_operand1_range (vr, handler, lhs, src, vrel_ptr)) return false; - gimple *src_stmt = SSA_NAME_DEF_STMT (op1); - gcc_checking_assert (src_stmt); - // Then feed this range back as the LHS of the defining statement. - return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); + src_stmt = SSA_NAME_DEF_STMT (op1); } - else if (op2_in_chain) + else { - Value_Range vr (TREE_TYPE (op2)); + gcc_checking_assert (op2_in_chain); + vr.set_type (TREE_TYPE (op2)); if (!compute_operand2_range (vr, handler, lhs, src, vrel_ptr)) return false; - gimple *src_stmt = SSA_NAME_DEF_STMT (op2); - gcc_checking_assert (src_stmt); - // Then feed this range back as the LHS of the defining statement. - return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); + src_stmt = SSA_NAME_DEF_STMT (op2); } - else - gcc_unreachable (); + gcc_checking_assert (src_stmt); + // Then feed this range back as the LHS of the defining statement. + return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); // If neither operand is derived, this statement tells us nothing. - return res; } -- 2.40.1