re PR target/65871 (bzhi builtin/intrinsic wrongly assumes bzhi instruction doesn...
authorUros Bizjak <ubizjak@gmail.com>
Wed, 29 Apr 2015 18:53:19 +0000 (20:53 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 29 Apr 2015 18:53:19 +0000 (20:53 +0200)
PR target/65871
* config/i386/i386.md (*bmi_bextr_<mode>_cczonly): New pattern.
(*bmi2_bzhi_<mode>3_1_cczonly): Ditto.

testsuite/ChangeLog:

PR target/65871
* gcc.target/i386/pr65871-1.c: New test
* gcc.target/i386/pr65871-2.c: Ditto.

From-SVN: r222588

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr65871-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr65871-2.c [new file with mode: 0644]

index d7455e4e0a542c245907d26d833564d8ad32a1ad..4c95a75b668ecfb63ba98223b321380f4e9396cc 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-29  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/65871
+       * config/i386/i386.md (*bmi_bextr_<mode>_cczonly): New pattern.
+       (*bmi2_bzhi_<mode>3_1_cczonly): Ditto.
+
 2015-04-29  Thomas Schwinge  <thomas@codesourcery.com>
 
        PR libgomp/65099
index 937871a5af552c776d68c1a89f7043d0ee456ee0..060ffa8ab8483ea85d4014e8ebed43260409f3bc 100644 (file)
    (set_attr "btver2_decode" "direct, double")
    (set_attr "mode" "<MODE>")])
 
+(define_insn "*bmi_bextr_<mode>_cczonly"
+  [(set (reg:CCZ FLAGS_REG)
+       (compare:CCZ
+         (unspec:SWI48 [(match_operand:SWI48 1 "nonimmediate_operand" "r,m")
+                        (match_operand:SWI48 2 "register_operand" "r,r")]
+                       UNSPEC_BEXTR)
+         (const_int 0)))
+   (clobber (match_scratch:SWI48 0 "=r,r"))]
+  "TARGET_BMI"
+  "bextr\t{%2, %1, %0|%0, %1, %2}"
+  [(set_attr "type" "bitmanip")
+   (set_attr "btver2_decode" "direct, double")
+   (set_attr "mode" "<MODE>")])
+
 (define_insn "*bmi_blsi_<mode>"
   [(set (match_operand:SWI48 0 "register_operand" "=r")
         (and:SWI48
    (set_attr "mode" "<MODE>")])
 
 (define_mode_attr k [(SI "k") (DI "q")])
+
 (define_insn "*bmi2_bzhi_<mode>3_1"
   [(set (match_operand:SWI48 0 "register_operand" "=r")
        (zero_extract:SWI48
    (set_attr "prefix" "vex")
    (set_attr "mode" "<MODE>")])
 
+(define_insn "*bmi2_bzhi_<mode>3_1_cczonly"
+  [(set (reg:CCZ FLAGS_REG)
+       (compare:CCZ
+         (zero_extract:SWI48
+           (match_operand:SWI48 1 "nonimmediate_operand" "rm")
+           (umin:SWI48
+             (zero_extend:SWI48 (match_operand:QI 2 "register_operand" "r"))
+             (match_operand:SWI48 3 "const_int_operand" "n"))
+           (const_int 0))
+       (const_int 0)))
+   (clobber (match_scratch:SWI48 0 "=r"))]
+  "TARGET_BMI2 && INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT"
+  "bzhi\t{%<k>2, %1, %0|%0, %1, %<k>2}"
+  [(set_attr "type" "bitmanip")
+   (set_attr "prefix" "vex")
+   (set_attr "mode" "<MODE>")])
+
 (define_insn "bmi2_pdep_<mode>3"
   [(set (match_operand:SWI48 0 "register_operand" "=r")
         (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")
index 7ff95665c48ea4aa92a8e095cf16323a05bfe9a7..9d428f83aec719bd25a79736a4a450ca900b2441 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-29  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/65871
+       * gcc.target/i386/pr65871-1.c: New test
+       * gcc.target/i386/pr65871-2.c: Ditto.
+
 2015-04-29  Marek Polacek  <polacek@redhat.com>
 
        PR c/64610
diff --git a/gcc/testsuite/gcc.target/i386/pr65871-1.c b/gcc/testsuite/gcc.target/i386/pr65871-1.c
new file mode 100644 (file)
index 0000000..d76181e
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbmi" } */
+
+int foo (unsigned int x, unsigned int y)
+{
+  if (__builtin_ia32_bextr_u32 (x, y))
+    return 1;
+
+  return 0;
+}
+
+/* { dg-final { scan-assembler-not "test" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr65871-2.c b/gcc/testsuite/gcc.target/i386/pr65871-2.c
new file mode 100644 (file)
index 0000000..e6538cc
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mbmi2" } */
+
+int foo (unsigned int x, unsigned int y)
+{
+  if (__builtin_ia32_bzhi_si (x, y))
+    return 1;
+
+  return 0;
+}
+
+/* { dg-final { scan-assembler-not "test" } } */