This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25230] New: __sync_add_and_fetch cannot use condition flags from subl
- From: "bcrl at kvack dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Dec 2005 20:09:16 -0000
- Subject: [Bug c/25230] New: __sync_add_and_fetch cannot use condition flags from subl
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The program below should generate code that looks something like:
fput:
addl $-1,(%rdi)
jne .L4
jmp release
.L4:
ret
But instead generates:
fput:
movl $-1, %eax
lock
xaddl %eax, (%rdi)
decl %eax
jne .L4
jmp release
.p2align 4,,7
.L4:
rep ; ret
test program:
struct file {
int counter;
};
void release(struct file *file);
void fput(struct file *file)
{
if (__sync_add_and_fetch(&file->counter, -1) == 0)
release(file);
}
--
Summary: __sync_add_and_fetch cannot use condition flags from
subl
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bcrl at kvack dot org
GCC build triplet: x86_64-unknown-linux
GCC host triplet: x86_64-unknown-linux
GCC target triplet: x86_64-unknown-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25230