]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/54236 ([SH] Improve addc and subc insn utilization)
authorOleg Endo <olegendo@gcc.gnu.org>
Wed, 19 Sep 2012 17:45:37 +0000 (17:45 +0000)
committerOleg Endo <olegendo@gcc.gnu.org>
Wed, 19 Sep 2012 17:45:37 +0000 (17:45 +0000)
PR target/54236
* config/sh/sh.md (*addc): Add pattern to handle one bit left shifts.

PR target/54236
* gcc.target/sh/pr54236-1.c (test_08): Add one bit left shift case.

From-SVN: r191489

gcc/ChangeLog
gcc/config/sh/sh.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/sh/pr54236-1.c

index d7918617722d1cdc0c21ba70876de3d11146feed..b4d23116fd42b7bd833ba53ab347011fcee31168 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-19  Oleg Endo  <olegendo@gcc.gnu.org>
+
+       PR target/54236
+       * config/sh/sh.md (*addc): Add pattern to handle one bit left shifts.
+
 2012-09-19  Oleg Endo  <olegendo@gcc.gnu.org>
 
        * config/sh/sh.md (prologue, epilogue): Use braced strings.
index 3497ce80c9a20d3d7b39de963fce7bf41983b6ce..71e758b3aee5dcd147e00209a2c12531916a4087 100644 (file)
                                          (reg:SI T_REG)))
              (clobber (reg:SI T_REG))])])
 
+;; Left shifts by one are usually done with an add insn to avoid T_REG
+;; clobbers.  Thus addc can also be used to do something like '(x << 1) + 1'.
+(define_insn_and_split "*addc"
+  [(set (match_operand:SI 0 "arith_reg_dest")
+       (plus:SI (mult:SI (match_operand:SI 1 "arith_reg_operand")
+                         (const_int 2))
+                (const_int 1)))
+   (clobber (reg:SI T_REG))]
+  "TARGET_SH1"
+  "#"
+  "&& 1"
+  [(set (reg:SI T_REG) (const_int 1))
+   (parallel [(set (match_dup 0) (plus:SI (plus:SI (match_dup 1) (match_dup 1))
+                                         (reg:SI T_REG)))
+             (clobber (reg:SI T_REG))])])
+
 ;; Sometimes combine will try to do 'reg + (0-reg) + 1' if the *addc pattern
 ;; matched.  Split this up into a simple sub add sequence, as this will save
 ;; us one sett insn.
index 6c6fdf374122a774d5e7cf65f80893e9c82b1d9a..c4c041f84930d075d1600d6ec072d2bee5a44085 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-19  Oleg Endo  <olegendo@gcc.gnu.org>
+
+       PR target/54236
+       * gcc.target/sh/pr54236-1.c (test_08): Add one bit left shift case.
+
 2012-09-19  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.c-torture/execute/20120919-1.c: New test.
index 3a7453c0d74af0959be5518351c823a3daec7108..748b6c9f237fceb6c1c76a87d8e815e76bcab24e 100644 (file)
@@ -4,9 +4,9 @@
 /* { dg-do compile { target "sh*-*-*" } } */
 /* { dg-options "-O1" } */
 /* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */
-/* { dg-final { scan-assembler-times "addc" 3 } } */
+/* { dg-final { scan-assembler-times "addc" 4 } } */
 /* { dg-final { scan-assembler-times "subc" 3 } } */
-/* { dg-final { scan-assembler-times "sett" 4 } } */
+/* { dg-final { scan-assembler-times "sett" 5 } } */
 /* { dg-final { scan-assembler-times "negc" 1 } } */
 /* { dg-final { scan-assembler-not "movt" } } */
 
@@ -74,3 +74,10 @@ test_07 (int *vec)
 
   return vi;
 }
+
+int
+test_08 (int a)
+{
+  /* 1x addc, 1x sett  */
+  return (a << 1) + 1;
+}