public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/14703] Inadequate optimization of inline templated functions Date: Fri, 03 Mar 2006 10:29:00 -0000 [thread overview] Message-ID: <20060303102918.19414.qmail@sourceware.org> (raw) In-Reply-To: <bug-14703-3016@http.gcc.gnu.org/bugzilla/> ------- Comment #7 from rguenth at gcc dot gnu dot org 2006-03-03 10:29 ------- Note that using functions as in fibconst is not really an efficient way to do this. Still, with gcc 4.1.0 you now have the ability to use template<unsigned long long L> inline __attribute__((flatten)) unsigned long long fibconst() { return fibconst<L - 1>() + fibconst<L - 2>(); } which will result in one call in main and a fibconst that returns the constant requested. Of course for big numbers you'll hit interesting quadraticness in time and memory required to build the program - so the limits in place actually prevent you from running into this issue. It's like rguenther@g148:/tmp> ~/bin/maxmem2.sh /space/rguenther/install/gcc-4.1.0/bin/gcc -O2 -S t.C -DVAL=23 total: 149886 kB rguenther@g148:/tmp> ~/bin/maxmem2.sh /space/rguenther/install/gcc-4.1.0/bin/gcc -O2 -S t.C -DVAL=24 total: 238102 kB rguenther@g148:/tmp> ~/bin/maxmem2.sh /space/rguenther/install/gcc-4.1.0/bin/gcc -O2 -S t.C -DVAL=25 total: 385738 kB rguenther@g148:/tmp> ~/bin/maxmem2.sh /space/rguenther/install/gcc-4.1.0/bin/gcc -O2 -S t.C -DVAL=26 total: 623094 kB so, an exponential growth in memory usage due to the way we're doing the inlining. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14703
next prev parent reply other threads:[~2006-03-03 10:29 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-14703-3016@http.gcc.gnu.org/bugzilla/> 2006-03-02 20:25 ` eric-gcc at omnifarious dot org 2006-03-03 10:29 ` rguenth at gcc dot gnu dot org [this message] 2008-09-06 12:39 ` [Bug tree-optimization/14703] [4.4 regression] Inadequate optimization of inline templated functions, infinite loop in ipa-reference and memory hog hubicka at gcc dot gnu dot org 2008-09-06 12:57 ` hubicka at gcc dot gnu dot org 2008-09-06 17:12 ` hubicka at gcc dot gnu dot org 2008-09-06 20:24 ` hubicka at gcc dot gnu dot org 2008-09-11 5:19 ` luisgpm at linux dot vnet dot ibm dot com 2008-09-12 8:34 ` hubicka at gcc dot gnu dot org 2008-09-12 8:40 ` hubicka at gcc dot gnu dot org 2008-09-19 6:23 ` hubicka at gcc dot gnu dot org 2008-11-01 11:52 ` [Bug tree-optimization/14703] " rguenth at gcc dot gnu dot org 2004-03-24 2:25 [Bug c++/14703] New: Inadequate optimization of inline templated functions eric-gcc at omnifarious dot org 2005-02-25 23:49 ` [Bug tree-optimization/14703] " rguenth at gcc dot gnu dot org 2005-05-27 0:18 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20060303102918.19414.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).