[Bug target/54087] __atomic_fetch_add does not use xadd instruction
ubizjak at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Aug 2 17:36:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54087
--- Comment #5 from Uros Bizjak <ubizjak at gmail dot com> 2012-08-02 17:35:30 UTC ---
Created attachment 27927
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27927
Patch that introduces atomic_fetch_sub<mode> with const_int operands
This patch introduces atomic_fetch_sub<mode>:
--cut here--
(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 "const_int_operand")))
(clobber (reg:CC FLAGS_REG))]
"TARGET_XADD"
{
/* Avoid overflows. */
if (mode_signbit_p (<MODE>mode, operands[2]))
FAIL;
operands[2] = negate_rtx (<MODE>mode, operands[2]);
emit_insn (gen_atomic_fetch_add<mode> (operands[0], operands[1],
operands[2], operands[3]));
DONE;
})
--cut here--
We have to take care of overflows, so we can handle only const_int operands
with known-to-be overflow free values.
More information about the Gcc-bugs
mailing list