From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25897 invoked by alias); 16 Jan 2013 14:21:38 -0000 Received: (qmail 25702 invoked by uid 48); 16 Jan 2013 14:20:57 -0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/3713] Pointers to functions or member functions are not folded or inlined Date: Wed, 16 Jan 2013 14:21: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-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jamborm 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 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: 2013-01/txt/msg01514.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3713 --- Comment #31 from Jan Hubicka 2013-01-16 14:20:46 UTC --- Well, after early optimizations we get: int main() () { struct Foo x; void Foo:: (const struct Foo *) * iftmp.0; long int _3; long int _4; int (*__vtbl_ptr_type) () * _5; long int _6; sizetype _7; int (*__vtbl_ptr_type) () * _8; : _3 = (long int) Bar; _4 = _3 & 1; if (_4 == 0) goto ; else goto ; : _5 = MEM[(int (*__vtbl_ptr_type) () * *)&x]; that is only later, at ccp2 times turned int int main() () { struct Foo x; long int _3; : _3 = (long int) Bar; Foo::Bar (&x); x ={v} {CLOBBER}; return 0; } ccp1 s not able to do this because it still sees: int main() () { struct { void Foo:: (const struct Foo *) * __pfn; long int __delta; } y; struct Foo x; void Foo:: (const struct Foo *) * iftmp.0; void Foo:: (const struct Foo *) * _5; long int _6; long int _7; long int _9; sizetype _10; struct Foo * _11; int (*__vtbl_ptr_type) () * _12; void Foo:: (const struct Foo *) * _13; long int _14; long int _15; sizetype _16; int (*__vtbl_ptr_type) () * _17; long int _19; sizetype _20; const struct Foo * _21; : y.__pfn = Bar; y.__delta = 0; _5 = y.__pfn; _6 = (long int) _5; _7 = _6 & 1; if (_7 == 0) goto ; else goto ; This is fixed by SRA to: : y$__pfn_4 = Bar; y$__delta_3 = 0; _5 = y$__pfn_4; _6 = (long int) _5; _7 = _6 & 1; if (_7 == 0) goto ; else goto ; : iftmp.0_8 = y$__pfn_4; Richi, is there chance for subsequent FRE to catch this?