public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/68084] New: Inverted conditions generated for x86 inline assembly "flag output constraints"
@ 2015-10-25  1:25 richardpku at gmail dot com
  2015-10-25  7:52 ` [Bug inline-asm/68084] " gccbugzilla at limegreensocks dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: richardpku at gmail dot com @ 2015-10-25  1:25 UTC (permalink / raw)
  To: gcc-bugs

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).


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-25 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-25  1:25 [Bug inline-asm/68084] New: Inverted conditions generated for x86 inline assembly "flag output constraints" richardpku at gmail dot com
2015-10-25  7:52 ` [Bug inline-asm/68084] " gccbugzilla at limegreensocks dot com
2015-10-25 13:12 ` ubizjak at gmail dot com
2015-10-25 13:24 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).