This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SH] Use SImode for return value in atomic_compare_and_swap*


The attached patch changes the atomic_compare_and_swap expander/insn to
use SImode for the return value instead of QImode.  This is more aligned
to the other insns which handle the T bit as SImode and avoids some
unnecessary test instructions in cases where the result of the atomic op
in the T bit is re-used.

Tested against rev 184582 with

make -k check RUNTESTFLAGS="--target_board=sh-sim

and no new failures.


2012-02-27  Oleg Endo  <>

	* config/sh/ (atomic_compare_and_swap<mode>): Use SImode
	for return value instead of QImode.
	(atomic_compare_and_swap<mode>_soft): Likewise.
Index: gcc/config/sh/
--- gcc/config/sh/	(revision 184582)
+++ gcc/config/sh/	(working copy)
@@ -109,7 +109,7 @@
   [(plus "add") (minus "sub") (ior "or") (xor "xor") (and "and")])
 (define_expand "atomic_compare_and_swap<mode>"
-  [(match_operand:QI 0 "register_operand" "")		;; bool success output
+  [(match_operand:SI 0 "register_operand" "")		;; bool success output
    (match_operand:I124 1 "register_operand" "")		;; oldval output
    (match_operand:I124 2 "memory_operand" "")		;; memory
    (match_operand:I124 3 "register_operand" "")		;; expected input
@@ -131,7 +131,7 @@
   else if (<MODE>mode == HImode)
     emit_insn (gen_zero_extendhisi2 (gen_lowpart (SImode, operands[1]),
-  emit_insn (gen_movqi (operands[0], gen_rtx_REG (QImode, T_REG)));
+  emit_insn (gen_movsi (operands[0], gen_rtx_REG (SImode, T_REG)));
@@ -144,8 +144,8 @@
    (set (mem:I124 (match_dup 1))
 	(unspec_volatile:I124 [(const_int 0)] UNSPECV_CMPXCHG_2))
-   (set (reg:QI T_REG)
-	(unspec_volatile:QI [(const_int 0)] UNSPECV_CMPXCHG_3))
+   (set (reg:SI T_REG)
+	(unspec_volatile:SI [(const_int 0)] UNSPECV_CMPXCHG_3))
    (clobber (match_scratch:SI 4 "=&u"))
    (clobber (reg:SI R0_REG))
    (clobber (reg:SI R1_REG))]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]