This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/43965] New: doubled code (x86)
- From: "hartmut dot schirmer at arcormail dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 May 2010 05:45:37 -0000
- Subject: [Bug c++/43965] New: doubled code (x86)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
On this test case
---
struct Vector
{
int size( void ) const
{
return mSize ? *mSize : 0 ;
}
int* mSize;
};
int diff(const Vector& a, const Vector& b)
{
if (a.size() != b.size())
{
return a.size() - b.size();
}
return 0;
}
---
gcc omits the following code:
__Z4diffRK6VectorS1_:
pushl %ebp #
movl %esp, %ebp #,
pushl %esi #
xorl %esi, %esi # D.2130
pushl %ebx #
movl 8(%ebp), %eax # a, a
movl (%eax), %ecx # a_2(D)->mSize, D.2131
testl %ecx, %ecx # D.2131
je L2 #,
movl (%ecx), %esi #* D.2131, D.2130
L2:
movl 12(%ebp), %eax # b, b
xorl %ebx, %ebx # D.2134
movl (%eax), %edx # b_4(D)->mSize, D.2135
testl %edx, %edx # D.2135
je L3 #,
movl (%edx), %ebx #* D.2135, D.2134
L3:
xorl %eax, %eax # D.2116
cmpl %ebx, %esi # D.2134, D.2130
je L4 #,
testl %ecx, %ecx # D.2131
je L5 #,
movl (%ecx), %eax #* D.2131, D.2138
L5:
xorl %ecx, %ecx # D.2142
testl %edx, %edx # D.2135
je L6 #,
movl (%edx), %ecx #* D.2135, D.2142
L6:
subl %ecx, %eax # D.2142, D.2116
L4:
popl %ebx #
popl %esi #
popl %ebp #
ret
Basicly code following the cmpl after L3 up to L6 is needless,
subl could operate on same values as cmpl did
# GNU C++ (GCC) version 4.5.0 (mingw32)
# compiled by GNU C version 4.5.0, GMP version 5.0.1, MPFR version 2.4.1,
MPC version 0.8.1
# GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
# options passed: -fpreprocessed yy4.ii -march=atom -O2 -fverbose-asm
--
Summary: doubled code (x86)
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hartmut dot schirmer at arcormail dot de
GCC build triplet: i686-pc-mingw32
GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43965