re PR target/83618 (_rdpid_u32 doesn't work on 64-bit targets as gas expects the...
authorJulia Koval <julia.koval@intel.com>
Wed, 31 Jan 2018 11:06:20 +0000 (12:06 +0100)
committerJulia Koval <jkoval@gcc.gnu.org>
Wed, 31 Jan 2018 11:06:20 +0000 (12:06 +0100)
PR target/83618

gcc/
* config/i386/i386.c (ix86_expand_builtin): Handle IX86_BUILTIN_RDPID.
* config/i386/i386.md (rdpid_rex64) New.
(rdpid): Make 32bit only.

gcc/testsuite/
* gcc.target/i386/rdpid.c: Remove "eax".

From-SVN: r257229

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/rdpid.c

index 9b9a1c39b1394e25325b33a7046af1f7e17cda06..8368986fbc872c9731135733cb57adf0a496f38a 100644 (file)
@@ -1,3 +1,10 @@
+2018-01-31  Julia Koval  <julia.koval@intel.com>
+
+       PR target/83618
+       * config/i386/i386.c (ix86_expand_builtin): Handle IX86_BUILTIN_RDPID.
+       * config/i386/i386.md (rdpid_rex64) New.
+       (rdpid): Make 32bit only.
+
 2018-01-29  Aldy Hernandez  <aldyh@redhat.com>
 
        PR lto/84105
index fef34a1ef64005b5a681f7488e4ad699e4bda7bf..deb7e8ff617d23560a8cf8ccae1a269eae7431da 100644 (file)
@@ -36736,6 +36736,29 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
     case IX86_BUILTIN_NANSQ:
       return expand_call (exp, target, ignore);
 
+    case IX86_BUILTIN_RDPID:
+
+      op0 = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
+
+      if (TARGET_64BIT)
+       {
+         insn = gen_rdpid_rex64 (op0);
+         op0 = convert_to_mode (SImode, op0, 1);
+       }
+      else
+       insn = gen_rdpid (op0);
+      emit_insn (insn);
+
+      if (target == 0)
+       {
+         /* mode is VOIDmode if __builtin_rdpid has been called
+            without lhs.  */
+         if (mode == VOIDmode)
+           return target;
+         target = gen_reg_rtx (mode);
+       }
+      emit_move_insn (target, op0);
+      return target;
     case IX86_BUILTIN_RDPMC:
     case IX86_BUILTIN_RDTSC:
     case IX86_BUILTIN_RDTSCP:
index fe9649d8738c73d0f0ca945dbe40b4aa0461e968..c08e4f55cff7f988e25cc9aa12346aa78c0e82f9 100644 (file)
 (define_insn "rdpid"
   [(set (match_operand:SI 0 "register_operand" "=r")
        (unspec_volatile:SI [(const_int 0)] UNSPECV_RDPID))]
-  "TARGET_RDPID"
+  "!TARGET_64BIT && TARGET_RDPID"
+  "rdpid\t%0"
+  [(set_attr "type" "other")])
+
+(define_insn "rdpid_rex64"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+       (unspec_volatile:DI [(const_int 0)] UNSPECV_RDPID))]
+  "TARGET_64BIT && TARGET_RDPID"
   "rdpid\t%0"
   [(set_attr "type" "other")])
 
index 5220da11d8c15c4dc4ac11b83306ebdc54b194cb..0ff502aab1e61db1163c9d859bcca855253f343f 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-31  Julia Koval  <julia.koval@intel.com>
+
+       PR target/83618
+       * gcc.target/i386/rdpid.c: Remove "eax".
+
 2018-01-31  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        PR tree-optimization/64946
index 286c2974823ee62a37f4eb87dffc4adc9115bec0..7bba98874612588ff578029fac86d93b13e30c38 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -mrdpid" } */
-/* { dg-final { scan-assembler "rdpid\[ \t]+(%|)eax" } } */
+/* { dg-final { scan-assembler "rdpid" } } */
 
 #include <x86intrin.h>