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 BF3C33853834 for ; Tue, 2 Aug 2022 14:25:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BF3C33853834 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-jiE-2kTGNDuLkMQ7Ln7OgA-1; Tue, 02 Aug 2022 10:25:34 -0400 X-MC-Unique: jiE-2kTGNDuLkMQ7Ln7OgA-1 Received: by mail-ot1-f69.google.com with SMTP id 7-20020a9d0107000000b006366f96b327so1108873otu.7 for ; Tue, 02 Aug 2022 07:25:33 -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=RDXqH26KdzytHWxv7EKMgDUeOBDuvgM4Hmnauvl9uRc=; b=umuB/jDX9YUtkr3vQi4dh8wFetLH/Hg/LA3+duU44fkxDKNAto6IFQroU5qrdm6AL/ ZC8t6Mi+//R3IedYL4hTSNQnL4amJXVtZ56Ycmt9VNrsd8b8x5CdYx88TWOkWs5tH2eV fyU1k7EcF8oudDNbjK3VKFbl00BY2+1PCDcvoNea85yQJt6a6QmIOYor6bmITA20WQiJ eXCMuwFepz6zOxWWPQ8Ow+WhVVHcJTt+3J6Eb3P0lbdeYxc/+O5e/csitKrSWuGlGX37 WrmRaqZX7FzaSMjJMWutAe5+2xN+Wm+C0eFbQFZKJAa8mle3mBFPMw/xHd3wsPqsf2xV 3zKA== X-Gm-Message-State: AJIora87bcNJGwrcF9h3+xQn+BPXN/ZnR30hD3bCPYB8TpcgO4y8gale brvrPUcniDt4PqrNZueD2CJQFr9jAtR5lPMdELqT5rSdS21A/QwgVI6rMPGbJHtMvUSeNd14PcV BKoZNGrLRge5PoCbWiwg+51rcQ5y42QQ3Yw== X-Received: by 2002:a05:6830:108c:b0:61c:cfcb:f436 with SMTP id y12-20020a056830108c00b0061ccfcbf436mr7912645oto.276.1659450333253; Tue, 02 Aug 2022 07:25:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uGDm+HD8LmT7K+7iKcKBx+9TLOJ8jldsEX+pdGy3mv0bFc5r53cMfsRuPZqOl5r/l7KOlu1YyfEEEWdRBIiC4= X-Received: by 2002:a05:6830:108c:b0:61c:cfcb:f436 with SMTP id y12-20020a056830108c00b0061ccfcbf436mr7912638oto.276.1659450333002; Tue, 02 Aug 2022 07:25:33 -0700 (PDT) MIME-Version: 1.0 References: <04261.122080204410800126@us-mta-529.us.mimecast.lan> In-Reply-To: From: Aldy Hernandez Date: Tue, 2 Aug 2022 16:25:22 +0200 Message-ID: Subject: Re: [PATCH] Properly honor param_max_fsm_thread_path_insns in backwards threader To: Richard Biener Cc: gcc-patches , "MacLeod, Andrew" , Jeff Law , Jan Hubicka X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, 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 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, 02 Aug 2022 14:25:40 -0000 Feel free to blame me for everything except the profitability code and the generic block copier. That stuff was all there before and I mostly avoided it. :-) Thanks for the work in this space. Aldy On Tue, Aug 2, 2022, 15:29 Richard Biener wrote: > On Tue, 2 Aug 2022, Aldy Hernandez wrote: > > > On Tue, Aug 2, 2022 at 1:59 PM Richard Biener wrote: > > > > > > On Tue, 2 Aug 2022, Aldy Hernandez wrote: > > > > > > > On Tue, Aug 2, 2022 at 1:45 PM Richard Biener > wrote: > > > > > > > > > > On Tue, 2 Aug 2022, Aldy Hernandez wrote: > > > > > > > > > > > Unfortunately, this was before my time, so I don't know. > > > > > > > > > > > > That being said, thanks for tackling these issues that my work > > > > > > triggered last release. Much appreciated. > > > > > > > > > > Ah. But it was your r12-324-g69e5544210e3c0 that did > > > > > > > > > > - else if (n_insns > 1) > > > > > + else if (!m_speed_p && n_insns > 1) > > > > > > > > > > causing the breakage on the 12 branch. That leads to a simpler > > > > > fix I guess. Will re-test and also backport to GCC 12 if > successful. > > > > > > > > Huh. It's been a while, but that looks like a typo. That patch was > > > > supposed to be non-behavior changing. > > > > > > Exactly my thinking so reverting it shouldn't be a reason for > > > detailed questions. Now, the contains_hot_bb computation is, > > > > Sorry for the pain. > > So - actually the change was probably done on purpose (even if > reverting - which I've now already one - caused no testsuite regressions). > That's because the whole function is invoked N + 1 times for a path > of length N and we definitely want to avoid using the size optimization > heuristics when the path is not complete yet. I think the proper > way is to do > > diff --git a/gcc/tree-ssa-threadbackward.cc > b/gcc/tree-ssa-threadbackward.cc > index ba114e98a41..6979398ef76 100644 > --- a/gcc/tree-ssa-threadbackward.cc > +++ b/gcc/tree-ssa-threadbackward.cc > @@ -767,7 +767,11 @@ back_threader_profitability::profitable_path_p (const > vec &m_path, > as in PR 78407 this leads to noticeable improvements. */ > if (m_speed_p > && ((taken_edge && optimize_edge_for_speed_p (taken_edge)) > - || contains_hot_bb)) > + || contains_hot_bb > + /* Avoid using the size heuristics when not doing the final > + thread evaluation, we get called for each added BB > + to the path. */ > + || !taken_edge)) > { > if (n_insns >= param_max_fsm_thread_path_insns) > { > > thus assume there'll be a hot BB in the future. > > That said, the very best fix would be to not call this function > N + 1 times (I have a patch to call it only N times - yay), but > instead factor out parts to be called per BB plus keeping enough > state so we can incrementally collect info. > > There's more "odd" things in the backward threader, of course :/ > > I'm looking for things applicable to the GCC 12 branch right now > so will try the above. > > Richard. > >