From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113970 invoked by alias); 20 Mar 2015 10:24:58 -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 Received: (qmail 113699 invoked by uid 48); 20 Mar 2015 10:24:53 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59739] missed optimization: attribute ((pure)) with aggregate returns Date: Fri, 20 Mar 2015 10:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords bug_status cc assigned_to short_desc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02088.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59739 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|NEW |ASSIGNED CC|rguenther at suse dot de | Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Summary|missed optimization: |missed optimization: |attribute ((pure)) could be |attribute ((pure)) with |honored more often |aggregate returns --- Comment #4 from Richard Biener --- The issue is rather that value-numbering is SSA based and thus D.2954 = globalStruct (); _10 = D.2954.val; D.2955 = globalStruct (); _12 = D.2955.val; to CSE _12 to _10 we lookup the D.2955.val load and arrive at its def D.2955 = globalStruct (); from where we can't look further. FRE has some tricks to look through aggregate copies but in this case the aggregate copy source is a function call... What we'd really need here is to re-write those aggregate temporaries into SSA form (that also get's us aggregate copyprop for free). We can't have partial defs for those, of course, and we'd have to be careful to not create overlapping life-ranges (because of cost issues - out-of-SSA will make those "registers" memory again). Eventually we could do this re-write into SSA form just for SCCVN ... I don't see how we can easily extend the aggregate copy trick to cover function calls. Mine for now. C testcase: extern void link_error (void); struct X { int i; }; struct X foo (void) __attribute__((pure)); int main() { if (foo ().i != foo ().i) link_error (); return 0; }