From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id DEE673877432 for ; Tue, 27 Jul 2021 09:00:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DEE673877432 Received: by mail-ed1-x536.google.com with SMTP id r16so14343347edt.7 for ; Tue, 27 Jul 2021 02:00:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S8tLS9R8pZqeV2pbeAKR395XKo3eG2rPIkXFaoL5S78=; b=W8hm7DJZF+TACQY6yxg1Ayc2FULAtlkaEzUn1/Gi6rIFRJiMp14ZZuTRPfKbK2NKD4 Nm6Fq+J1xCbaxXYWigy1ZoIlsI0ihVRBquuLKFX/TAGQrXCLpLjLq3W78V5Ng8t54bxX CI4N3tRxZquTAuoWWG+TJFYwGGc0vPYOyQvALXvTFiIaCZ637rA/LDqfVF8Qxz36jSsk 10NIElJrJ99s3koA2DuVzKeXeqgxzAn7fT9qBQGUjbW3vQ9lnTDQHeAfseNA4o+eb0uo 7UQEzfpjuwrjrT9LPgVmPd9lK1vV+s2BvPdjXAJKzf1Eah13S4mnqqclFE9GNQqnOFjC g5Tw== X-Gm-Message-State: AOAM531qYp6CkLVHFvoD/iLx/kwKHOQR6zmzlANETjltd31/lKyAxgQF dE2E2sh9f0pK9vexuOGEkbfER+a30ZuTQDkgvKw= X-Google-Smtp-Source: ABdhPJw3IMWyUPt1sAkkfe6SGPbHEJaUgJjX0FWbnGq858GTauEdFC2LT5FKRSpZen78bqb0UQ6e6JsScP+jjsJgQNg= X-Received: by 2002:a50:ab1c:: with SMTP id s28mr18443397edc.214.1627376410074; Tue, 27 Jul 2021 02:00:10 -0700 (PDT) MIME-Version: 1.0 References: <54c74204-38f5-690a-6f0c-6b9fb5e96756@gmail.com> In-Reply-To: From: Richard Biener Date: Tue, 27 Jul 2021 10:59:59 +0200 Message-ID: Subject: Re: 0001-Don-t-skip-prologue-instructions-as-it-could-affect-.patch To: "Bin.Cheng" Cc: Jeff Law , GCC Patches , "bin.cheng" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Tue, 27 Jul 2021 09:00:16 -0000 On Tue, Jul 27, 2021 at 10:51 AM Bin.Cheng via Gcc-patches wrote: > > On Mon, Jul 26, 2021 at 11:07 PM Jeff Law wrote: > > > > > > > > On 7/25/2021 7:47 PM, Bin.Cheng wrote: > > > On Sat, Jul 24, 2021 at 12:30 AM Jeff Law via Gcc-patches > > > wrote: > > >> > > >> > > >> On 7/14/2021 3:14 AM, bin.cheng via Gcc-patches wrote: > > >>> Hi, > > >>> I ran into a wrong code bug in code with deep template instantiation when working on sdx::simd. > > >>> The root cause as described in commit summary is we skip prologue insns in init_alias_analysis. > > >>> This simple patch fixes the issue, however, it's hard to reduce a case because of heavy use of > > >>> templates. > > >>> Bootstrap and test on x86_64, is it OK? > > >> It's a clear correctness improvement, but what's unclear to me is why > > >> we'd want to skip them in the epilogue either. > > > I can only guess, there is nothing to initialize epilogue for because > > > no code follows. > > Yea, but couldn't the lack of analysis of the epilogue lead to a pass > > mis-optimizing code within the epilogue itself? It's not terribly > > likely, but it just seems wrong to skip the epilogue like this. > > Remember, the aliasing bits are just an analysis phase to find the > > aliasing relationships that exist and we don't necessarily know how that > > data is going to be used. It may in fact be safe now, but may not be > > safe in the future if someone added a late RTL pass that used the > > aliasing info in a new way. > > > > The more I think about it, the more I think we should remove remove this > > hunk of code completely. There is some chance for fallout, but I think > > it's unlikely. > Hi Jeff, > Thanks for the suggestion, here is the simple patch removing all of it. > diff --git a/gcc/alias.c b/gcc/alias.c > index 69e1eb89ac6..099acabca6b 100644 > --- a/gcc/alias.c > +++ b/gcc/alias.c > @@ -3406,14 +3406,6 @@ init_alias_analysis (void) > rpo = XNEWVEC (int, n_basic_blocks_for_fn (cfun)); > rpo_cnt = pre_and_rev_post_order_compute (NULL, rpo, false); > > - /* The prologue/epilogue insns are not threaded onto the > - insn chain until after reload has completed. Thus, > - there is no sense wasting time checking if INSN is in > - the prologue/epilogue until after reload has completed. */ > - bool could_be_prologue_epilogue = ((targetm.have_prologue () > - || targetm.have_epilogue ()) > - && reload_completed); > - > pass = 0; > do > { > @@ -3459,10 +3451,6 @@ init_alias_analysis (void) > { > rtx note, set; > > - if (could_be_prologue_epilogue > - && prologue_epilogue_contains (insn)) > - continue; > - > /* If this insn has a noalias note, process it, Otherwise, > scan for sets. A simple set will have no side effects > which could change the base value of any other > register. */ > > No fallouts in bootstrap/test on x86_64. Is it OK? OK. Thanks, Richard. > Thanks, > bin > > > > Jeff > >