This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Optimization of conditional stores (was: Re: [PATCH] Add adaptive elision to rwlocks)
- From: Andi Kleen <andi at firstfloor dot org>
- To: Alexander Monakov <amonakov at ispras dot ru>
- Cc: Roland McGrath <roland at hack dot frob dot com>, Andi Kleen <ak at linux dot intel dot com>, Andi Kleen <andi at firstfloor dot org>, libc-alpha at sourceware dot org
- Date: Mon, 7 Apr 2014 18:10:55 +0200
- Subject: Re: Optimization of conditional stores (was: Re: [PATCH] Add adaptive elision to rwlocks)
- Authentication-results: sourceware.org; auth=none
- References: <1396652083-18920-1-git-send-email-andi at firstfloor dot org> <20140404234516 dot 3DFAD74446 at topped-with-meat dot com> <20140405003759 dot GQ32556 at tassilo dot jf dot intel dot com> <20140405044201 dot 9B44D74445 at topped-with-meat dot com> <alpine dot LNX dot 2 dot 00 dot 1404071824530 dot 2531 at monopod dot intra dot ispras dot ru>
> 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