Note: I'm not 100% sure the transformation I'm proposing is correct, or profitable. If it's not feel free to close.
Consider the typical Go CAS loop:
On x64, this gets compiled to: (https://godbolt.org/z/7905Kp)
There are 3 things that jump out:
Rewritten, the loop could become:
The text was updated successfully, but these errors were encountered:
This would be nice to fix. There's even a TODO in the code:
The restriction mentioned may still be a problem. Memory-using ops can now generate flags, but I think it would still be a problem for memory-generating ops.
I'm not particularly worried about either of these. The loop should only execute once in typical situations (and if it doesn't, you have bigger problems).