From: Ian Worthington <ianworthington@yahoo.com>
To: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: asm() / goto() concern
Date: Tue, 24 May 2022 09:02:00 +0000 (UTC) [thread overview]
Message-ID: <1538337561.2146473.1653382920615@mail.yahoo.com> (raw)
In-Reply-To: <1538337561.2146473.1653382920615.ref@mail.yahoo.com>
I'm trying to write some inline assembler but I see that asm() does not support branching to labels, and that asm goto() does not support output (at least prior to gcc 11).
If I tie them together by declaring an output of the asm() as an input to asm goto() I assume that this will prevent the optimiser from reordering them, but how can I ensure that they are run without any intervening instructions if the goto() has a dependency on the cc generated by the asm(), eg:
asm ( "algr %[rs],%[rb] \n\t"
: [rs] "+r" (sum) // output
: [rb] "r" (u64b) // input
);
asm goto ( "bc 3,%l[done]" // branch if carry bit set (cc 2 or 3)
: // output
: [rs] "r" (sum) // input: ensure this comes after the algr
: // clobbers
: done
);
Best wishes / Mejores deseos / Meilleurs vœux
Ian ...
next parent reply other threads:[~2022-05-24 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1538337561.2146473.1653382920615.ref@mail.yahoo.com>
2022-05-24 9:02 ` Ian Worthington [this message]
2022-05-24 20:56 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1538337561.2146473.1653382920615@mail.yahoo.com \
--to=ianworthington@yahoo.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).