OSDN Git Service

* config/sh/sh.c (expand_cbranchdi4): Use a scratch register
authorkkojima <kkojima@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 May 2009 12:53:22 +0000 (12:53 +0000)
committerkkojima <kkojima@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 May 2009 12:53:22 +0000 (12:53 +0000)
for the none zero constant operand except for EQ and NE
comprisons even when the first operand is R0.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147661 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/sh/sh.c

index b769bcc..575773f 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-18  Kaz Kojima  <kkojima@gcc.gnu.org>
+
+       * config/sh/sh.c (expand_cbranchdi4): Use a scratch register
+       for the none zero constant operand except for EQ and NE
+       comprisons even when the first operand is R0.
+
 2009-05-18  Andreas Krebbel  <krebbel1@de.ibm.com>
 
        * config/s390/2064.md: Remove trailing whitespaces.
index 79343bf..363934d 100644 (file)
@@ -1632,7 +1632,8 @@ expand_cbranchdi4 (rtx *operands, enum rtx_code comparison)
   operands[2] = op2h;
   operands[4] = NULL_RTX;
   if (reload_completed
-      && ! arith_reg_or_0_operand (op2h, SImode) && true_regnum (op1h)
+      && ! arith_reg_or_0_operand (op2h, SImode)
+      && (true_regnum (op1h) || (comparison != EQ && comparison != NE))
       && (msw_taken != LAST_AND_UNUSED_RTX_CODE
          || msw_skip != LAST_AND_UNUSED_RTX_CODE))
     {
@@ -1662,8 +1663,12 @@ expand_cbranchdi4 (rtx *operands, enum rtx_code comparison)
   if (lsw_taken != LAST_AND_UNUSED_RTX_CODE)
     {
       if (reload_completed
-         && ! arith_reg_or_0_operand (op2l, SImode) && true_regnum (op1l))
-       operands[4] = scratch;
+         && ! arith_reg_or_0_operand (op2l, SImode)
+         && (true_regnum (op1l) || (lsw_taken != EQ && lsw_taken != NE)))
+       {
+         emit_move_insn (scratch, operands[2]);
+         operands[2] = scratch;
+       }
       expand_cbranchsi4 (operands, lsw_taken, lsw_taken_prob);
     }
   if (msw_skip != LAST_AND_UNUSED_RTX_CODE)