re PR tree-optimization/77856 (wrong code at -O2 on x86_64-linux-gnu in 32-bit mode)
authorVladimir Makarov <vmakarov@redhat.com>
Wed, 30 Nov 2016 17:35:40 +0000 (17:35 +0000)
committerVladimir Makarov <vmakarov@gcc.gnu.org>
Wed, 30 Nov 2016 17:35:40 +0000 (17:35 +0000)
2016-11-30  Vladimir Makarov  <vmakarov@redhat.com>

PR tree-optimization/77856
* lra-constraints.c (inherit_in_ebb): Check original regno for
invalid invariant regs too.  Set only clobbered hard regs for the
invalid invariant regs.

2016-11-30  Vladimir Makarov  <vmakarov@redhat.com>

PR tree-optimization/77856
* gcc.target/i386.c (pr77856.c): New.

From-SVN: r243038

gcc/ChangeLog
gcc/lra-constraints.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr77856.c [new file with mode: 0644]

index 80b1c90be61e444c6d4a44a714899fd3a8ed7ad8..6abb47ff0a7c2b694fea5d7d2dda0a8550966e1a 100644 (file)
@@ -1,3 +1,10 @@
+2016-11-30  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR tree-optimization/77856
+       * lra-constraints.c (inherit_in_ebb): Check original regno for
+       invalid invariant regs too.  Set only clobbered hard regs for the
+       invalid invariant regs.
+
 2016-11-30  Pitchumani Sivanupandi  <pitchumani.sivanupandi@microchip.com>
 
        Commit files forgotten in r242966.
index 7784ad29744b1e43d282c92a33ede2a48ebf382f..260591acb06bbc4d567d59d02743bc90daf13645 100644 (file)
@@ -5888,7 +5888,9 @@ inherit_in_ebb (rtx_insn *head, rtx_insn *tail)
               && dst_regno >= lra_constraint_new_regno_start
               && invariant_p (SET_SRC (curr_set))
               && (cl = lra_get_allocno_class (dst_regno)) != NO_REGS
-              && ! bitmap_bit_p (&invalid_invariant_regs, dst_regno))
+              && ! bitmap_bit_p (&invalid_invariant_regs, dst_regno)
+              && ! bitmap_bit_p (&invalid_invariant_regs,
+                                 ORIGINAL_REGNO(regno_reg_rtx[dst_regno])))
        {
          /* 'reload_pseudo <- invariant'.  */
          if (ira_class_hard_regs_num[cl] <= max_small_class_regs_num)
@@ -6159,16 +6161,20 @@ inherit_in_ebb (rtx_insn *head, rtx_insn *tail)
          curr_id = lra_get_insn_recog_data (curr_insn);
          for (reg = curr_id->regs; reg != NULL; reg = reg->next)
            if (reg->type != OP_IN)
-             bitmap_set_bit (&invalid_invariant_regs, reg->regno);
+             {
+               bitmap_set_bit (&invalid_invariant_regs, reg->regno);
+               bitmap_set_bit (&invalid_invariant_regs,
+                               ORIGINAL_REGNO (regno_reg_rtx[reg->regno]));
+             }
          curr_static_id = curr_id->insn_static_data;
          for (reg = curr_static_id->hard_regs; reg != NULL; reg = reg->next)
            if (reg->type != OP_IN)
              bitmap_set_bit (&invalid_invariant_regs, reg->regno);
          if (curr_id->arg_hard_regs != NULL)
            for (i = 0; (regno = curr_id->arg_hard_regs[i]) >= 0; i++)
+             if (regno >= FIRST_PSEUDO_REGISTER)
                bitmap_set_bit (&invalid_invariant_regs,
-                               regno >= FIRST_PSEUDO_REGISTER
-                               ? regno : regno - FIRST_PSEUDO_REGISTER);
+                               regno - FIRST_PSEUDO_REGISTER);
        }
       /* We reached the start of the current basic block.  */
       if (prev_insn == NULL_RTX || prev_insn == PREV_INSN (head)
index 327a89ed089c631c553fb9c5c914a713b566b14c..fe0edd71f66c33148d5f9afc56e1ebe59872b822 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-30  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR tree-optimization/77856
+       * gcc.target/i386.c (pr77856.c): New.
+
 2016-11-30  David Edelsohn  <dje.gcc@gmail.com>
 
        * g++.dg/debug/dwarf2/ptrdmem-1.C: Don't XFAIL scan-assembler-not on AIX.
diff --git a/gcc/testsuite/gcc.target/i386/pr77856.c b/gcc/testsuite/gcc.target/i386/pr77856.c
new file mode 100644 (file)
index 0000000..81556be
--- /dev/null
@@ -0,0 +1,83 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+unsigned a, e;
+
+struct S0
+{
+  int f1;
+  int f8;
+} c = {4, 6};
+
+int b, f, g, h, i, j, l, p;
+short d, o = -7;
+char k, n = 5;
+
+unsigned fn1 (int p1, int p2)
+{
+  return p2 >= 2 || p1 >> p2 ? p1 : p1 << p2;
+}
+
+static short fn2 (struct S0 p1)
+{
+  int *q = 0;
+  int r = 7;
+  if (!a)
+    {
+      c.f1 = 1;
+      for (; c.f1; c.f1--)
+       if (fn1 (10 != 0, p1.f8))
+         {
+           short s = 9 << ~o % (d ^ n);
+           int t = s >> h % ~d;
+           p = r;
+           r = s | p * (d && 9) | t;
+           int u = i & c.f1;
+           unsigned v = ~(~(u & h) | (~(8 >> c.f1) & i));
+           int w = v;
+           if (u < 9)
+             w = c.f1;
+           if (i > h && u)
+             {
+               __builtin_printf ("%d\n", c.f1);
+               continue;
+             }
+           c.f1 = w;
+           if (!p)
+             continue;
+           return 0;
+         }
+      for (;;)
+       *q = 0;
+    }
+  return 0;
+}
+
+static void fn3 ()
+{
+  fn2 (c);
+  l = c.f1 < b;
+  if (l)
+    {
+    L1:
+      e = l | j / e % ~f;
+      j = f - 4 % k < c.f1 / e / b - j - 1;
+      if (l)
+       {
+         __builtin_printf ("%d\n", b);
+         goto L1;
+       }
+      int m[245];
+      g = m[2];
+    }
+}
+
+int main ()
+{
+  fn3 ();
+  if (c.f1 != 1)
+    abort ();
+  return 0;
+}