On 11/28/2011 02:16 PM, Alan Modra wrote:
> Hmm, I suppose you could argue that powerpc and others ought to not
> generate those three extra instructions when using the return value.
> I'll see about fixing powerpc.

True.  For weak, the value *should* always be used (otherwise the user program 
is broken).

However, we can do better by considering the value to be stored in CR0.  We 
perform the comparison in the loop, which sets CR0 == EQ (true) or NE (false); 
CR0 is set again by the STWCX insn in the same fashion.  So the

      /* ??? It's either this or an unlikely jump over (set bool 1).  */
      x = gen_rtx_EQ (SImode, cond, const0_rtx);
      emit_insn (gen_rtx_SET (VOIDmode, boolval, x));

code currently emitted by rs6000_expand_atomic_compare_and_swap is sufficient, 
and merely needs to be adjusted so that it is computed after label2, and other 
settings to boolval removed.

This may be sufficient for better stong compare-and-swap as well.


r~

Reply via email to