re PR target/85073 ([x86] extra check after BLSR)
authorUros Bizjak <ubizjak@gmail.com>
Mon, 26 Mar 2018 19:26:19 +0000 (21:26 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Mon, 26 Mar 2018 19:26:19 +0000 (21:26 +0200)
PR target/85073
* config/i386/i386.md (*bmi_blsr_<mode>_cmp): New insn pattern.
(*bmi_blsr_<mode>_ccz): Ditto.

testsuite/ChangeLog:

PR target/85073
* gcc.target/i386/pr85073.c: New test.

From-SVN: r258864

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

index a8d9e76b8f54cc9f03570063357771709971a977..e2a809c3a17b71c9f38fb414cde77b9bc12d44dd 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-26  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/85073
+       * config/i386/i386.md (*bmi_blsr_<mode>_cmp): New insn pattern.
+       (*bmi_blsr_<mode>_ccz): Ditto.
+
 2018-03-26  Tom de Vries  <tom@codesourcery.com>
 
        PR tree-optimization/85063
index 2b73e8f61871bd3e35d8385463a2d3c493ecda11..5eb9e2fa0e698b3d9abef9d5c2d055a64d13bbcd 100644 (file)
    (set_attr "btver2_decode" "double")
    (set_attr "mode" "<MODE>")])
 
+(define_insn "*bmi_blsr_<mode>_cmp"
+  [(set (reg:CCZ FLAGS_REG)
+       (compare:CCZ
+         (and:SWI48
+           (plus:SWI48
+             (match_operand:SWI48 1 "nonimmediate_operand" "rm")
+             (const_int -1))
+           (match_dup 1))
+         (const_int 0)))
+   (set (match_operand:SWI48 0 "register_operand" "=r")
+       (and:SWI48
+         (plus:SWI48
+           (match_dup 1)
+           (const_int -1))
+         (match_dup 1)))]
+   "TARGET_BMI"
+   "blsr\t{%1, %0|%0, %1}"
+  [(set_attr "type" "bitmanip")
+   (set_attr "btver2_decode" "double")
+   (set_attr "mode" "<MODE>")])
+
+(define_insn "*bmi_blsr_<mode>_ccz"
+  [(set (reg:CCZ FLAGS_REG)
+       (compare:CCZ
+         (and:SWI48
+           (plus:SWI48
+             (match_operand:SWI48 1 "nonimmediate_operand" "rm")
+             (const_int -1))
+           (match_dup 1))
+         (const_int 0)))
+   (clobber (match_scratch:SWI48 0 "=r"))]
+   "TARGET_BMI"
+   "blsr\t{%1, %0|%0, %1}"
+  [(set_attr "type" "bitmanip")
+   (set_attr "btver2_decode" "double")
+   (set_attr "mode" "<MODE>")])
+
 ;; BMI2 instructions.
 (define_expand "bmi2_bzhi_<mode>3"
   [(parallel
index fd7345bd1c974f150e9ef63af645159596b5a659..857870af8706ab8a268f14cceef9685ea0018c93 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-26  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/85073
+       * gcc.target/i386/pr85073.c: New test.
+
 2018-03-26  Richard Biener  <rguenther@suse.de>
 
        PR testsuite/85066
diff --git a/gcc/testsuite/gcc.target/i386/pr85073.c b/gcc/testsuite/gcc.target/i386/pr85073.c
new file mode 100644 (file)
index 0000000..187102d
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR target/85073 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbmi" } */
+
+int
+foo (unsigned x)
+{
+  int c = 0;
+  while (x)
+    {
+      c += 1;
+      x = (x - 1) & x;
+    }
+
+  return c;
+}
+
+/* { dg-final { scan-assembler-times "test" 1 } } */