This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/44194] struct returned by value generates useless stores


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

--- Comment #17 from Easwaran Raman <eraman at google dot com> 2011-04-21 00:20:51 UTC ---
On Sun, Apr 17, 2011 at 3:45 AM, rguenther at suse dot de
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44194
>
> --- Comment #16 from rguenther at suse dot de <rguenther at suse dot de> 2011-04-17 10:44:02 UTC ---
> On Fri, 15 Apr 2011, eraman at google dot com wrote:
>
>> 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?
>
> No, the version with || should be ok. ÂThe dt_parm argument does
> not escape at the _gfortran_st_write call site because this
> intrinsic function has a ".wW" fnspec attribute which specifies
> the arguments do not escape. ÂWhat you indeed need to do in
> addition to the escaped solution query is walk over all function
> arguments and see if there is one that aliases 'base'. ÂThat
> may not be easily possible on RTL though. ÂOn the tree level
> we have a separate points-to set for such call clobbers/uses
> but we do not preserve it for RTL.

Is it ok to make calls whose arg(s) have EAF_NOESCAPE kill all
locations off the frame in addition to killing all locations that
potentially escape (using the || case you suggested)? Will it be
better or worse than just checking !may_be_aliased (base) alone?

Thanks,
Easwaran


> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]