public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8935: Failure to apply trivial peephole optimizations
@ 2002-12-14 2:46 martin
0 siblings, 0 replies; only message in thread
From: martin @ 2002-12-14 2:46 UTC (permalink / raw)
To: gcc-gnats
>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:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-14 10:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-14 2:46 c++/8935: Failure to apply trivial peephole optimizations martin
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).