asm inline

Samuel Rydh samuel at
Tue Dec 3 04:00:17 EST 2002

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


** Sent via the linuxppc-dev mail list. See

More information about the Linuxppc-dev mailing list