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