From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by sourceware.org (Postfix) with ESMTPS id 4323F3835406 for ; Wed, 30 Jun 2021 19:20:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4323F3835406 Received: by mail-yb1-xb2f.google.com with SMTP id m9so6773503ybp.8 for ; Wed, 30 Jun 2021 12:20:52 -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:content-transfer-encoding; bh=0uxdFEwnoCKhvcMNCZU0AhgABGGu4XNMPTj/1Ydt4SA=; b=nOxAAGgKEalfgF8xL2KQcVuaEwJ+4+9WVO7EgjaEoOHDZ7UTKRcJjPsQrNp2Ui+e1B m4+zqvHxBFd/ho3vx9WvKz/5UF+oZXBS56RbZsviy31yyby2r6lIkUnM5932mMXgNMOl 2stH6v0rLNR3w0LXd8q0+w5Sr0Frj9pUjkQjJsaaOIyO9FCntb/iHNzTwQ0dQXdpw2Gl TIlrVYFOC0hjczxJ0c6XuHc9X0COXo8WtNTI2yej2JBEE3lpGiyBkbNwbG6wcKEhmA0a OXCeuBOTTNfzFHEy2s3PX5AqUcTZA/6akW4/+PMbkFZoVUlqYSTFw6gbs6QMcvzd6bH+ AJXA== X-Gm-Message-State: AOAM531ednEt36aDn/BDISP2it7I/a68nuIxlBd/jISilqeKfbQwg/LK pEulKh/oOP4re8IEd+n+6m7NlK7B3Q23ylsRss8= X-Google-Smtp-Source: ABdhPJyXCujEe+nM7YLKc0zItv/8Lg9yieqhgy1WBdhmKVoaz2KVt/7qz5YeN7z41G4X63xr2ExmKtMIICOxDtOvNOs= X-Received: by 2002:a25:8b12:: with SMTP id i18mr44818363ybl.162.1625080851786; Wed, 30 Jun 2021 12:20:51 -0700 (PDT) MIME-Version: 1.0 References: <004A0552-4D2E-48F4-8474-5902E462D77B@oracle.com> <495DF61E-8E9A-4A0F-A6FC-AD470B7EDADA@suse.de> <4A5C3A75-A927-4680-A6C5-82A44670B0DC@suse.de> <347052B2-1E12-4425-B047-403FDA56AC4C@oracle.com> In-Reply-To: <347052B2-1E12-4425-B047-403FDA56AC4C@oracle.com> From: Andrew Pinski Date: Wed, 30 Jun 2021 12:20:38 -0700 Message-ID: Subject: Re: HELP!! How to inhibit optimizations applied to .DEFERRED_INIT argument? To: Qing Zhao Cc: Richard Biener , richard Sandiford , gcc-patches Qing Zhao via , kees cook Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, PLING_QUERY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 30 Jun 2021 19:20:53 -0000 On Wed, Jun 30, 2021 at 12:14 PM Qing Zhao wrote: > > > > > On Jun 30, 2021, at 1:59 PM, Richard Biener wrote: > > > > On June 30, 2021 8:07:43 PM GMT+02:00, Qing Zhao = wrote: > >> > >> > >>> On Jun 30, 2021, at 12:36 PM, Richard Biener > >> wrote: > >>> > >>> On June 30, 2021 7:20:18 PM GMT+02:00, Andrew Pinski > >> wrote: > >>>> On Wed, Jun 30, 2021 at 8:47 AM Qing Zhao via Gcc-patches > >>>> wrote: > >>>>> > >>>>> I came up with a very simple testing case that can repeat the same > >>>> issue: > >>>>> > >>>>> [qinzhao@localhost gcc]$ cat t.c > >>>>> extern void bar (int); > >>>>> void foo (int a) > >>>>> { > >>>>> int i; > >>>>> for (i =3D 0; i < a; i++) { > >>>>> if (__extension__({int size2; > >>>>> size2 =3D 4; > >>>>> size2 > 5;})) > >>>>> bar (a); > >>>>> } > >>>>> } > >>>> > >>>> You should show the full dump, > >>>> What we have is the following: > >>>> > >>>> > >>>> > >>>> size2_3 =3D PHI > >>>> : > >>>> > >>>> size2_12 =3D .DEFERRED_INIT (size2_3, 2); > >>>> size2_13 =3D 4; > >>>> > >>>> So CCP decides to propagate 4 into the PHI and then decides > >> size2_1(D) > >>>> is undefined so size2_3 is then considered 4 and propagates it into > >>>> the .DEFERRED_INIT. > >>> > >>> Which means the DEFERED_INIT is inserted at the wrong place. > >> > >> Then, where is the correct place for =E2=80=9C.DEFERRED_INIT(size2,2)? > >> > >> The variable =E2=80=9Csize2=E2=80=9D is a block scope variable which i= s declared inside > >> the =E2=80=9Cif=E2=80=9D condition: > > > > But that's obviously not how it behaves > > During into SSA phase since we're inserting a PHI for it - and we're in= serting it because of the use in the DEFERED_INIT call. I suppose you need = to fiddle with the SSA rewrite and avoid treating the use as a use but only= for the purpose of inserting PHIs... > > Please see my other email on the new small testing case without -ftrivial= -auto-var-init. The same issue in SSA with that testing case even without = -ftrivial-auto-var-init. > It looks like an existing bug to me in SSA. > > Let me know if I still miss anything Yes you missed it is unspecified what the value if the auto variable is used uninitialized. Isn't that the point of what you are trying to fix in the first place? So ccp takes PHI and says since a_1(D) is uninitialized, the value is 4. Thanks, Andrew > > Qing > > > > You might be able to construct a testcase which has a use before the re= al init where then the optimistic CCP propagation will defeat the DEFERED_I= NIT otherwise. > > > > I'd need to play with the actual patch to find a good solution to this = problem. > > > > Richard. > > >