public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Richard Biener <rguenther@suse.de>
Cc: Andrew Pinski <pinskia@gmail.com>,
	richard Sandiford <richard.sandiford@arm.com>,
	gcc-patches Qing Zhao via <gcc-patches@gcc.gnu.org>,
	kees cook <keescook@chromium.org>
Subject: Re: HELP!! How to inhibit optimizations applied to .DEFERRED_INIT argument?
Date: Wed, 30 Jun 2021 19:14:38 +0000	[thread overview]
Message-ID: <347052B2-1E12-4425-B047-403FDA56AC4C@oracle.com> (raw)
In-Reply-To: <4A5C3A75-A927-4680-A6C5-82A44670B0DC@suse.de>



> On Jun 30, 2021, at 1:59 PM, Richard Biener <rguenther@suse.de> wrote:
> 
> On June 30, 2021 8:07:43 PM GMT+02:00, Qing Zhao <qing.zhao@oracle.com> wrote:
>> 
>> 
>>> On Jun 30, 2021, at 12:36 PM, Richard Biener <rguenther@suse.de>
>> wrote:
>>> 
>>> On June 30, 2021 7:20:18 PM GMT+02:00, Andrew Pinski
>> <pinskia@gmail.com> wrote:
>>>> On Wed, Jun 30, 2021 at 8:47 AM Qing Zhao via Gcc-patches
>>>> <gcc-patches@gcc.gnu.org> 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 = 0; i < a; i++) {
>>>>>   if (__extension__({int size2;
>>>>>       size2 = 4;
>>>>>       size2 > 5;}))
>>>>>   bar (a);
>>>>> }
>>>>> }
>>>> 
>>>> You should show the full dump,
>>>> What we have is the following:
>>>> 
>>>> 
>>>> 
>>>> size2_3 = PHI <size2_1(D), size2_13>
>>>> <bb 3> :
>>>> 
>>>> size2_12 = .DEFERRED_INIT (size2_3, 2);
>>>> size2_13 = 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 “.DEFERRED_INIT(size2,2)?
>> 
>> The variable “size2” is a block scope variable which is declared inside
>> the “if” condition:
> 
> But that's obviously not how it behaves
> During into SSA phase since we're inserting a PHI for it - and we're inserting 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 

Qing
> 
> You might be able to construct a testcase which has a use before the real init where then the optimistic CCP propagation will defeat the DEFERED_INIT otherwise. 
> 
> I'd need to play with the actual patch to find a good solution to this problem. 
> 
> Richard.
> 


  parent reply	other threads:[~2021-06-30 19:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-30  0:14 Qing Zhao
2021-06-30  7:46 ` Richard Biener
2021-06-30 14:04   ` Qing Zhao
2021-06-30 14:39     ` Richard Biener
2021-06-30 15:11       ` Qing Zhao
2021-06-30 15:43       ` Qing Zhao
2021-06-30 17:20         ` Andrew Pinski
2021-06-30 17:36           ` Richard Biener
2021-06-30 18:07             ` Qing Zhao
2021-06-30 18:59               ` Richard Biener
2021-06-30 19:10                 ` Qing Zhao
2021-06-30 19:14                 ` Qing Zhao [this message]
2021-06-30 19:20                   ` Andrew Pinski
2021-06-30 19:54                     ` Qing Zhao
2021-07-01  6:48                   ` Richard Biener
2021-07-01 13:45                     ` Qing Zhao
2021-07-01 14:04                       ` Richard Biener
2021-07-01 15:27                         ` Qing Zhao
2021-07-01 14:09                       ` Richard Sandiford
2021-07-01 14:40                         ` Michael Matz
2021-07-01 15:35                           ` Richard Sandiford
2021-07-01 16:06                             ` Michael Matz
2021-07-01 16:23                               ` Richard Sandiford
2021-07-01 16:35                                 ` Qing Zhao
2021-07-01 15:42                           ` Qing Zhao
2021-07-01 18:14                           ` Richard Biener
2021-07-01 15:32                         ` Qing Zhao
2021-06-30 19:04               ` Qing Zhao
2021-06-30 17:45           ` Qing Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=347052B2-1E12-4425-B047-403FDA56AC4C@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=keescook@chromium.org \
    --cc=pinskia@gmail.com \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).