From patchwork Tue Nov 1 13:19:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 13657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2960950wru; Tue, 1 Nov 2022 06:20:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6qjRwBXwndm3U2ctWVFy2bJybHUG9wXWow+MzYgGmTec+KAiCFdi9nBGmy00PLlrRerRb5 X-Received: by 2002:a17:907:7245:b0:78d:ec9c:e743 with SMTP id ds5-20020a170907724500b0078dec9ce743mr18507487ejc.466.1667308839964; Tue, 01 Nov 2022 06:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667308839; cv=none; d=google.com; s=arc-20160816; b=ns6bn6Ra5c6hAPIuvEr7QSNue+T4bwNPZD1H51ETjD5/2jh33AAa/TnI0WzpgAc0lY qQ/816NA7AGgN0edPh22RZGy8aNXzYPEN1879LEcvS2PplGqP7Ja9Dk+YxL7ggG2RpnY RYA1SFxYlaJFpCqzFPOPXFEh14goq4ikX45ZggW8ewhbOJVhc/Q6MO2rrhBLaL85Og0p XnYgXMQkqUy704cqQFXlTNgYqjnSMaoeFjqRs6aeib1nyo6k1nQdw8M/tXZ0+ZReZd5j Fem7yhpIVmE4gEb5hiD39eY0actuYTqPZHADZsgYplr29PyV9+HTIDbS2LgkY7cas/sI B/KQ== 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:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=TJynZjTY6MkfQAcPKzuqODdx1b1frzOZN1EOnuY/Gj8=; b=LcIvKQ7yHRuir9l8OaS9koSr/UOI8fWxgwbHl6SNH1H57EX6o7dxXfrSyg+zYywnxV PruW8B2hLNZhn/tvFQ1ZwwFsZjFTZC0QqAQnZbAv+B2BQxgFkvM9prlK6fKzTeX0e6Km vdQmMSsQCax3UWPGVLNXWZnJBoAYt773EHrWf8uhYy5Wu/hJ+mxLWcatwmOE1tSE/p1w tJUhDt7ZPhizy52SxOvkqZJFfhGwXOG57+ivnOoRgdvrmPuPhXXfQzGhHD3mKsl8St01 mcVaI7/uarIx2UxQY/U82gRJ5+erus7PaBG1BAjRneAYGgH2SeacLFYUwv1i6ytiCVhb I8Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=E9Xt6CnL; 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 j27-20020a170906279b00b00772fe97b31esi8549383ejc.901.2022.11.01.06.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 06:20:39 -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=E9Xt6CnL; 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 5C4803857824 for ; Tue, 1 Nov 2022 13:20:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C4803857824 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667308818; bh=TJynZjTY6MkfQAcPKzuqODdx1b1frzOZN1EOnuY/Gj8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=E9Xt6CnLbCqDZPAvZjsUmFTU40I7R7P9n1WX5JzG5Pi5NwRq2JXyjgLJNoGXOshnj j10MyGrXT3SpocTAxMaRzuLT7xWQE1ucdnY1CX2kUSs3khvYqCYKf256pVbqeKm/r7 1CHnuusf2dQZrIKUC5n3q7oYcs3Redn5I/odKOg0= 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 2C33D3858006 for ; Tue, 1 Nov 2022 13:19:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2C33D3858006 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-151-uJRg1uNROCSfKYkUdoI2cQ-1; Tue, 01 Nov 2022 09:19:30 -0400 X-MC-Unique: uJRg1uNROCSfKYkUdoI2cQ-1 Received: by mail-qt1-f200.google.com with SMTP id 17-20020ac85711000000b0039ccd4c9a37so9879855qtw.20 for ; Tue, 01 Nov 2022 06:19:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=VcuwyMYylwkI/j0BfDAFgm99Odgaki5isxgNwjL4Z5I=; b=LfysANVP3agXYz2c+HsRihZTfRCkhfmu8uOHeSjJFHzemF8I4N9Dta6Os8oCtVJ1Ml AerQP27OzsRQGmKuzjz3NwsLd7FdrYm5o3O4iFN25GqGHKl41sO0NXRPqFBR+qJzVtEW iV6HJHj2I0aHabfZ4WYz6e5HtjNMAkbq0+rDreBjgZeamg/3c36MzfPb7ICH24GsBC57 Z3S1e0XSqShFzrMlEBxabSitQvtBgmMekmrkFfiaFXvgacSnE20RUYt85VvARy8gaCw7 mZT8o+2zHYGLIgYYPsRcllnc1ZcKCB7rWYWfwOtNrYNOPRdOJsvGerwf70gzih/ywKwD dIgA== X-Gm-Message-State: ACrzQf3eqOsyLbs6ZwVWQPFP2VVppLUTPJgN7xkzNTrffsPccumsTtvD q/B0x8z5nL4gi0vj1FK9DePt8EBRV/+S2y/uRB6rLzBrfcJklgnOLQg4NpNg9IImOo1hAT6WXaK keWakzAnB07Hj3l2fJ2Q8xs8HES440fL0/FzXehJMsi9hjUKytiGK9RUxlYJSuq82NF1w2Q== X-Received: by 2002:a05:620a:146c:b0:6fa:3ae2:b54c with SMTP id j12-20020a05620a146c00b006fa3ae2b54cmr4732919qkl.378.1667308769441; Tue, 01 Nov 2022 06:19:29 -0700 (PDT) X-Received: by 2002:a05:620a:146c:b0:6fa:3ae2:b54c with SMTP id j12-20020a05620a146c00b006fa3ae2b54cmr4732891qkl.378.1667308769106; Tue, 01 Nov 2022 06:19:29 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::72c3? ([2607:fea8:a263:f600::72c3]) by smtp.gmail.com with ESMTPSA id r10-20020ac85e8a000000b0039cb5c9dbacsm5107796qtx.22.2022.11.01.06.19.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 06:19:28 -0700 (PDT) Message-ID: <052c0ba5-79fc-ad55-bfa9-38b5b3394e11@redhat.com> Date: Tue, 1 Nov 2022 09:19:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 To: gcc-patches Subject: [COMMITTED] Allow ranger queries on exit block. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.0 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_H2, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748300034627729561?= X-GMAIL-MSGID: =?utf-8?q?1748300034627729561?= Ranger was not allowing the exit block to be queried for range_on_entry or exit, for no good reason.  This removes that restriction. Interestingly, it seems that when we calculate dominance info, GCC does not set the dominators for the EXIT_BLOCK?  I worked around it by starting with a single pred of the exit block for my queries, but as a result it doesn't support multiple exit blocks. For the record:   get_immediate_dominator (CDI_DOMINATORS, EXIT_BLOCK_PTR_FOR_FN (cfun)) returns NULL.   Is this actually working as intended?  It was unexpected on my part. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 592bbe3d7eb3cff656c731e84ad872719a4a9d16 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Mon, 31 Oct 2022 10:56:25 -0400 Subject: [PATCH 2/3] Allow queries on exit block. Ranger was not allowing the exit block to be queried for range_on_entry or exit. This removes that restriction. * gimple-range-cache.cc (ranger_cache::fill_block_cache): Allow exit block to be specified. (ranger_cache::range_from_dom): If exit block is specified, use the immediate predecessor instead of the dominator to start. * gimple-range.cc (gimple_ranger::range_on_exit): Allow query for exit block. --- gcc/gimple-range-cache.cc | 16 ++++++++++------ gcc/gimple-range.cc | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index f279371948a..89e2403acce 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -1193,9 +1193,8 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb) Value_Range block_result (type); Value_Range undefined (type); - // At this point we shouldn't be looking at the def, entry or exit block. - gcc_checking_assert (bb != def_bb && bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) && - bb != EXIT_BLOCK_PTR_FOR_FN (cfun)); + // At this point we shouldn't be looking at the def, entry block. + gcc_checking_assert (bb != def_bb && bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)); gcc_checking_assert (m_workback.length () == 0); // If the block cache is set, then we've already visited this block. @@ -1434,10 +1433,15 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb, // Default value is global range. get_global_range (r, name); + // The dominator of EXIT_BLOCK doesn't seem to be set, so at least handle + // the common single exit cases. + if (start_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) && single_pred_p (start_bb)) + bb = single_pred_edge (start_bb)->src; + else + bb = get_immediate_dominator (CDI_DOMINATORS, start_bb); + // Search until a value is found, pushing blocks which may need calculating. - for (bb = get_immediate_dominator (CDI_DOMINATORS, start_bb); - bb; - prev_bb = bb, bb = get_immediate_dominator (CDI_DOMINATORS, bb)) + for ( ; bb; prev_bb = bb, bb = get_immediate_dominator (CDI_DOMINATORS, bb)) { // Accumulate any block exit inferred ranges. m_exit.maybe_adjust_range (infer, name, bb); diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 058439733ee..110cf574454 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -167,7 +167,6 @@ void gimple_ranger::range_on_exit (vrange &r, basic_block bb, tree name) { // on-exit from the exit block? - gcc_checking_assert (bb != EXIT_BLOCK_PTR_FOR_FN (cfun)); gcc_checking_assert (gimple_range_ssa_p (name)); unsigned idx; -- 2.37.3