public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: update address taken: don't drop clobbers
Date: Sun, 07 Sep 2014 15:28:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.11.1409071654310.5483@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <alpine.DEB.2.11.1407271853200.22972@stedding.saclay.inria.fr>

On Sun, 27 Jul 2014, Marc Glisse wrote:

> On Thu, 10 Jul 2014, Richard Biener wrote:
>
>>> --- gcc/tree-into-ssa.c (revision 212109)
>>> +++ gcc/tree-into-ssa.c (working copy)
>>> @@ -1831,26 +1831,38 @@ maybe_register_def (def_operand_p def_p,
>>>  {
>>>    tree def = DEF_FROM_PTR (def_p);
>>>    tree sym = DECL_P (def) ? def : SSA_NAME_VAR (def);
>>>
>>>    /* If DEF is a naked symbol that needs renaming, create a new
>>>       name for it.  */
>>>    if (marked_for_renaming (sym))
>>>      {
>>>        if (DECL_P (def))
>>>         {
>>> -         tree tracked_var;
>>> -
>>> -         def = make_ssa_name (def, stmt);
>>> +         if (gimple_clobber_p (stmt) && is_gimple_reg (sym))
>> 
>> sym should always be a gimple reg here (it's marked for renaming).
>> 
>>> +           {
>>> +             /* Replace clobber stmts with a default def.  Create a new
>>> +                variable so we don't later think we must coalesce, which
>>> would
>>> +                fail with some ada abnormal PHIs.  Still, we try to keep 
>>> a
>>> +                similar name so error messages make sense.  */
>>> +             unlink_stmt_vdef (stmt);
>> 
>> I think that's redundant with gsi_replace (note that using gsi_replace
>> looks dangerous here as it calls update_stmt during SSA rewrite...
>> that might open a can of worms).
>> 
>>> +             gsi_replace (&gsi, gimple_build_nop (), true);
>>> +             tree id = DECL_NAME (sym);
>>> +             const char* name = id ? IDENTIFIER_POINTER (id) : 0;
>>> +             tree newvar = create_tmp_var (TREE_TYPE (sym), name);
>>> +             def = get_or_create_ssa_default_def (cfun, newvar);
>> 
>> So - can't you simply do
>>
>>    gimple_assign_set_rhs_from_tree (&gsi,
>> get_or_create_dda_default_def (cfun, sym));
>> 
>> ?  Thus replace x = CLOBBER; with x_3 = x_2(D);
>> 
>>> +           }
>>> +         else
>> 
>> and of course still rewrite the DEF then.  IMHO the copy-propagation
>> you do is premature optimization.
>
> Using your version, I end up with spurious warnings, in particular for 
> va_list. pass_fold_builtins stops va_start/va_end taking the address of the 
> list, so we get:
>
>  list_6 = list_2(D);
>
> in place of the clobber at the end of the function. And there is no DCE-like 
> pass afterwards, so we warn for the use of list_2(D).
> (passes.def contains a comment about running dce before uninit)
>
> I don't know if update_address_taken could avoid generating this assignment 
> where the lhs has 0 use, but this shows the optimization is not completely 
> premature.
>
> (uninit could also check for this case, but that feels like a bad hack)

I would like some guidance on this. I just tried this trivial patch:

        NEXT_PASS (pass_split_crit_edges);
+      NEXT_PASS (pass_dce);
        NEXT_PASS (pass_late_warn_uninitialized);

and it does not cause any regression, it even XPASS 
gfortran.dg/reassoc_6.f for some reason. The FIXME note just above in 
passes.def mentions 2 testcases that are already xfailed anyway.

Would that extra pass be acceptable?

Otherwise, what do you think should be responsible for cleaning up the 
dead assignments?

-- 
Marc Glisse

  reply	other threads:[~2014-09-07 15:28 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28 22:33 Marc Glisse
2014-06-29 23:38 ` SRA: " Marc Glisse
2014-07-07  8:56   ` Richard Biener
2014-07-07  9:32     ` Marc Glisse
2014-07-07 18:32       ` Richard Biener
2014-07-07 20:15         ` Marc Glisse
2014-07-07 16:59     ` Jeff Law
2014-07-10 14:55   ` Richard Biener
2014-07-10 15:01     ` Jakub Jelinek
2014-06-30 19:31 ` update address taken: " Jeff Law
2014-07-06 14:24   ` Marc Glisse
2014-07-06 14:54     ` pinskia
2014-07-06 15:01       ` Marc Glisse
2014-07-07 10:21     ` Richard Biener
2014-07-07 17:20     ` Jeff Law
2014-07-08 13:31       ` Marc Glisse
2014-07-10 15:10 ` Richard Biener
2014-07-10 15:49   ` Michael Matz
2014-07-10 18:23     ` Jeff Law
2014-07-11  8:10       ` Richard Biener
2014-07-11  8:14         ` Richard Biener
2014-07-11 12:06       ` Michael Matz
2014-07-11 17:16         ` Jeff Law
2014-07-12  6:15   ` Marc Glisse
2014-07-24 13:06     ` Richard Biener
2014-07-27 11:53   ` Marc Glisse
2014-07-27 18:01   ` Marc Glisse
2014-09-07 15:28     ` Marc Glisse [this message]
2014-10-15 14:36       ` Marc Glisse
2014-10-15 16:12         ` Jeff Law
2014-10-16 11:20           ` Richard Biener
2014-10-16 14:11             ` Marc Glisse
2014-10-16 14:34               ` Richard Biener
2014-10-16 17:29               ` Jeff Law
2014-10-16 17:58                 ` Richard Biener
2014-10-16 18:37                   ` Jeff Law
2014-10-17 20:46                     ` Marc Glisse
2014-10-24 20:22                       ` Jeff Law
2014-10-25  8:06                         ` Marc Glisse
2014-10-31 21:06                           ` Jeff Law
2014-10-25 17:14                         ` Marc Glisse
2014-10-31 11:12                           ` Richard Biener
2014-11-02 10:34                             ` Marc Glisse
2014-11-03  9:06                               ` Richard Biener
2014-10-31 21:16                           ` Jeff Law
2014-10-16 17:23             ` Jeff Law
2014-10-18 22:23   ` Marc Glisse
2014-10-24 20:19     ` Jeff Law

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=alpine.DEB.2.11.1409071654310.5483@laptop-mg.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.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).