public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls @ 2010-02-07 23:01 matt at use dot net 2010-02-07 23:04 ` [Bug middle-end/42995] " pinskia at gcc dot gnu dot org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: matt at use dot net @ 2010-02-07 23:01 UTC (permalink / raw) To: gcc-bugs Using gcc 4.4.1 under Ubuntu 9.10 on amd64: main.c: #include "database.h" int main() { int my_id = 0; int result_for_my_id = get_data_for(my_id); switch (result_for_my_id) { case 0: return 666; default: return -1; } } database.h: #include <stdlib.h> int get_data_for(int id) { return rand(); } Compiling with: gcc -O2 main.c -o n produces this code: 0000000000400380 <main>: 400380: 48 83 ec 08 sub rsp,0x8 400384: 31 ff xor edi,edi 400386: e8 e5 ff ff ff call 400370 <get_data_for> 40038b: 83 f8 01 cmp eax,0x1 40038e: 19 c0 sbb eax,eax 400390: 48 83 c4 08 add rsp,0x8 400394: 25 9b 02 00 00 and eax,0x29b 400399: 83 e8 01 sub eax,0x1 40039c: c3 ret 40039d: 0f 1f 00 nop DWORD PTR [rax] Note the 3 bytes of padding after the return. I'm confused why inline-small-functions does not inline get_data_for. I tried this experiment: gcc -O2 -finline-functions --param max-inline-insns-auto=20 main.c -o n which produces this code: 0000000000400380 <main>: 400380: 48 83 ec 08 sub rsp,0x8 400384: e8 27 02 00 00 call 4005b0 <rand@plt> 400389: 83 f8 01 cmp eax,0x1 40038c: 19 c0 sbb eax,eax 40038e: 48 83 c4 08 add rsp,0x8 400392: 25 9b 02 00 00 and eax,0x29b 400397: 83 e8 01 sub eax,0x1 40039a: c3 ret 40039b: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0] The padding got larger, but the code is actually smaller. Shouldn't the heuristic used for inline-small-functions have caused get_data_for() to be inlined? This does not appear to be a problem in GCC 4.5.20091228 or 4.3.4. -- Summary: [4.3 regression] inline-small-functions does not inline simple delegation calls Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: matt at use dot net GCC build triplet: x86_64-linux-unknown GCC host triplet: x86_64-linux-unknown GCC target triplet: x86_64-linux-unknown http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42995 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/42995] [4.3 regression] inline-small-functions does not inline simple delegation calls 2010-02-07 23:01 [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls matt at use dot net @ 2010-02-07 23:04 ` pinskia at gcc dot gnu dot org 2010-02-08 10:19 ` [Bug middle-end/42995] [4.4 Regression] " rguenth at gcc dot gnu dot org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu dot org @ 2010-02-07 23:04 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from pinskia at gcc dot gnu dot org 2010-02-07 23:03 ------- >The padding got larger, But the alignment stayed the same. :). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42995 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/42995] [4.4 Regression] inline-small-functions does not inline simple delegation calls 2010-02-07 23:01 [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls matt at use dot net 2010-02-07 23:04 ` [Bug middle-end/42995] " pinskia at gcc dot gnu dot org @ 2010-02-08 10:19 ` rguenth at gcc dot gnu dot org 2010-02-08 10:41 ` rguenth at gcc dot gnu dot org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu dot org @ 2010-02-08 10:19 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from rguenth at gcc dot gnu dot org 2010-02-08 10:19 ------- It doesn't inline it because: Considering inline candidate get_data_for. Not inlining: code size would grow by 3 insns. The callee is estimated to have size 16 while the call costs less. The issue is a missing check for VOID_TYPE_P in estimate_num_insns which has been fixed for 4.5. I have a fix. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Known to fail| |4.4.3 Known to work| |4.3.4 4.5.0 Last reconfirmed|0000-00-00 00:00:00 |2010-02-08 10:19:12 date| | Summary|[4.3 regression] inline- |[4.4 Regression] inline- |small-functions does not |small-functions does not |inline simple delegation |inline simple delegation |calls |calls Target Milestone|--- |4.4.4 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42995 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/42995] [4.4 Regression] inline-small-functions does not inline simple delegation calls 2010-02-07 23:01 [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls matt at use dot net 2010-02-07 23:04 ` [Bug middle-end/42995] " pinskia at gcc dot gnu dot org 2010-02-08 10:19 ` [Bug middle-end/42995] [4.4 Regression] " rguenth at gcc dot gnu dot org @ 2010-02-08 10:41 ` rguenth at gcc dot gnu dot org 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu dot org @ 2010-02-08 10:41 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from rguenth at gcc dot gnu dot org 2010-02-08 10:41 ------- Subject: Bug 42995 Author: rguenth Date: Mon Feb 8 10:41:25 2010 New Revision: 156598 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156598 Log: 2010-02-08 Richard Guenther <rguenther@suse.de> PR middle-end/42995 * gcc.dg/tree-ssa/inline-4.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/inline-4.c Modified: trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42995 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/42995] [4.4 Regression] inline-small-functions does not inline simple delegation calls 2010-02-07 23:01 [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls matt at use dot net ` (2 preceding siblings ...) 2010-02-08 10:41 ` rguenth at gcc dot gnu dot org @ 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu dot org @ 2010-02-08 14:11 UTC (permalink / raw) To: gcc-bugs ------- Comment #4 from rguenth at gcc dot gnu dot org 2010-02-08 14:10 ------- Subject: Bug 42995 Author: rguenth Date: Mon Feb 8 14:10:15 2010 New Revision: 156601 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156601 Log: 2010-02-08 Richard Guenther <rguenther@suse.de> PR middle-end/42995 * tree-inline.c (estimate_move_cost): Assert we are not called with a void type. (estimate_num_insns): Do not count the terminating void_type_node of a function argument type list. Backport from mainline: 2010-01-06 Richard Guenther <rguenther@suse.de> * ipa-inline.c (cgraph_decide_inlining_incrementally): Do not inline regular functions into always-inline functions. 2010-01-05 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42462 * ipa-inline.c (compute_inline_parameters): Pass node->decl instead of current_function_decl to helper functions and macros. * gcc.dg/tree-ssa/inline-4.c: New testcase. * gcc.dg/Wunreachable-2.c: Remove. Added: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/inline-4.c Removed: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/Wunreachable-2.c Modified: branches/gcc-4_4-branch/gcc/ChangeLog branches/gcc-4_4-branch/gcc/ipa-inline.c branches/gcc-4_4-branch/gcc/tree-inline.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42995 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/42995] [4.4 Regression] inline-small-functions does not inline simple delegation calls 2010-02-07 23:01 [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls matt at use dot net ` (3 preceding siblings ...) 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org @ 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org 4 siblings, 0 replies; 6+ messages in thread From: rguenth at gcc dot gnu dot org @ 2010-02-08 14:11 UTC (permalink / raw) To: gcc-bugs ------- Comment #5 from rguenth at gcc dot gnu dot org 2010-02-08 14:11 ------- Fixed. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42995 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-02-08 14:11 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-02-07 23:01 [Bug middle-end/42995] New: [4.3 regression] inline-small-functions does not inline simple delegation calls matt at use dot net 2010-02-07 23:04 ` [Bug middle-end/42995] " pinskia at gcc dot gnu dot org 2010-02-08 10:19 ` [Bug middle-end/42995] [4.4 Regression] " rguenth at gcc dot gnu dot org 2010-02-08 10:41 ` rguenth at gcc dot gnu dot org 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org 2010-02-08 14:11 ` rguenth at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).