public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: martin@xemacs.org To: gcc-gnats@gcc.gnu.org Subject: c++/8935: Failure to apply trivial peephole optimizations Date: Sat, 14 Dec 2002 02:46:00 -0000 [thread overview] Message-ID: <20021214104221.23290.qmail@sources.redhat.com> (raw) >Number: 8935 >Category: c++ >Synopsis: Failure to apply trivial peephole optimizations >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: pessimizes-code >Submitter-Id: net >Arrival-Date: Sat Dec 14 02:46:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Martin Buchholz >Release: gcc-3.2.1 >Organization: >Environment: Linux x86 >Description: Some very easy optimizations are being missed on x86 at -O3. The x86 asm for a function that effectively does { return 0; } is pushl %ebp xorl %eax, %eax movl %esp, %ebp subl $40, %esp movl %ebp, %esp popl %ebp ret A trivial peephole optimizer with a two instruction window can convert the sequence subl $40, %esp movl %ebp, %esp to movl %ebp, %esp Subsequently, we can convert the sequence movl %esp, %ebp movl %ebp, %esp to movl %esp, %ebp leaving us with pushl %ebp xorl %eax, %eax movl %esp, %ebp subl $40, %esp movl %ebp, %esp popl %ebp ret which is the asm generated for other functions. Detail: gcc 3.2.1, x86 Linux, g++ -O3 Entire source files follows: struct S { public: enum E { E1, E2 } e; S (enum E ee) : e (ee) {} S (const S&other); operator E () { return e; } }; bool foo () { return S::E1 == S::E2; } bool bar () { return S::E(S(S::E1)) == S::E(S(S::E2)); } >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2002-12-14 10:46 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=20021214104221.23290.qmail@sources.redhat.com \ --to=martin@xemacs.org \ --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).