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