diff mbox series

[i386] : Fix PR89945, ICE in gen_lowpart_general

Message ID CAFULd4ZSDFnSst4UF_HmSuJQb+8d_21UK9GWnApyVvmCkbOmng@mail.gmail.com
State New
Headers show
Series [i386] : Fix PR89945, ICE in gen_lowpart_general | expand

Commit Message

Uros Bizjak April 7, 2019, 7:21 p.m. UTC
2019-04-07  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/89945
    * config/i386/i386.md (anddi_1 to andsi_1_zext splitter):
    Avoid calling gen_lowpart with SYMBOL_REF and LABEL_REF operand.

testsuite/ChangeLog:

2019-04-07  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/89945
    * gcc.target/i386/pr89945.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN, will be backported to release branches.

Uros.
diff mbox series

Patch

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 270169)
+++ config/i386/i386.md	(working copy)
@@ -8609,7 +8609,16 @@ 
   [(parallel [(set (match_dup 0)
 		   (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))
 	      (clobber (reg:CC FLAGS_REG))])]
-  "operands[2] = gen_lowpart (SImode, operands[2]);")
+{
+  if (GET_CODE (operands[2]) == SYMBOL_REF
+      || GET_CODE (operands[2]) == LABEL_REF)
+    {
+      operands[2] = shallow_copy_rtx (operands[2]);
+      PUT_MODE (operands[2], SImode);
+    }
+  else
+    operands[2] = gen_lowpart (SImode, operands[2]);
+})
 
 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
 (define_insn "*andsi_1_zext"
Index: testsuite/gcc.target/i386/pr89945.c
===================================================================
--- testsuite/gcc.target/i386/pr89945.c	(nonexistent)
+++ testsuite/gcc.target/i386/pr89945.c	(working copy)
@@ -0,0 +1,21 @@ 
+/* PR target/89945 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo ()
+{
+  void *g[] = {&&a, &&b};
+
+  for (unsigned c = 0x1F;; c >>= 1)
+    {
+      unsigned d = (long)"a";
+      long e = 8;
+
+      while (e)
+        {
+          a: goto *g[c&d];
+          b: e--;
+        }
+    }
+}