public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: wesslen@users.sourceforge.net To: gcc-gnats@gcc.gnu.org Subject: c++/8781: Pessimization of functional-style code Date: Mon, 02 Dec 2002 02:26:00 -0000 [thread overview] Message-ID: <20021202102342.7326.qmail@sources.redhat.com> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2157 bytes --] >Number: 8781 >Category: c++ >Synopsis: Pessimization of functional-style code >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: pessimizes-code >Submitter-Id: net >Arrival-Date: Mon Dec 02 02:26:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Daniel Wesslén >Release: gcc version 3.3 20021125 (experimental) >Organization: >Environment: CYGWIN_NT-5.1 DANIEL-P4 1.3.17(0.67/3/2) 2002-11-27 18:54 i686 unknown >Description: Functional programming style constructs makes g++ generate unneccesary stores. >How-To-Repeat: A somewhat modified version of the program submitted by AWLaFramboise in http://gcc.gnu.org/ml/gcc/2002-11/msg01012.html follows. Compile this with -O3. /// begin int f(); template<typename predicate> class noop_t { const predicate &pred; public: explicit noop_t(const predicate &p) : pred(p) {} int operator()() const { return pred(); } }; template<typename predicate> inline noop_t<predicate> noop(const predicate pred) { return noop_t<predicate>(pred); } int x() { return (noop(noop(noop(noop(noop(noop(noop(noop(noop(f)))))))))()); } /// end Compiled with -O3, the following code is generated. .globl __Z1xv .def __Z1xv; .scl 2; .type 32; .endef __Z1xv: pushl %ebp movl %esp, %ebp leal -4(%ebp), %ecx leal -12(%ebp), %eax subl $40, %esp movl %ecx, -12(%ebp) leal -8(%ebp), %edx movl %eax, -16(%ebp) leal -16(%ebp), %ecx movl %edx, -4(%ebp) leal -20(%ebp), %eax movl %ecx, -20(%ebp) leal -32(%ebp), %edx movl %eax, -24(%ebp) leal -24(%ebp), %ecx movl $__Z1fv, -8(%ebp) leal -28(%ebp), %eax movl %ecx, -28(%ebp) movl %eax, -32(%ebp) movl %edx, -36(%ebp) call __Z1fv movl %ebp, %esp popl %ebp ret .def __Z1fv; .scl 3; .type 32; .endef >Fix: >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2002-12-02 10:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20021202102342.7326.qmail@sources.redhat.com \ --to=wesslen@users.sourceforge.net \ --cc=gcc-gnats@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).