2016-01-21 Vladimir Makarov <vmakarov@redhat.com>
authorvmakarov <vmakarov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 2016 16:01:22 +0000 (16:01 +0000)
committervmakarov <vmakarov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 2016 16:01:22 +0000 (16:01 +0000)
PR rtl-optimization/68990
* lra-coalesce.c (lra_coalesce): Invalidate value for the result
pseudo instead of inheritance ones.

2016-01-21  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/68990
* gcc.target/i386/pr68990: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232679 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e620e30..d15a87d 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-21  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR rtl-optimization/68990
+       * lra-coalesce.c (lra_coalesce): Invalidate value for the result
+       pseudo instead of inheritance ones.
+
 2016-01-21  Bernd Enlinger  <bernd.edlinger@hotmail.de>
            Nick Clifton  <nickc@redhat.com>
 
index 94764d9..178ed3f 100644 (file)
@@ -224,13 +224,10 @@ lra_coalesce (void)
   rtx_insn *mv, *insn, *next, **sorted_moves;
   rtx set;
   int i, mv_num, sregno, dregno;
-  unsigned int regno;
   int coalesced_moves;
   int max_regno = max_reg_num ();
   bitmap_head involved_insns_bitmap;
-  bitmap_head result_pseudo_vals_bitmap;
-  bitmap_iterator bi;
-
+  
   timevar_push (TV_LRA_COALESCE);
 
   if (lra_dump_file != NULL)
@@ -327,7 +324,7 @@ lra_coalesce (void)
     }
   /* If we have situation after inheritance pass:
 
-     r1 <- ...  insn originally setting p1
+     r1 <- p1   insn originally setting p1
      i1 <- r1   setting inheritance i1 from reload r1
        ...
      ... <- ... p2 ... dead p2
@@ -339,20 +336,18 @@ lra_coalesce (void)
      And we are coalescing p1 and p2 using p1.  In this case i1 and p1
      should have different values, otherwise they can get the same
      hard reg and this is wrong for insn using p2 before coalescing.
-     So invalidate such inheritance pseudo values.  */
-  bitmap_initialize (&result_pseudo_vals_bitmap, &reg_obstack);
-  EXECUTE_IF_SET_IN_BITMAP (&coalesced_pseudos_bitmap, 0, regno, bi)
-    bitmap_set_bit (&result_pseudo_vals_bitmap,
-                   lra_reg_info[first_coalesced_pseudo[regno]].val);
-  EXECUTE_IF_SET_IN_BITMAP (&lra_inheritance_pseudos, 0, regno, bi)
-    if (bitmap_bit_p (&result_pseudo_vals_bitmap, lra_reg_info[regno].val))
+     The situation even can be more complicated when new reload
+     pseudos occur after the inheriatnce.  So invalidate the result
+     pseudos.  */
+  for (i = 0; i < max_regno; i++)
+    if (first_coalesced_pseudo[i] == i
+       && first_coalesced_pseudo[i] != next_coalesced_pseudo[i])
       {
-       lra_set_regno_unique_value (regno);
+       lra_set_regno_unique_value (i);
        if (lra_dump_file != NULL)
          fprintf (lra_dump_file,
-                  "     Make unique value for inheritance r%d\n", regno);
+                  "     Make unique value for coalescing result r%d\n", i);
       }
-  bitmap_clear (&result_pseudo_vals_bitmap);
   bitmap_clear (&used_pseudos_bitmap);
   bitmap_clear (&involved_insns_bitmap);
   bitmap_clear (&coalesced_pseudos_bitmap);
index 08aafd1..843ccac 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-21  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR rtl-optimization/68990
+       * gcc.target/i386/pr68990: New.
+
 2016-01-21  Nick Clifton  <nickc@redhat.com>
 
        PR target/69129
diff --git a/gcc/testsuite/gcc.target/i386/pr68990.c b/gcc/testsuite/gcc.target/i386/pr68990.c
new file mode 100644 (file)
index 0000000..4c3ca03
--- /dev/null
@@ -0,0 +1,49 @@
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-O3 -march=x86-64" } */
+/* { dg-final { scan-assembler-not "cmpl\[ \t]+(\[%a-z]+), \\1" } } */
+
+short a;
+int b = 1, f;
+char c, e = 1;
+long long d;
+
+static short
+foo ()
+{
+  unsigned g, h = 0;
+  int i = 0 || d * (b | e);
+  char j = a << i, l = a;
+  short k;
+  int m = -b;
+  if (m < b)
+    {
+      k = m = b;
+      g = (k || l) / (b / e);
+      if (b)
+       __builtin_printf ("foo=%lld\n", (long long) a);
+    }
+  a = b = m;
+  if (j || e)
+    {
+      h = g;
+      i = m;
+      g = j * k / (i - d);
+      if (m)
+       b = j && b;
+      e = b * (h & d) || g;
+    }
+  b = i;
+  char n = e || h | d;
+  e = i < d & k / n;
+  return f;
+}
+
+int
+main ()
+{
+  if (foo ())
+    if (c)
+    lab:
+      goto lab;
+  return 0;
+}