uweigand wrote:

Hmm, interesting.  Not sure this difference is observable under normal 
circumstances, but if the z/OS builtins are guaranteed to perform the store 
unconditionally, I agree this should be followed.

That said, I guess it would still in principle be possible to achieve the same 
effect, using the old-style GCC `__sync_val_compare_and_swap` builtin:

```
unsigned int old, mem, newval;

int test_atomic() {
    unsigned int oldval = old;
    unsigned int memval = __sync_val_compare_and_swap(&mem, oldval, newval);
    old = memval;
    return memval != oldval;
}
```

However, with the current back-end it seems you'll be getting slightly less 
efficient assembler; this could likely be fixed in the back-end, but you'd 
still have to rely on optimization being enabled.

In the end, I guess having this as separate builtins is fine with me.



https://github.com/llvm/llvm-project/pull/202362
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to