]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
mips.md (*popcountdi2_trunc): New pattern to handle popcount of a truncation.
authorAndrew Pinski <apinski@cavium.com>
Sat, 21 Jul 2012 11:05:04 +0000 (11:05 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sat, 21 Jul 2012 11:05:04 +0000 (04:05 -0700)
2012-07-21  Andrew Pinski  <apinski@cavium.com>

* config/mips/mips.md (*popcountdi2_trunc): New pattern
to handle popcount of a truncation.

2012-07-21  Andrew Pinski  <apinski@cavium.com>

* gcc.target/mips/octeon-pop-2.c: New testcase.

From-SVN: r189744

gcc/ChangeLog
gcc/config/mips/mips.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/octeon-pop-2.c [new file with mode: 0644]

index 40277665f23b751ffb9fe2fb7b6d285cccfff271..a2838d787271a2cb225b9a93f7c4a9d464f13e97 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-21  Andrew Pinski  <apinski@cavium.com>
+
+       * config/mips/mips.md (*popcountdi2_trunc): New pattern
+       to handle popcount of a truncation.
+
 2012-07-21  Andrew Pinski  <apinski@cavium.com>
 
        * config/mips/mips-protos.h (mips_expand_ext_as_unaligned_load):
index 0edc9d94986a3d779514d6186e0481a064891e5c..af741ba2b8278353bb5acd2d42e3bce78ce9a188 100644 (file)
   "<d>pop\t%0,%1"
   [(set_attr "type" "pop")
    (set_attr "mode" "<MODE>")])
+
+;; The POP instruction is special as it does not take into account the upper
+;; 32bits and is documented that way.
+(define_insn "*popcountdi2_trunc"
+  [(set (match_operand:SI 0 "register_operand" "=d")
+       (popcount:SI (truncate:SI (match_operand:DI 1 "register_operand" "d"))))]
+  "ISA_HAS_POP && TARGET_64BIT"
+  "pop\t%0,%1"
+  [(set_attr "type" "pop")
+   (set_attr "mode" "SI")])
 \f
 ;;
 ;;  ....................
index 75aa11414049299c8a68736418897aa707afeb30..3dd4fb86c80d9caa11c11b96bc916fd105363fb6 100644 (file)
@@ -1,3 +1,7 @@
+2012-07-21  Andrew Pinski  <apinski@cavium.com>
+
+       * gcc.target/mips/octeon-pop-2.c: New testcase.
+
 2012-07-21  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/48820
diff --git a/gcc/testsuite/gcc.target/mips/octeon-pop-2.c b/gcc/testsuite/gcc.target/mips/octeon-pop-2.c
new file mode 100644 (file)
index 0000000..8acd935
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -march=octeon -mgp64" } */
+/* The pop instruction does not depend on the word value to be sign extended. */
+/* { dg-final { scan-assembler-not "sll\t" } } */
+
+long long f(long long i)
+{
+  return __builtin_popcount (i);
+}
+