https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80080

--- Comment #7 from Dominik Vogt <vogt at linux dot vnet.ibm.com> ---
(In reply to Jakub Jelinek from comment #6)
> I think it depends on what
> (success, old_reg) = compare-and-swap(mem, old_reg, new_reg)
> sets if success is true.  Is there a guarantee that old_reg will be assigned
> whatever has been passed as the second argument in that case on all targets?

Isn't that part of the interface of the atomic_compare_and_swap pattern?

Gccinternals:
> Operand 1 is an output operand which is set to the contents of the memory
> before the operation was attempted. Operand 3 is the value that is
> expected to be in memory.

If the CS instruction on a target does not overwrite the register old_reg with
the memory value before swapping, the target's backend must do that manually, I
think.

Reply via email to