public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "eraman at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/44194] struct returned by value generates useless stores
Date: Fri, 15 Apr 2011 22:27:00 -0000	[thread overview]
Message-ID: <bug-44194-4-q14A6k3LR3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-44194-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44194

--- Comment #15 from Easwaran Raman <eraman at google dot com> 2011-04-15 22:22:15 UTC ---
(In reply to comment #14)
> On Fri, 15 Apr 2011, eraman at google dot com wrote:
> 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44194
> > 
> > Easwaran Raman <eraman at google dot com> changed:
> > 
> >            What    |Removed                     |Added
> > ----------------------------------------------------------------------------
> >                  CC|                            |eraman at google dot com
> > 
> > --- Comment #13 from Easwaran Raman <eraman at google dot com> 2011-04-15 19:18:25 UTC ---
> > Richard, did you mean to write
> > 
> > static bool
> > can_escape (tree expr)
> > {
> >   tree base;
> >   if (!expr)
> >     return true;
> >   base = get_base_address (expr);
> >   if (DECL_P (base)
> >       && (!may_be_aliased (base)
> >           && !pt_solution_includes (&cfun->gimple_df->escaped, base)))
> >     return false;
> >   return true;
> > }
> > 
> > Only case when we know it doesn't escape is if bas is a DECL_P and is not in
> > cfun->gimple_df->escaped and not aliased, right? Actually, I'm wondering if it
> > is sufficient to test just
> > DECL_P (base) && !pt_solution_includes (&cfun->gimple_df->escaped, base).
> 
> No, because if the escaped solution for example includes ANYTHING then
> the test will return true.  That !may-aliased variables are not
> contained in ANYTHING isn't known w/o context.
> 
> Richard.

Correct me if I am wrong. If I understand you right, just using DECL_P (base)
&& !pt_solution_includes is conservative since pt_solution_includes may return
true if the escaped solution contains ANYTHING. To make it less conservative,
you're suggesting

  if (DECL_P (base)
      && (!may_be_aliased (base)
          || !pt_solution_includes (&cfun->gimple_df->escaped, base)))
    return false;

 I tried that and most Fortran tests are failing. One of the tests
(default_format_1.f90) has the following RTL sequence:


(insn 30 29 32 4 (set (mem/s/c:SI (plus:DI (reg/f:DI 20 frame)
                (const_int -608 [0xfffffffffffffda0])) [2
dt_parm.0.common.flags+0 S4 A64])
        (const_int 16512 [0x4080])) default_format_1.inc:56 64
{*movsi_internal}
     (nil))

(insn 32 30 33 4 (set (reg:DI 5 di)
        (reg/f:DI 106)) default_format_1.inc:56 62 {*movdi_internal_rex64}
     (expr_list:REG_EQUAL (plus:DI (reg/f:DI 20 frame)
            (const_int -608 [0xfffffffffffffda0]))
        (nil)))

(call_insn 33 32 36 4 (call (mem:QI (symbol_ref:DI ("_gfortran_st_write")
[flags 0x41]  <function_decl 0x7f301ed12e00 _gfortran_st_write>) [0
_gfortran_st_write S1 A8])
        (const_int 0 [0])) default_format_1.inc:56 618 {*call_0}
     (expr_list:REG_DEAD (reg:DI 5 di)
        (nil))
    (expr_list:REG_DEP_TRUE (use (reg:DI 5 di))
        (nil)))

For the DECL dt_parm, pt_solution_includes (&cfun->gimple_df->escaped, base)
returns false, even though its location is passed as a parameter to
_gfortran_st_write.

I did test  with 
if (DECL_P (base)
      && (!may_be_aliased (base)
          && !pt_solution_includes (&cfun->gimple_df->escaped, base)))

which has no regressions. Is that what you suggest?


  parent reply	other threads:[~2011-04-15 22:27 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-44194-4@http.gcc.gnu.org/bugzilla/>
2011-02-24  5:10 ` jhaberman at gmail dot com
2011-04-12 22:39 ` eraman at google dot com
2011-04-14 18:59 ` eraman at google dot com
2011-04-14 22:22 ` ebotcazou at gcc dot gnu.org
2011-04-15  9:10 ` rguenth at gcc dot gnu.org
2011-04-15 19:19 ` eraman at google dot com
2011-04-15 19:34 ` rguenther at suse dot de
2011-04-15 22:27 ` eraman at google dot com [this message]
2011-04-17 10:47 ` rguenther at suse dot de
2011-04-21  0:22 ` eraman at google dot com
2011-04-21  8:37 ` rguenther at suse dot de
2011-06-14 22:59 ` eraman at gcc dot gnu.org
2011-06-15 16:50 ` ebotcazou at gcc dot gnu.org
2011-06-15 20:35 ` eraman at google dot com
2011-06-15 21:11 ` ebotcazou at gcc dot gnu.org
2011-06-15 23:17 ` xinliangli at gmail dot com
2011-06-16  5:27 ` ebotcazou at gcc dot gnu.org
2011-06-16  7:43 ` xinliangli at gmail dot com
2011-06-16  8:37 ` rguenther at suse dot de
2011-06-16 17:16 ` eraman at google dot com
2011-06-17  8:22 ` rguenther at suse dot de
2011-06-18  9:06 ` xinliangli at gmail dot com
2011-06-18  9:29 ` ebotcazou at gcc dot gnu.org
2011-06-18 16:34 ` xinliangli at gmail dot com
2011-06-20  9:22 ` rguenther at suse dot de
2011-06-20 15:28 ` ebotcazou at gcc dot gnu.org
2011-06-20 16:27 ` xinliangli at gmail dot com
2011-06-20 16:52 ` eraman at google dot com
2011-06-22  7:58 ` ebotcazou at gcc dot gnu.org
2011-07-07 14:58 ` ebotcazou at gcc dot gnu.org
2011-12-05 17:49 ` ebotcazou at gcc dot gnu.org
2012-03-22  9:10 ` rguenth at gcc dot gnu.org
2012-03-22 17:13 ` ubizjak at gmail dot com
2012-03-22 18:35 ` ebotcazou at gcc dot gnu.org
2012-07-02 14:04 ` rguenth at gcc dot gnu.org
2012-08-06  1:23 ` chip at pobox dot com
2012-09-12 22:31 ` ebotcazou at gcc dot gnu.org
2012-09-12 23:22 ` chip at pobox dot com
2012-09-13  0:00 ` ebotcazou at gcc dot gnu.org
2012-09-14 13:30 ` ebotcazou at gcc dot gnu.org
2012-09-14 13:38 ` ebotcazou at gcc dot gnu.org
2012-09-14 17:24 ` chip at pobox dot com
2012-10-21 12:36 ` ebotcazou at gcc dot gnu.org
2012-11-02  0:29 ` eraman at gcc dot gnu.org
2010-05-19  5:06 [Bug rtl-optimization/44194] New: " jhaberman at gmail dot com
2010-05-19  9:39 ` [Bug rtl-optimization/44194] " rguenth at gcc dot gnu dot org
2010-05-19 10:14 ` jakub at gcc dot gnu dot org
2010-05-19 10:22 ` rguenth at gcc dot gnu dot org
2010-07-10  1:38 ` jhaberman at gmail dot com
2010-07-10  1:40 ` pinskia at gcc dot gnu dot org
2010-07-10  1:42 ` pinskia at gcc dot gnu dot org
2010-07-10  1:48 ` jhaberman at gmail dot com

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=bug-44194-4-q14A6k3LR3@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).