Thread (20 messages) flat view 20 messages, 6 authors, 2002-12-02

Re: asm inline

From: Franz Sirl <hidden>
Date: 2002-12-02 15:12:27

At 14:11 02.12.2002, Samuel Rydh wrote:
(unrelated: Does anyone understand why the compiler clears cr4.eq?)
Because you didn't give a prototype for TESTING.
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.
Adding volatile after asm also fixes things (but I did not see
this effect in the unsimplified example).
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),
you are just lucky that the __volatile__ fixes it.

So either fixup your code (with unions or char pointers) to be C compliant
or accept the performance penalty of -fno-strict-aliasing.

Franz.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help