This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/30455] New: i386 generates unnecessary TEST instructions for arithmetic ops on memory
- From: "nmiell at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jan 2007 06:33:02 -0000
- Subject: [Bug target/30455] New: i386 generates unnecessary TEST instructions for arithmetic ops on memory
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the following function:
int add_zf(int *x, int y, int a, int b)
{
if ((*x += y) == 0)
return a;
else
return b;
}
Ideally, it should produce (modulo cmov verses branches / scheduling issues):
addl %esi, (%rdi)
movl %edx, %eax
cmovne %ecx, %eax
ret
Instead, it produces:
addl (%rdi), %esi # reversed
movl %edx, %eax
testl %esi, %esi # unnecessary
movl %esi, (%rdi) # unnecessary
cmovne %ecx, %eax
ret
This is true of all flags and all arithmetic instructions (afaict).
--
Summary: i386 generates unnecessary TEST instructions for
arithmetic ops on memory
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nmiell at comcast dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30455