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: Andrew MacLeod X-Patchwork-Id: 1657707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=ScNn1hqA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LmtDs74r3z9sG1 for ; Tue, 19 Jul 2022 06:03:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 446403852753 for ; Mon, 18 Jul 2022 20:03:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 446403852753 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658174580; 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=ScNn1hqAQh7ugjM/WsJHS6UQ9ex8RrAtnfkUWzbckIvj2tpbk6WOyxXLdH4x/lEhD hV9HxGNeHKewtGhvtPq3qYAtP4KAeFMp3KdXWtPez7m9quvF5wGURpTAm5xc7e8m8A bbPVSKOLu3GfuU7snbHc1MTxtnNHWYTeN2MTGy1s= 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-Google-Smtp-Source: AGRyM1s+DyJt+Vlz+z3l7k+rT7ZNzMTMBKtdYT/ozkX/XO+GUtAqVGlEiGs6I8MJM92QAB2BFhY/Mw== 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: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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 {