On Wed, Oct 19, 2011 at 08:05:26AM -0700, Richard Henderson wrote: > In one of Andrew's previous ideas he split _ace into two separate builtins: > > T __atomic_compare_exchange (T* mem, T oldval, T newval, ...); > bool __atomic_compare_exchange_success (T); > > where the input to __ace_success *must* be the ssa_name output of _ace. > We then use magic to wire up both results to the same rtl pattern. > > We can still probably do something exactly like that, but Andrew is > concerned about getting the generic user-level interface correct.
Until we support more than one lhs stmts in GIMPLE, there is always an option to return a _Complex or vector or struct from the builtin, where one part of the return value would contain the bool whether it has succeeded and the other part would contain the old value. That of course doesn't need to be the externally exposed builtin, it could be an internal builtin (perhaps with space in the name or something). Or perhaps the user builtin if (__atomic_compare_exchange (&mem, &expected, newval)) could be lowered into tmp1 = expected; tmp2 = __atomic val_compare_exchange (&mem, tmp1, newval); expected = tmp2; if (tmp1 == tmp2) if it is known that it can be handled by the backend. Jakub