]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/90547 (ICE in gen_lowpart_general, at rtlhooks.c:63)
authorUros Bizjak <ubizjak@gmail.com>
Wed, 22 May 2019 18:49:22 +0000 (20:49 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 22 May 2019 18:49:22 +0000 (20:49 +0200)
Backported from mainline
2019-05-21  Uroš Bizjak  <ubizjak@gmail.com>

* config/i386/cpuid.h (__cpuid): For 32bit targets, zero
%ebx and %ecx bafore calling cpuid with leaf 1 or
non-constant leaf argument.

2019-05-21  Uroš Bizjak  <ubizjak@gmail.com>

PR target/90547
* config/i386/i386.md (anddi_1 to andsi_1_zext splitter):
Avoid calling gen_lowpart with CONST operand.

testsuite/ChangeLog:

Backported from mainline
2019-05-21  Uroš Bizjak  <ubizjak@gmail.com>

PR target/90547
* gcc.target/i386/pr90547.c: New test.

From-SVN: r271516

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

index e04e0b3244789a433c00c4597124d2f3d2e85db2..232dc373939508d1f2041efc33748e5f111296f9 100644 (file)
@@ -1,3 +1,18 @@
+2019-05-22  Uroš Bizjak  <ubizjak@gmail.com>
+
+       Backported from mainline
+       2019-05-21  Uroš Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/cpuid.h (__cpuid): For 32bit targets, zero
+       %ebx and %ecx bafore calling cpuid with leaf 1 or
+       non-constant leaf argument.
+
+       2019-05-21  Uroš Bizjak  <ubizjak@gmail.com>
+
+       PR target/90547
+       * config/i386/i386.md (anddi_1 to andsi_1_zext splitter):
+       Avoid calling gen_lowpart with CONST operand.
+
 2019-05-21  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
        Backported from mainline
index 39bf0fb1b838bd5856887f4bb9331331e24f3742..2775e705c70f85aa24cd44804b11bad88b2e7183 100644 (file)
 #define signature_VORTEX_ecx   0x436f5320
 #define signature_VORTEX_edx   0x36387865
 
+#ifndef __x86_64__
+/* At least one cpu (Winchip 2) does not set %ebx and %ecx
+   for cpuid leaf 1. Forcibly zero the two registers before
+   calling cpuid as a precaution.  */
+#define __cpuid(level, a, b, c, d)                     \
+  do {                                                 \
+    if (__builtin_constant_p (level) && (level) != 1)  \
+      __asm__ ("cpuid\n\t"                             \
+             : "=a" (a), "=b" (b), "=c" (c), "=d" (d)  \
+             : "0" (level));                           \
+    else                                               \
+      __asm__ ("cpuid\n\t"                             \
+             : "=a" (a), "=b" (b), "=c" (c), "=d" (d)  \
+             : "0" (level), "1" (0), "2" (0));         \
+  } while (0)
+#else
 #define __cpuid(level, a, b, c, d)                     \
   __asm__ ("cpuid\n\t"                                 \
           : "=a" (a), "=b" (b), "=c" (c), "=d" (d)     \
           : "0" (level))
+#endif
 
 #define __cpuid_count(level, count, a, b, c, d)                \
   __asm__ ("cpuid\n\t"                                 \
index 4188c1a96225c9eb7fcf03e932c6da0fef827aba..f8915440ff34718b79aaa726503898a64a353dbc 100644 (file)
       operands[2] = shallow_copy_rtx (operands[2]);
       PUT_MODE (operands[2], SImode);
     }
+  else if (GET_CODE (operands[2]) == CONST)
+    {
+      /* (const:DI (plus:DI (symbol_ref:DI ("...")) (const_int N))) */
+      operands[2] = copy_rtx (operands[2]);
+      PUT_MODE (operands[2], SImode);
+      PUT_MODE (XEXP (operands[2], 0), SImode);
+      PUT_MODE (XEXP (XEXP (operands[2], 0), 0), SImode);
+    }    
   else
     operands[2] = gen_lowpart (SImode, operands[2]);
 })
index 5d89a5e33537b1a32bcbfbe774f9f050b4d7325f..76810e08d4bb3336072da8f22c99956657ba4161 100644 (file)
@@ -1,3 +1,11 @@
+2019-05-22  Uroš Bizjak  <ubizjak@gmail.com>
+
+       Backported from mainline
+       2019-05-21  Uroš Bizjak  <ubizjak@gmail.com>
+
+       PR target/90547
+       * gcc.target/i386/pr90547.c: New test.
+
 2019-05-20  Jeff Law  <law@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/gcc.target/i386/pr90547.c b/gcc/testsuite/gcc.target/i386/pr90547.c
new file mode 100644 (file)
index 0000000..fcfe669
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR target/90547 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo ()
+{
+  void *g[] = {&&a, &&b};
+
+  for (unsigned c = 0x1F;; c >>= 1)
+    {
+      unsigned d = (long)("a"+1);
+      long e = 8;
+
+      while (e)
+        {
+          a: goto *g[c&d];
+          b: e--;
+        }
+    }
+}