[Bug rtl-optimization/44194] struct returned by value generates useless stores
eraman at google dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 15 22:27:00 GMT 2011
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?
More information about the Gcc-bugs
mailing list