[patch] s390: support for __sync_lock_test_and_set

Adrian Straetling straetling@de.ibm.com
Tue Oct 4 20:38:00 GMT 2005


On Sat, Oct 01, 2005 at 08:41:41PM -0700, Richard Henderson wrote:
> On Fri, Sep 30, 2005 at 03:05:11PM +0200, Adrian Straetling wrote:
> > However, the test_and_set instruction on s390(x) stores 0xff into the
> > memory location, which should be ok since the documentation states that
> > 'the true contents of the memory are implementation defined'.
> 
> But I would strongly suggest that targets that *can* store a
> particular value do so.  And s390 can, via compare-and-swap.
For HImode and QImode it actually cannot. Hence, we need the pattern for
these modes to support at least the "1" case. In the other cases
compare-and-swap is still available as fallback.
 
> I'd really intended this caveat only be used for weak targets
> that really have no other atomic instructions...

IMHO, if the caller of __sync_lock_test_and_set cannot expect deterministic
behaviour in some cases ("weak targets"), it should not do that in any
case for the sake of portability.

Using this for optimization we could perform a test-and-set(mem,1)
with one instruction instead of an unnecessary compare-and-swap loop.

Ok with all modes?

regards,
Adrian

P.S. Support for only HI/QImode should be doable with a back-end only patch.



More information about the Gcc-patches mailing list