]> 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>
Thu, 23 May 2019 04:55:40 +0000 (06:55 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Thu, 23 May 2019 04:55:40 +0000 (06:55 +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: r271537

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 59d39e55ebb00385f0141d8a3d6d92614c0afc00..785793af037c55b3d1548b3e3eb583bf18613b21 100644 (file)
@@ -1,3 +1,18 @@
+2019-05-23  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-20  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        Backport from mainline.
index b3b0f912c98648262430f4642ca0b4da838a182a..df90089a96fb084ed9235254cc0a10b8cfcc4f3c 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 b665dc5834a5d791ce607043c9e0828d4ab2246e..c36023f2c4d49740fccdc4d39570f66846db7e05 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 35da4a2b8bda4014419b77c2f9af289073bdcee9..ba9467fae51e64abcf6818e75da00a658e21660b 100644 (file)
@@ -1,3 +1,11 @@
+2019-05-23  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  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        Backport 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--;
+        }
+    }
+}