i386.md (*popcounthi2_1): New insn_and_split pattern.
authorUros Bizjak <uros@gcc.gnu.org>
Mon, 19 Dec 2016 20:23:08 +0000 (21:23 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Mon, 19 Dec 2016 20:23:08 +0000 (21:23 +0100)
* config/i386/i386.md (*popcounthi2_1): New insn_and_split pattern.

testsuite/ChangeLog:

* gcc.target/i386/pr59874-3.c: New test.

From-SVN: r243811

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr59874-3.c [new file with mode: 0644]

index 69ef89b0e30fb3d861208e08a22cf46301702f3f..49484d79407e02762c3f4635800482d35d081435 100644 (file)
@@ -1,6 +1,10 @@
+2016-12-19  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/i386.md (*popcounthi2_1): New insn_and_split pattern.
+
 2016-12-19  Sandra Loosemore  <sandra@codesourcery.com>
 
-       * doc/cpp.texi: Clean up anachronistic C99 references and remove 
+       * doc/cpp.texi: Clean up anachronistic C99 references and remove
        discussion of very old GCC versions.
        (Differences from previous versions): Delete entire section.
 
        * config/arc/arc.md (mulsidi_600): Change to insn_and_split,
        generate new mul64 insn for core multiplication work.
        (umulsidi_600): Likewise, but use mulu64 insn.
-       (mul64): New pattern, content taken from old mulsidi_600 insn
-       pattern.
+       (mul64): New pattern, content taken from old mulsidi_600 insn pattern.
        (mulu64): Likewise, but using umulsidi_600.
        (mulsidi3): Remove move to destination, this is now handled by
        mulsidi_600 insn_and_split.
index 2123914bef9e8cac330ece7ff74247ee0c7b8605..a88c0b8c81afb9f94b25e2827411c43b337c2f5e 100644 (file)
    (set_attr "type" "bitmanip")
    (set_attr "mode" "<MODE>")])
 
+(define_insn_and_split "*popcounthi2_1"
+  [(set (match_operand:SI 0 "register_operand")
+       (popcount:SI
+         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand"))))
+   (clobber (reg:CC FLAGS_REG))]
+  "TARGET_POPCNT
+   && can_create_pseudo_p ()"
+  "#"
+  "&& 1"
+  [(const_int 0)]
+{
+  rtx tmp = gen_reg_rtx (HImode);
+
+  emit_insn (gen_popcounthi2 (tmp, operands[1]));
+  emit_insn (gen_zero_extendhisi2 (operands[0], tmp));
+  DONE;
+})
+
 (define_insn "popcounthi2"
   [(set (match_operand:HI 0 "register_operand" "=r")
        (popcount:HI
index 4eb7ea7a9113792441470e149c018a5550704a5d..cd0d954976afaeacc93e836107f68b7317f31901 100644 (file)
@@ -1,18 +1,21 @@
+2016-12-19  Uros Bizjak  <ubizjak@gmail.com>
+
+       * gcc.target/i386/pr59874-3.c: New test.
+
 2016-12-19  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
-       *  gcc.dg/vmx/mult-even-odd-be-order.c: Mark
-       variables as volatile.
-       *  gcc.target/powerpc/fold-vec-mult-char.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-float.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-floatdouble.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-int.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-int128-p8.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-int128-p9.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-longlong.c: New.
-       *  gcc.target/powerpc/fold-vec-mult-short.c: New.
+       * gcc.dg/vmx/mult-even-odd-be-order.c: Mark variables as volatile.
+       * gcc.target/powerpc/fold-vec-mult-char.c: New.
+       * gcc.target/powerpc/fold-vec-mult-float.c: New.
+       * gcc.target/powerpc/fold-vec-mult-floatdouble.c: New.
+       * gcc.target/powerpc/fold-vec-mult-int.c: New.
+       * gcc.target/powerpc/fold-vec-mult-int128-p8.c: New.
+       * gcc.target/powerpc/fold-vec-mult-int128-p9.c: New.
+       * gcc.target/powerpc/fold-vec-mult-longlong.c: New.
+       * gcc.target/powerpc/fold-vec-mult-short.c: New.
 
 2016-12-19  Will Schmidt  <will_schmidt@vnet.ibm.com>
+
        * gcc.target/powerpc/fold-vec-sub-char.c: New.
        * gcc.target/powerpc/fold-vec-sub-float.c: New.
        * gcc.target/powerpc/fold-vec-sub-floatdouble.c: New.
@@ -39,7 +42,7 @@
 2016-12-17  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/78746
-       * charlen_03.f90: Remove test. 
+       * charlen_03.f90: Remove test.
        * charlen_10.f90: Ditto.
 
 2016-12-17  Jakub Jelinek  <jakub@redhat.com>
diff --git a/gcc/testsuite/gcc.target/i386/pr59874-3.c b/gcc/testsuite/gcc.target/i386/pr59874-3.c
new file mode 100644 (file)
index 0000000..ec55a12
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR target/59874 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mpopcnt -masm=att" } */
+/* { dg-final { scan-assembler "popcntw" } } */
+
+unsigned int
+foo (unsigned short x)
+{
+  return __builtin_popcount (x);
+}