From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26644 invoked by alias); 10 Jan 2013 13:49:36 -0000 Received: (qmail 26583 invoked by uid 48); 10 Jan 2013 13:49:15 -0000 From: "timo.kreuzer at reactos dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/52381] asm goto output operands diagnostics Date: Thu, 10 Jan 2013 13:49:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: timo.kreuzer at reactos dot org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00934.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52381 Timo Kreuzer changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timo.kreuzer at reactos dot | |org --- Comment #3 from Timo Kreuzer 2013-01-10 13:49:11 UTC --- I support this feature request. As an exmple I'd like to mention the x86 instruction cmpxchg. While GCC has 2 CAS builtins (__sync_bool_compare_and_swap and __sync_val_compare_and_swap) neither of these supports what the x86 cmpxchg instruction does, namely returning both a boolean value indicating success AND the previous value of the memory operand in case of failure. So here's the code that would handle this, if output operand was usable. try_again: // do something asm goto ( "lock cmpxchg %%ecx, %[Destination] \t\n" "jnz %l[try_again] \t\n" : "=c"(Exchange) // <= does not work : [Destination]"m"(Destination), [Comparand]"a"(Comparand), [Exchange]"c"(Exchange) : "memory" : try_again ); Note that in this case the output is needed on the jump path.