From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22984 invoked by alias); 17 Apr 2011 10:47:10 -0000 Received: (qmail 22974 invoked by uid 22791); 17 Apr 2011 10:47:10 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_FN X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Apr 2011 10:46:56 +0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/44194] struct returned by value generates useless stores X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sun, 17 Apr 2011 10:47:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01753.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44194 --- Comment #16 from 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 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 changed: > > > > > > What |Removed |Added > > > ---------------------------------------------------------------------------- > > > CC| |eraman at google dot com > > > > > > --- Comment #13 from Easwaran Raman 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] ) [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.