m68k.c (output_btst): Use `movew to ccr' when useful.
authorPhilippe De Muyter <phdm@macqel.be>
Wed, 18 Apr 2007 20:51:42 +0000 (22:51 +0200)
committerPhilippe De Muyter <phdm@gcc.gnu.org>
Wed, 18 Apr 2007 20:51:42 +0000 (20:51 +0000)
2007-04-18  Philippe De Muyter  <phdm@macqel.be>

* config/m68k/m68k.c (output_btst): Use `movew to ccr' when useful.

From-SVN: r123959

gcc/ChangeLog
gcc/config/m68k/m68k.c

index db9ff5cf8371a6a624953dd44119c8de8b415fae..584dd82a9c46c1de5271e2fcac4c9f0dcf0d12c8 100644 (file)
@@ -1,3 +1,7 @@
+2007-04-18  Philippe De Muyter  <phdm@macqel.be>
+
+       * config/m68k/m68k.c (output_btst): Use `movew to ccr' when useful.
+
 2007-04-18  Dirk Mueller  <dmueller@suse.de>
 
        PR diagnostic/31227
index b450a424d680a7ab1373e28392a4b17f29dd956b..2df2a7c8904e3d53bb32703f1c674226cdfa1384 100644 (file)
@@ -1550,6 +1550,27 @@ output_btst (rtx *operands, rtx countop, rtx dataop, rtx insn, int signpos)
       if (count == 7
          && next_insn_tests_no_inequality (insn))
        return "tst%.b %1";
+      /* Try to use `movew to ccr' followed by the appropriate branch insn.
+         On some m68k variants unfortunately that's slower than btst.
+         On 68000 and higher, that should also work for all HImode operands. */
+      if (TUNE_CPU32 || TARGET_COLDFIRE || optimize_size)
+       {
+         if (count == 3 && DATA_REG_P (operands[1])
+             && next_insn_tests_no_inequality (insn))
+           {
+           cc_status.flags = CC_NOT_NEGATIVE | CC_Z_IN_NOT_N | CC_NO_OVERFLOW;
+           return "move%.w %1,%%ccr";
+           }
+         if (count == 2 && DATA_REG_P (operands[1])
+             && next_insn_tests_no_inequality (insn))
+           {
+           cc_status.flags = CC_NOT_NEGATIVE | CC_INVERTED | CC_NO_OVERFLOW;
+           return "move%.w %1,%%ccr";
+           }
+         /* count == 1 followed by bvc/bvs and
+            count == 0 followed by bcc/bcs are also possible, but need
+            m68k-specific CC_Z_IN_NOT_V and CC_Z_IN_NOT_C flags. */
+       }
 
       cc_status.flags = CC_NOT_NEGATIVE;
     }