search for: newcmp

Displaying 2 results from an estimated 2 matches for "newcmp".

Did you mean: newcomp
2008 Feb 21
0
[LLVMdev] compare and swap
...returned bool could be useful. However, it is > pretty easy to pattern match > CAS -> Compare > in those backends that can save the compare by testing the result of > the store conditional. Food for thought, on x86 it is typical to have a lock-free algorithm like so: int cmp, newcmp = *ptr; do { cmp = newcmp; } while((newcmp = cas(ptr, exch, cmp)) != cmp); Which translates (optimized) into: mov eax, [ptr] loop: lock cmpxchg [ptr], exch jnz loop cmpxchg fills eax with the old [ptr] value and sets ZF on success, so it can be used without extra load and compare instructions....
2008 Feb 21
2
[LLVMdev] compare and swap
On 2/21/08, Torvald Riegel <torvald at se.inf.tu-dresden.de> wrote: > why is the intrinsic name not CAS? And having another version that returns > just a bool might be better in some cases ( 1. does CAS return the value on > all architectures? 2. you can just jump based on a flag and don't need to > compare it again). Just my 2 cents though ... I was going from