From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 6A6D13858C2D for ; Tue, 16 Aug 2022 12:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A6D13858C2D Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-615-jjAddjiSO4GGwrr5pGgJ4g-1; Tue, 16 Aug 2022 08:32:19 -0400 X-MC-Unique: jjAddjiSO4GGwrr5pGgJ4g-1 Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-116c235fda1so2519372fac.4 for ; Tue, 16 Aug 2022 05:32:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=ZSenzALL+SjJSYvcnZnVMUbdVpTOz20882/bO7UoE2E=; b=LSyMyS94NnjByVhJGYt9L/GpFx0+VnNUnqiH+RgW7XU1izbsAHihZY7Fpv2Vf751vq +8Z8CnpykBk86gTFdJZ/vCkwu/iBo72EJTEdoGktxCoj+VHvQ/hlxvvFaBXYudv2XiH3 cFWqRsTleh0V/M2lXZDgmlm+5MUJ7hzikz7hZl8HKsKcde8i410HMNCSOIW4FeeV1lBi Kq/Cyjg5hkzdn8rPutEoEwQdunm7ALHa2taaZ+VtcRJzkFAglMRuntBI7Dfaf90oOrSE kz6aMa4AqFCeEhJe8elsbvsEfJgy1W2KdHSB0Dz4DwCdTUl9fSWlaotT/6f7Haj8uxnZ buxg== X-Gm-Message-State: ACgBeo0D6JabgYmwy3sW3VlG/JCwQC3CkilzUtuc74JUgwcJFFf8lOqT Lx206nVqB8D1Gl2lZUgQesK9FyBnEW8nxb7S+vf+9NSA/cwBCYD93RFRIEOGCKjLkQZVjrvRn7G 5PkaqVQNth/v1IsUX/z+diTFq/LtHf4c9pA== X-Received: by 2002:a05:6870:b617:b0:10d:f7ce:50df with SMTP id cm23-20020a056870b61700b0010df7ce50dfmr12986683oab.36.1660653138524; Tue, 16 Aug 2022 05:32:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4UrO2l0bCjIiNsY7+m4TzqxM4CtIOIa20lYY3M9Mdi4VJ0XoSAu9cdAoTQTbSusJFrtELPnLS4UJeuoiR3UQY= X-Received: by 2002:a05:6870:b617:b0:10d:f7ce:50df with SMTP id cm23-20020a056870b61700b0010df7ce50dfmr12986674oab.36.1660653138299; Tue, 16 Aug 2022 05:32:18 -0700 (PDT) MIME-Version: 1.0 References: <73820.122081107421800679@us-mta-533.us.mimecast.lan> In-Reply-To: From: Aldy Hernandez Date: Tue, 16 Aug 2022 14:32:07 +0200 Message-ID: Subject: Re: [PATCH] Tame path_range_query::compute_imports To: Richard Biener Cc: Andrew MacLeod , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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-List-Received-Date: Tue, 16 Aug 2022 12:32:27 -0000 On Tue, Aug 16, 2022, 14:26 Richard Biener wrote: > On Tue, 16 Aug 2022, Aldy Hernandez wrote: > > > On Tue, Aug 16, 2022 at 1:38 PM Richard Biener > wrote: > > > > > > On Tue, 16 Aug 2022, Aldy Hernandez wrote: > > > > > > > On Mon, Aug 15, 2022 at 11:53 AM Richard Biener > wrote: > > > > > > > > > > The remaining issue I have with the path_range_query is that > > > > > we re-use the same instance in the back threader but the > > > > > class doesn't provide any way to "restart", aka give m_path > > > > > a lifetime. The "start a new path" API seems to essentially > > > > > be compute_ranges (), but there's no convenient way to end. > > > > > It might be more appropriate to re-instantiate the > path_range_query, > > > > > though that comes at a cost. Or abstract an actual query, like > > > > > adding a > > > > > > > > Yes, compute_ranges() is the way to start a new path. It resets exit > > > > dependencies, the path, relations, etc. I think it would be clearer > > > > to name it set_path (or reset_path if we want to share nomenclature > > > > with the path_oracle). > > > > > > > > Instantiating a new path_range_query per path is fine, as long as you > > > > allocate the ranger it uses yourself, instead of letting > > > > path_range_query allocate it. Instantiating a new ranger does have a > > > > cost, and it's best to let path_range_query re-use a ranger from path > > > > to path. This is why path_range_query is (class) global in the > > > > backwards threader. Andrew mentioned last year making the ranger > > > > start-up 0-cost, but it still leaves the internal caching the ranger > > > > will do from path to path (well, the stuff outside the current path, > > > > cause the stuff inside the path is irrelevant since it'll get > > > > recalculated). > > > > > > > > However, why can't you use compute_ranges (or whatever we rename it > to ;-))?? > > > > > > I've added > > > > > > auto_bb_flag m_on_path; > > > > > > to the path query and at set_path time set m_on_path on each BB so > > > the m_path->contains () linear walks go away. But I need to clear > > > the flag for which I would need something like finish_path (), > > > doing it just at the point we deallocate the path query object > > > or when we set the next path via compute_ranges doesn't look right > > > (and in fact it doesn't work out-of-the-box without adjusting the > > > lifetime of the path query object). > > > > > > So a more incremental thing would be to add such finish_path () > > > or to make the whole path query object single-shot, thus remove > > > compute_ranges and instead use the CTOR for this. > > > > > > Probably not too important (for short paths). > > > > On a high level, I wonder if this matters since we don't allow long > > paths for other performance reasons you've already tackled. But OTOH, > > I've always been a little uncomfortable with contains_p linear search, > > so if you think this makes a difference, go right ahead :). > > > > I'm fine with either the finish_path() or the single-shot thing you > > speak of. Although making path query inmutable makes things cleaner > > in the long run. I like it! My guess is that the non-ranger > > instantiation penalty would be minimal. I'd even remove the default > > (auto-allocated) ranger from path_range_query, to make it obvious that > > you need to manage that yourself and avoid folks shooting themselves > > in the foot. > > We currently have > > path_range_query::path_range_query (bool resolve, gimple_ranger *ranger) > : m_cache (new ssa_global_cache), > m_has_cache_entry (BITMAP_ALLOC (NULL)), > m_resolve (resolve), > m_alloced_ranger (!ranger) > { > if (m_alloced_ranger) > m_ranger = new gimple_ranger; > else > m_ranger = ranger; > > m_oracle = new path_oracle (m_ranger->oracle ()); > > if (m_resolve && flag_checking) > verify_marked_backedges (cfun); > } > > so at least verify_marked_backedges will explode, I suppose we > want to hoist that somehow ... > Good point. > then we allocate the path_oracle - that one does have a > reset_path () function at least. It's allocation looks > quite harmless, but we should only need it when m_resolve? > Yes. > > Wanna have a go at it? If you'd rather not, I can work on it. > > If you have cycles go ahead - I'm fiddling with other parts of > the threader right now. > Sure, I'll take a stab at it. Thanks for the other stuff you're doing on the threader. Aldy > Richard. > >