This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54087] __atomic_fetch_add does not use xadd instruction
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 02 Aug 2012 17:35:30 +0000
- Subject: [Bug target/54087] __atomic_fetch_add does not use xadd instruction
- Auto-submitted: auto-generated
- References: <bug-54087-4@http.gcc.gnu.org/bugzilla/>
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.