From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16950 invoked by alias); 16 Jan 2014 06:10:48 -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 16917 invoked by uid 48); 16 Jan 2014 06:10:44 -0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/46507] std::get and devirtualization on non-automatic variables Date: Thu, 16 Jan 2014 06:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.6.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc assigned_to everconfirmed 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: 2014-01/txt/msg01650.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46507 Jan Hubicka changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2014-01-16 CC| |hubicka at gcc dot gnu.org, | |rguenther at suse dot de Assignee|unassigned at gcc dot gnu.org |hubicka at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #7 from Jan Hubicka --- OK, GIMPLE representation is pre-inlining as follows: void arg_tuple_test(const std::pair&) (const struct pair & t) { const struct type & _2; const struct type & _3; int (*__vtbl_ptr_type) () * _5; int (*__vtbl_ptr_type) () _6; : _2 = std::get<0ul, A, A> (t_1(D)); _3 = _2; _5 = _3->_vptr.A; _6 = *_5; OBJ_TYPE_REF(_6;(const struct A)_3->0) (_3); return; } Here I do not think we can devirtualize, because std::get can return a derived type in general. After inlining we get: void arg_tuple_test(const std::pair&) (const struct pair & t) { int (*__vtbl_ptr_type) () * _3; int (*__vtbl_ptr_type) () _4; const struct A & _6; : _6 = &t_1(D)->first; _3 = MEM[(const struct type *)t_1(D)]._vptr.A; _4 = *_3; OBJ_TYPE_REF(_4;(const struct A)_6->0) (_6); [tail call] return; } Here we look all the way to figuring out that the object comes as parameter of arg_tuple_test and give up on this point. I think GIMPLE typing rules does not really allow us to take the type from COMPONENT_REF in statement defining _6, so it seems we completely lose track of the type info here. (and it indeed looks like a common case) Richard?