[lkml]   [2007]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 0/24] make atomic_read() behave consistently across all architectures
> In a reasonable world, gcc should just make that be (on x86)
> addl $1,i(%rip)
> on x86-64, which is indeed what it does without the volatile. But with
> the
> volatile, the compiler gets really nervous, and doesn't dare do it in
> one
> instruction, and thus generates crap like
> movl i(%rip), %eax
> addl $1, %eax
> movl %eax, i(%rip)
> instead. For no good reason, except that "volatile" just doesn't have
> any
> good/clear semantics for the compiler, so most compilers will just
> make it
> be "I will not touch this access in any way, shape, or form". Including
> even trivially correct instruction optimization/combination.

It's just a (target-specific, perhaps) missed-optimisation kind
of bug in GCC. Care to file a bug report?

> but is
> (again) something that gcc doesn't dare do, since "i" is volatile.

Just nobody taught it it can do this; perhaps no one wanted to
add optimisations like that, maybe with a reasoning like "people
who hit the go-slow-in-unspecified-ways button should get what
they deserve" ;-)


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-08-18 00:57    [W:0.476 / U:0.784 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site