On Fri, Aug 3, 2012 at 5:08 PM, Richard Henderson <[email protected]> wrote:
>>>> The same reasoning goes for dynamic negation: for neg %eax,%eax value
>>>> 0x80000000 stays the same, but we have changed (x)sub to an (x)add in
>>>> the code stream.
>>>
>>> So? Did you think the xadd will trap?
>>
>> No, but can we ignore the fact that we changed xsub -0x80000000, mem
>> to xadd -0x080000000, mem?
>
> Yes, since it'll have the same effect on the bits.
Nice, so we can go with full
--cut here--
;; We can implement atomic_fetch_sub as
;; atomic_fetch_add with negated operand 2.
(define_expand "atomic_fetch_sub<mode>"
[(set (match_operand:SWI 0 "register_operand")
(unspec_volatile:SWI
[(match_operand:SWI 1 "memory_operand")
(match_operand:SI 3 "const_int_operand")] ;; model
UNSPECV_XCHG))
(set (match_dup 1)
(minus:SWI (match_dup 1)
(match_operand:SWI 2 "nonmemory_operand")))
(clobber (reg:CC FLAGS_REG))]
"TARGET_XADD"
{
emit_insn
(gen_atomic_fetch_add<mode> (operands[0], operands[1],
negate_rtx (<MODE>mode, operands[2]),
operands[3]));
DONE;
})
--cut here--
?
Uros.