--- /gcc/config/sh/sh.c 2008-03-25 14:36:14.000000000 +0530 +++ /gcc/config/sh/sh.c 2008-03-25 14:37:25.000000000 +0530 @@ -10591,6 +10591,9 @@ sh_expand_t_scc (enum rtx_code code, rtx val = INTVAL (sh_compare_op1); if ((code == EQ && val == 1) || (code == NE && val == 0)) emit_insn (gen_movt (result)); + else if (TARGET_SH2A && ((code == EQ && val == 0) + || (code == NE && val == 1))) + emit_insn (gen_movrt (result)); else if ((code == EQ && val == 0) || (code == NE && val == 1)) { emit_insn (gen_rtx_CLOBBER (VOIDmode, result)); --- /gcc/config/sh/sh.md 2008-03-25 14:36:51.000000000 +0530 +++ /gcc/config/sh/sh.md 2008-03-25 14:38:04.000000000 +0530 @@ -3326,6 +3326,15 @@ label: xori %1, %2, %0" [(set_attr "type" "arith_media")]) +;; Store the complements of the T bit in a register. +(define_insn "xorsi3_movrt" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (xor:SI (reg:SI T_REG) + (const_int 1)))] + "TARGET_SH2A" + "movrt\\t%0" + [(set_attr "type" "arith")]) + (define_insn "xordi3" [(set (match_operand:DI 0 "arith_reg_dest" "=r,r") (xor:DI (match_operand:DI 1 "arith_reg_operand" "%r,r") @@ -9545,6 +9554,16 @@ mov.l\\t1f,r0\\n\\ "movt %0" [(set_attr "type" "arith")]) +;; complements the T bit and stores the result in a register +(define_insn "movrt" + [(set (match_operand:SI 0 "arith_reg_dest" "=r") + (if_then_else (eq:SI (reg:SI T_REG) (const_int 0)) + (const_int 1) + (const_int 0)))] + "TARGET_SH2A" + "movrt\\t%0" + [(set_attr "type" "arith")]) + (define_expand "seq" [(set (match_operand:SI 0 "arith_reg_dest" "") (match_dup 1))] --- /gcc/testsuite/gcc.target/sh/sh2a-movrt.c 1970-01-01 05:30:00.000000000 +0530 +++ /gcc/testsuite/gcc.target/sh/sh2a-movrt.c 2008-03-25 14:37:25.000000000 +0530 @@ -0,0 +1,16 @@ +/* Testcase to check generation of a SH2A specific instruction for + 'MOVRT Rn'. */ +/* { dg-do assemble {target sh*-*-*}} */ +/* { dg-options "-O1" } */ +/* { dg-skip-if "" { "sh*-*-*" } "*" "-m2a -m2a-nofpu -m2a-single -m2a-single-only" } */ +/* { dg-final { scan-assembler "movrt"} } */ + + +int +foo (void) +{ + int a, b, g, stop; + if (stop = ((a + b) % 2 != g)); + return stop; +} +