https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68084
Bug ID: 68084 Summary: Inverted conditions generated for x86 inline assembly "flag output constraints" Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: richardpku at gmail dot com Target Milestone: --- I have been trying out the new "flag output constraints" feature in inline assembly ("=@ccCC"), and have found GCC sometimes incorrectly generates inverted conditions in assembler code. The minimal test case is as follows: _Bool dec_ref(unsigned *p) { _Bool r; asm ("cmp %2, %1" : "=@ccae"(r) : "m"(*p), "ri"(2)); if (r) return __atomic_sub_fetch(p, 1, __ATOMIC_RELEASE) == 0; return 1; } GCC (6.0.0 20151024) generates the following assembler code: dec_ref: cmp $2, (%rdi) movl $1, %eax jc .L7 rep ret .p2align 4,,10 .p2align 3 .L7: lock subl $1, (%rdi) sete %al ret where "jc" is incorrect. It should be "jnc". Interestingly, GCC generates the expected code if "=@ccae" is written as "=@ccnb" (ae and nb are synonymous).