re PR target/25111 ([m68k] bset is not used for A = 1 << (B & 31) on ColdFire)
authorJeff Law <law@redhat.com>
Sat, 19 Nov 2016 17:52:04 +0000 (10:52 -0700)
committerJeff Law <law@gcc.gnu.org>
Sat, 19 Nov 2016 17:52:04 +0000 (10:52 -0700)
PR target/25111
* config/m68k/m68k.md (bsetdreg): New pattern.
(bchgdreg, bclrdreg): Likewise.

PR target/25111
* gcc.target/m68k/pr25111.c: New test.

From-SVN: r242623

gcc/ChangeLog
gcc/config/m68k/m68k.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/m68k/pr25111.c [new file with mode: 0644]

index fd09a79049435ea9545367884bb9fd36335aa8b1..1d560f5c68eef726a209f081b3c6c33afdc8d56f 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-19  Jeff Law  <law@redhat.com>
+
+       PR target/25111
+       * config/m68k/m68k.md (bsetdreg): New pattern.
+       (bchgdreg, bclrdreg): Likewise.
+
 2016-11-19  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        PR target/78426
index 7b7f3731f0716411af24eb7b92b0f51c2b4325da..208561996e774fa365cea5f1d019236efd63d17a 100644 (file)
 }
   [(set_attr "type" "bitrw")])
 
+(define_insn "*bsetdreg"
+  [(set (match_operand:SI 0 "register_operand" "+d")
+       (ior:SI (ashift:SI (const_int 1)
+                          (and:SI (match_operand:SI 1 "register_operand" "d")
+                                  (const_int 31)))
+               (match_operand:SI 2 "register_operand" "0")))]
+  ""
+{
+  CC_STATUS_INIT;
+  return "bset %1,%0";
+}
+  [(set_attr "type" "bitrw")])
+
+(define_insn "*bchgdreg"
+  [(set (match_operand:SI 0 "register_operand" "+d")
+       (xor:SI (ashift:SI (const_int 1)
+                          (and:SI (match_operand:SI 1 "register_operand" "d")
+                                  (const_int 31)))
+               (match_operand:SI 2 "register_operand" "0")))]
+  ""
+{
+  CC_STATUS_INIT;
+  return "bchg %1,%0";
+}
+  [(set_attr "type" "bitrw")])
+
+(define_insn "*bclrdreg"
+  [(set (match_operand:SI 0 "register_operand" "+d")
+       (and:SI (rotate:SI (const_int -2)
+                          (and:SI (match_operand:SI 1 "register_operand" "d")
+                                  (const_int 31)))
+               (match_operand:SI 2 "register_operand" "0")))]
+  ""
+{
+  CC_STATUS_INIT;
+  return "bclr %1,%0";
+}
+  [(set_attr "type" "bitrw")])
+
 ;; clear bit, bit number is int
 (define_insn "bclrmemqi"
   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
index 50b8888ab4bfdf6db56b73e1a203dbca4f27e906..41133d8228081089653ad588fa58a9c84008297b 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-18  Jeff Law  <law@redhat.com>
+
+       PR target/25111
+       * gcc.target/m68k/pr25111.c: New test.
+
 2016-11-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/68180
diff --git a/gcc/testsuite/gcc.target/m68k/pr25111.c b/gcc/testsuite/gcc.target/m68k/pr25111.c
new file mode 100644 (file)
index 0000000..950eeda
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* { dg-final { scan-assembler-times "bset" 1 } } */
+/* { dg-final { scan-assembler-times "bchg" 1 } } */
+/* { dg-final { scan-assembler-times "bclr" 1 } } */
+
+int bar (void);
+
+int
+foo1 (int b)
+{
+  int a = bar ();
+  return ( a | (1 << (b & 31)));
+}
+
+int
+foo2 (int b)
+{
+  int a = bar ();
+  return ( a ^ (1 << (b & 31)));
+}
+
+
+int
+foo3 (int b)
+{
+  int a = bar ();
+  return ( a & ~(1 << (b & 31)));
+}
+
+