re PR target/49263 (SH Target: underutilized "TST #imm, R0" instruction)
authorOleg Endo <olegendo@gcc.gnu.org>
Mon, 26 Jan 2015 23:56:05 +0000 (23:56 +0000)
committerOleg Endo <olegendo@gcc.gnu.org>
Mon, 26 Jan 2015 23:56:05 +0000 (23:56 +0000)
gcc/
PR target/49263
* config/sh/sh.c (sh_split_treg_set_expr): Invoke emit_insn before
remove_insn.
* config/sh/sh.md (tstsi_t): Don't try to optimize constant with right
shifts if it already fits into K08.

gcc/testsuite/
PR target/49263
* gcc.target/sh/pr49263-4.c: New.

From-SVN: r220144

gcc/ChangeLog
gcc/config/sh/sh.c
gcc/config/sh/sh.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/sh/pr49263-4.c [new file with mode: 0644]

index 8cf5d5b104a1684a9254f1d2cba9138a4061467f..e44eb7360afddd1d3de88586a52532c3361ab5e5 100644 (file)
@@ -1,3 +1,11 @@
+2015-01-26  Oleg Endo  <olegendo@gcc.gnu.org>
+
+       PR target/49263
+       * config/sh/sh.c (sh_split_treg_set_expr): Invoke emit_insn before
+       remove_insn.
+       * config/sh/sh.md (tstsi_t): Don't try to optimize constant with right
+       shifts if it already fits into K08.
+
 2015-01-26  Jakub Jelinek  <jakub@redhat.com>
 
        PR ipa/64730
index 7d07634abe3518e1a0e3f01489fb3f8147d73d76..a7427f56288dcb7cf17f39ba101387032a7bae0e 100644 (file)
@@ -14466,6 +14466,8 @@ sh_split_treg_set_expr (rtx x, rtx_insn* curr_insn)
        fprintf (dump_file, "trailing nott insn %d\n", INSN_UID (nott_insn));
     }
 
+  emit_insn (insnlist.first);
+
   if (nott_insn != NULL && append_nott)
     {
       if (dump_file)
@@ -14475,8 +14477,6 @@ sh_split_treg_set_expr (rtx x, rtx_insn* curr_insn)
       append_nott = false;
     }
 
-  emit_insn (insnlist.first);
-
   if (append_nott)
     nott_insn = emit_insn (gen_nott (get_t_reg_rtx ()));
 
index 956d1ef672ef6e322d1316bb24240f457edeae4d..4a39e12d8db29fb070b3711d04b4334e479ca54e 100644 (file)
      variant instead and load the constant into a reg.  For that we'd need
      to do some analysis.  */
 
-  if ((op1val & 0xFFFF) == 0
-      && CONST_OK_FOR_K08 (op1val >> 16) && optimize_size)
+  if (CONST_OK_FOR_K08 (op1val))
+    {
+      /* Do nothing.  */
+    }
+  else if ((op1val & 0xFFFF) == 0
+          && CONST_OK_FOR_K08 (op1val >> 16) && optimize_size)
     {
       /* Use a swap.w insn to do a shift + reg copy (to R0) in one insn.  */
       op1val = op1val >> 16;
index cf72ea9264864c9c096bd77ad266c1d9065e546b..c66df2007d6fafbd9f7ddea612a11dffb1117230 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-26  Oleg Endo  <olegendo@gcc.gnu.org>
+
+       PR target/49263
+       * gcc.target/sh/pr49263-4.c: New.
+
 2015-01-26  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/62044
diff --git a/gcc/testsuite/gcc.target/sh/pr49263-4.c b/gcc/testsuite/gcc.target/sh/pr49263-4.c
new file mode 100644 (file)
index 0000000..cbba68b
--- /dev/null
@@ -0,0 +1,10 @@
+/* Verify that TST #imm, R0 instruction is generated if the constant
+   allows it when compiling for -Os.  */
+/* { dg-do compile }  */
+/* { dg-options "-Os" } */
+/* { dg-final { scan-assembler-not "and" } } */
+/* { dg-final { scan-assembler-not "extu" } } */
+/* { dg-final { scan-assembler-not "exts" } } */
+/* { dg-final { scan-assembler-not "shlr" } } */
+
+#include "pr49263.c"