This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] s390: support for __sync_lock_test_and_set
- From: Adrian Straetling <straetling at de dot ibm dot com>
- To: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org, "Weigand, Ulrich" <uweigand at de dot ibm dot com>
- Date: Tue, 4 Oct 2005 22:38:08 +0200
- Subject: Re: [patch] s390: support for __sync_lock_test_and_set
- References: <20050930130511.GA4305@de.ibm.com> <20051002034141.GA22940@redhat.com>
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.