linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Rydh <samuel@ibrium.se>
To: Franz Sirl <Franz.Sirl-ppc@lauterbach.com>
Cc: linuxppc-dev@lists.linuxppc.org
Subject: Re: asm inline
Date: Mon, 2 Dec 2002 18:00:17 +0100	[thread overview]
Message-ID: <20021202170017.GA8469@ibrium.se> (raw)
In-Reply-To: <5.2.0.9.2.20021202155713.01d9b7e8@mail.lauterbach.com>


On Mon, Dec 02, 2002 at 04:12:27PM +0100, Franz Sirl wrote:
> >The compiler does the right thing if -fno-strict-aliasing is used or
> >if 'int b' is replaced by 'ulong b'.
>
> Well, the compiler was right before and as Andreas said, you are wrong. In
> C *(ulong*)&B and *&B are different unrelated objects and the compiler
> optimizes accordingly.

Indeed. A quick check of the ISO C99 standard revealed that the compiler is
allowed to distinguish between int and long even though they share the
same representation on a particular arch.

> Besides the fact that it's almost always right in low-level inline assembly
> to use __asm__ __volatile__ (because without the __volatile__ the __asm__
> maybe hoisted out of loops if the compiler thinks it's a loop invariant),

...which is desirable in this case. The st_le32 inline is just an efficient
way to flip the endian and is not supposted to have any undeclared
side effects (like touching hardware).

/Samuel


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

  reply	other threads:[~2002-12-02 17:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-29 16:08 asm inline Samuel Rydh
2002-11-29 16:21 ` Gabriel Paubert
2002-11-29 17:49   ` Samuel Rydh
2002-12-02 11:17     ` Franz Sirl
2002-12-02 13:11       ` Samuel Rydh
2002-12-02 13:35         ` Andreas Schwab
2002-12-02 14:14           ` Kevin B. Hendricks
2002-12-02 14:29             ` Andreas Schwab
2002-12-02 14:37               ` Kevin B. Hendricks
2002-12-02 14:51                 ` Franz Sirl
2002-12-02 15:08                   ` Kevin B. Hendricks
2002-12-02 15:11                   ` Kevin B. Hendricks
2002-12-02 15:35                     ` Franz Sirl
2002-12-02 15:45                       ` Kevin B. Hendricks
2002-12-02 15:12         ` Franz Sirl
2002-12-02 17:00           ` Samuel Rydh [this message]
2002-12-02 17:53             ` Gabriel Paubert
2002-12-02 19:17               ` Samuel Rydh
2002-11-29 16:30 ` Benjamin Herrenschmidt
2002-12-02 14:29   ` Gabriel Paubert

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=20021202170017.GA8469@ibrium.se \
    --to=samuel@ibrium.se \
    --cc=Franz.Sirl-ppc@lauterbach.com \
    --cc=linuxppc-dev@lists.linuxppc.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 NNTP newsgroup(s).