Optimization of conditional stores (was: Re: [PATCH] Add adaptive elision to rwlocks)
Andi Kleen
andi@firstfloor.org
Mon Apr 7 16:11:00 GMT 2014
> If the compiler can prove that `ptr' must be pointing to writeable location
> (for instance if there is a preceding (dominating) unconditional store), it
> can, and likely will, perform the optimization.
Except it's not an optimization, but a pessimization
Which compiler would do that? It sounds very broken to me.
>
> I would also suggest making the intent (perform the store only when necessary)
> explicit, and make sure to disallow the compiler optimization, for example:
>
> if (*ptr != value)
> *(volatile typeof(*ptr)*)ptr = value;
That's really ugly.
-Andi
More information about the Libc-alpha
mailing list