[LLVMdev] cmpxchg instruction with pointer operands

Philip Reames listmail at philipreames.com
Tue Sep 9 19:49:51 PDT 2014


On 09/09/2014 03:58 AM, David Chisnall wrote:
> On 8 Sep 2014, at 21:09, Philip Reames <listmail at philipreames.com> wrote:
>
>> This has been brought up a couple times now.  I don't believe anyone has voiced strong objection to having a variant which directly takes pointers, but no one has proposed a patch either.
>>
>> p.s. I'm solidly in the "it would be nice to see" camp.  For much the same reasons as David.
> I'm also in two minds about whether it would be a good idea to allow the atomic cmpxchg to support arbitrary types.  With RTM, for example, you might want to lower an atomic exchange of a structure to a begin-transaction, memcmp, memcpy, end-transaction block.  Elsewhere, you lower it to a call to a helper function that does the right thing.  Currently, this decision is made in the front end, but that removes some potential optimisation opportunities.
Again, agreed.  Though, frankly, this is much less important to me.

One subset of David's proposal that would be very useful is to allow 
cmpxchg of arbitrary types whose size is less-than-equal the largest the 
target supports.  In practice, this is what the frontend does anyways 
(with the additions of casts).  It exposes some target specific details 
in the IR, but no more than is already exposed.

Worth noting is that all of the points we've made here w.r.t. cmpxchg 
also apply to ordered ("atomic") loads and stores.

Philip




More information about the llvm-dev mailing list