Decrementing of the field causes 3 instructions for what could be one on i686
target.
--- testcase ---
struct C { int fld; };
extern void a();
extern void b();
void f(C *c) {
if (--c->fld > 0) {
a();
} else {
a();
}
}
--- result of assembly with -O5 option ---
_Z1fP1C:
.LFB0:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
subl $8, %esp
.LCFI2:
movl 8(%ebp), %edx
movl (%edx), %eax ; XXX
decl %eax ; XXX these three should be one insn
movl %eax, (%edx) ; XXX
leave
jmp _Z1av
--
Summary: field in-place decrement isn't optimized
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yuri at tsoft dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43503