From patchwork Mon Jul 18 20:02:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 45 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2049852eik; Mon, 18 Jul 2022 13:03:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tqiLtrBNaBE39I9x6mvl3nCh4MPuqLF3FWApiHmc3eBTJAdeeMpnUCJYz5sepn16sXabKJ X-Received: by 2002:a17:907:6296:b0:72b:50c8:c6f8 with SMTP id nd22-20020a170907629600b0072b50c8c6f8mr26992976ejc.318.1658174604733; Mon, 18 Jul 2022 13:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658174604; cv=none; d=google.com; s=arc-20160816; b=KwhJ+OLsmX6I9GPGN3UX8DkJf4dIP6kglOQaeG6v/Wx6J4U7XhOyaWVBzHPy6QC4ZA dYwcVUAqRqUcx4hBCh9yBv2ViJbA5AhI5O5ErDNuyJMi+KldGRybSWukeZBS4G8nSxd7 tQdKS3Q+XasP79RxTUTPotR9DRu8Nue+ClKXVnMqwum8edsRhj4mDPSb1mDkGdNeLee/ bIb8wBa6t9x0jxAAfrtWLeKamo4f5x85NQVHvXcI2E87yyq5PQP1rouLutlHp/aSD6pE 0rWUJbGotEnt+KfAZsIlfSp3E3Ccfp+QESW2Auw4SSfZQO7mPftZgFrBA8aT1NjoEG/N DaWQ== 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 :to:subject:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Y1MbawuQP6YhmQMVTUIsw7pEqngLh6gC/Q0M/eqDFyA=; b=HlXU17BEbdrVxkyztaz6SdvDcXQajsX3EITwAXrX2TSVFUMy958K23rDPuchtOkiFx g0TIlkjmU2gbMOUtnw+5363juIMoZ5r+bVkzomF4+fryUOjaCyTQHlgcb6PRHuNf/4Yc 3Jk2ja408ebFA6dpd6qFo1KTiSMPZ+MCim7mnPpuplQrbLEQfNO3quFvaynTlT98EN0h hAqoaAcmk2NpxI73RSCLbUMdysg9x1Y4YyLJxunU6WK7sBlUpIuVixCp6IBuOka/28q8 csjuDW1cL/IX+lOGXcI84ishCo30OHNVUImcOroFOBQ8OyT4n5WZLBp4ttVOfC68s1LR S1BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=c9Ha1RuD; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u16-20020aa7d0d0000000b004358c3bfb61si13563953edo.141.2022.07.18.13.03.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 13:03:24 -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=c9Ha1RuD; 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 832973851C02 for ; Mon, 18 Jul 2022 20:03:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 832973851C02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658174603; bh=Y1MbawuQP6YhmQMVTUIsw7pEqngLh6gC/Q0M/eqDFyA=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=c9Ha1RuDBmnEVDpPCTxWqZKgJFiioDHo7v0sWN6ZEKJhROddq9v9fxtPDyqK0HZEd /6nAUqfihKSFECCd5sh4GsorYSM3PVfYiMsqXQhP4Sa3s0EcZi4s/btRNBFay/+MA3 K9fea0z2/Lr85N9l3MUdQon6eSh4lsYPomlHfa+Q= 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 A419F3858438 for ; Mon, 18 Jul 2022 20:02:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A419F3858438 Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-317XEP_eOCi8e2dLjMrNTQ-1; Mon, 18 Jul 2022 16:02:36 -0400 X-MC-Unique: 317XEP_eOCi8e2dLjMrNTQ-1 Received: by mail-io1-f71.google.com with SMTP id a26-20020a6b661a000000b0067be5b57f45so4068828ioc.16 for ; Mon, 18 Jul 2022 13:02:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:content-language; bh=uXkZRyzln481QCb/VpQv/wYMp7tmIGChiVBqGW64tCk=; b=cxvMGNjW3ZOC9o7dWYoaqLFOrj354huySRnO0AuuzvhchRqH2E/7mMnXJFRSHky1Vl t0ROrwO22mz454Hqi4FcO5m66hR4K7QoEMUFx60gh4K0PN++djQVq5URoDRRzoHFFESO AepLqJvSYmjM7jkiFMWQX0qkq0L80ftFZ1KZV+7XNbxEyoWT/A+lMltmBAoe/ZlRXS1S RCU0dyovhzS4RX3QBw5QrO8OIhAMzzCBKN8HSWp6j5lWBVLV/iXiY1EjZo0IAs1EII/e zxpLMl1bUUvzhAu60wv/+9CkyzCu4EkdgWXX59ZyzeXILJLZLnWF8z1EYwXWw2x1J0Uo FDfQ== X-Gm-Message-State: AJIora/zDOfvudPwJFGpzecAXnTDhlkon5psYnMHAJqN9K3fCfaqoWdd mQ/DRwuVaaeODrhPD0gGt1RTd9upMQ9sQNeXqRKmZ5I0kVNL8QMFYK3rG687RJaywmWFZXqe2Vs JzNdxs6+wIP3utps0kTyJeiN2Ux0p8EREwSNKBWeuByrKyIT0FTSjI7yMxByup1K6TOLOVg== X-Received: by 2002:a05:6638:d15:b0:341:610d:5472 with SMTP id q21-20020a0566380d1500b00341610d5472mr5822826jaj.188.1658174555924; Mon, 18 Jul 2022 13:02:35 -0700 (PDT) X-Received: by 2002:a05:6638:d15:b0:341:610d:5472 with SMTP id q21-20020a0566380d1500b00341610d5472mr5822817jaj.188.1658174555627; Mon, 18 Jul 2022 13:02:35 -0700 (PDT) Received: from [192.168.0.135] ([104.219.122.67]) by smtp.gmail.com with ESMTPSA id k7-20020a02c767000000b003415545d938sm3871038jao.166.2022.07.18.13.02.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Jul 2022 13:02:34 -0700 (PDT) Message-ID: <58aa1a95-c496-5fa3-42de-477d32efae31@redhat.com> Date: Mon, 18 Jul 2022 16:02:32 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [COMMITTED] tree-optimization/106280 - Check if transitives need to be registered. To: gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.7 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, 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.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: "Li, Pan2 via Gcc-patches" 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?1738722094116578430?= X-GMAIL-MSGID: =?utf-8?q?1738722094116578430?= Regardless of whether this is enough of an improvement for the PR, it should be done. Whenever a relation is registered with the oracle, it walks the dominator tree trying to apply any transitives it can find. FIrst, it should check whether the operands are already in any relation. If neither operand is in a relation, we can conclude there cannot be any transitives. this is a simple bitmask check. The second thing this patch does is adjust the set_relation routine to return NULL if the relation being applied already exists.  ie, we don't need to set the relation or do any additionalwork if the relation is already true. This will also prevent additional calls to the register transitives. This provides some marginal improvements across the board, and noticeable improvements in the testcase. Bootstrapped on    x86_64-pc-linux-gnu with no regressions. Pushed. Andrew commit 5e47c9333df6df1aa9da861f07e68f985d7d28fb Author: Andrew MacLeod Date: Thu Jul 14 12:35:55 2022 -0400 Check if transitives need to be registered. Whenever a relation is added, register_transitive is always called. If neither operand was in a relation before, or this is not a new relation, then there is no need to register transitives. PR tree-optimization/106280 * value-relation.cc (dom_oracle::register_relation): Register transitives only when it is possible for there to be one. (dom_oracle::set_one_relation): Return NULL if this is an existing relation. diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index 13ce44199f7..bd344253af3 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -967,8 +967,12 @@ dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1, equiv_oracle::register_relation (bb, k, op1, op2); else { + // if neither op1 nor op2 are in a relation before this is registered, + // there will be no transitive. + bool check = bitmap_bit_p (m_relation_set, SSA_NAME_VERSION (op1)) + || bitmap_bit_p (m_relation_set, SSA_NAME_VERSION (op2)); relation_chain *ptr = set_one_relation (bb, k, op1, op2); - if (ptr) + if (ptr && check) register_transitives (bb, *ptr); } } @@ -1010,13 +1014,16 @@ dom_oracle::set_one_relation (basic_block bb, relation_kind k, tree op1, // Check into whether we can simply replace the relation rather than // intersecting it. THis may help with some optimistic iterative // updating algorithms. - ptr->intersect (vr); + bool new_rel = ptr->intersect (vr); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " to produce "); ptr->dump (dump_file); - fprintf (dump_file, "\n"); + fprintf (dump_file, " %s.\n", new_rel ? "Updated" : "No Change"); } + // If there was no change, return no record.. + if (!new_rel) + return NULL; } else {