re PR target/57736 (ICE in emit_move_insn with __builtin_ia32_rdtsc)
authorJakub Jelinek <jakub@redhat.com>
Fri, 28 Jun 2013 20:25:35 +0000 (22:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 28 Jun 2013 20:25:35 +0000 (22:25 +0200)
PR target/57736
* config/i386/i386.c (ix86_expand_builtin): If target == NULL
and mode is VOIDmode, don't create a VOIDmode pseudo to copy result
into.

* gcc.target/i386/pr57736.c: New test.

From-SVN: r200555

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

index 0ac6e1b3d261b452015df25216e1b2e665dced97..4a2c28190b7db234756cd4ce5065cb5b0af80a6f 100644 (file)
@@ -1,3 +1,10 @@
+2013-06-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/57736
+       * config/i386/i386.c (ix86_expand_builtin): If target == NULL
+       and mode is VOIDmode, don't create a VOIDmode pseudo to copy result
+       into.
+
 2013-06-28  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
        * builtins.def: Fixed the function type of CILKPLUS_BUILTIN.
index 2a65fc2a6de800659a7c0a02bb2d55b2950c47fb..3dbaddfa1bb232d2ad1738b97760edacf9e341f4 100644 (file)
@@ -32218,7 +32218,13 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
        }
 
       if (target == 0)
-       target = gen_reg_rtx (mode);
+       {
+         /* mode is VOIDmode if __builtin_rd* has been called
+            without lhs.  */
+         if (mode == VOIDmode)
+           return target;
+         target = gen_reg_rtx (mode);
+       }
 
       if (TARGET_64BIT)
        {
index b9a61801a275b6c0b6404b09a45f50eb771351bb..28874b0f28fe9b6155e7c8a9af43eca3e4f86eac 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/57736
+       * gcc.target/i386/pr57736.c: New test.
+
 2013-06-28  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
        * c-c++-common/cilk-plus/AN/decl-ptr-colon.c (main): Made this testcase
diff --git a/gcc/testsuite/gcc.target/i386/pr57736.c b/gcc/testsuite/gcc.target/i386/pr57736.c
new file mode 100644 (file)
index 0000000..120e5dc
--- /dev/null
@@ -0,0 +1,41 @@
+/* PR target/57736 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <x86intrin.h>
+
+unsigned long long
+f1 (void)
+{
+  return __rdtsc ();
+}
+
+unsigned long long
+f2 (unsigned int *x)
+{
+  return __rdtscp (x);
+}
+
+unsigned long long
+f3 (unsigned int x)
+{
+  return __rdpmc (x);
+}
+
+void
+f4 (void)
+{
+  __rdtsc ();
+}
+
+void
+f5 (unsigned int *x)
+{
+  __rdtscp (x);
+}
+
+void
+f6 (unsigned int x)
+{
+  __rdpmc (x);
+}