]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/42662 (invalid rtl sharing found in the insn)
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Jan 2010 09:45:19 +0000 (10:45 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Jan 2010 09:45:19 +0000 (10:45 +0100)
PR debug/42662
* simplify-rtx.c (simplify_relational_operation_1): Avoid invalid rtx
sharing when canonicalizing ({lt,ge}u (plus a b) b).

* gcc.dg/pr42662.c: New test.

From-SVN: r155831

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr42662.c [new file with mode: 0644]

index 47491c083117d634e067725dbfe3dad5ddb9aaaf..4d8cfb3cfd49975e92b802ee0aa15d1f84b1662f 100644 (file)
@@ -1,5 +1,9 @@
 2010-01-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/42662
+       * simplify-rtx.c (simplify_relational_operation_1): Avoid invalid rtx
+       sharing when canonicalizing ({lt,ge}u (plus a b) b).
+
        PR tree-optimization/42645
        * tree-inline.c (processing_debug_stmt): Move earlier.  Make static.
        (remap_ssa_name): If processing_debug_stmt and name wasn't found in
index 5e384d4e8f4300caeee92cefa35a79e7234834f5..7c79afbe5fdee01dcf72805c3b94e62fb2c0564a 100644 (file)
@@ -4046,7 +4046,8 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode,
       && rtx_equal_p (op1, XEXP (op0, 1))
       /* Don't recurse "infinitely" for (LTU/GEU (PLUS b b) b).  */
       && !rtx_equal_p (op1, XEXP (op0, 0)))
-    return simplify_gen_relational (code, mode, cmp_mode, op0, XEXP (op0, 0));
+    return simplify_gen_relational (code, mode, cmp_mode, op0,
+                                   copy_rtx (XEXP (op0, 0)));
 
   if (op1 == const0_rtx)
     {
index cc978cd3bd4afe75a7ce0f52fa374f07ea4a6a16..4bdc4819385bc36e5bf6edfa8ffa6566713c6cd4 100644 (file)
@@ -1,5 +1,8 @@
 2010-01-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/42662
+       * gcc.dg/pr42662.c: New test.
+
        PR tree-optimization/42645
        * g++.dg/other/pr42645-1.C: New test.
        * g++.dg/other/pr42645-2.C: New test.
diff --git a/gcc/testsuite/gcc.dg/pr42662.c b/gcc/testsuite/gcc.dg/pr42662.c
new file mode 100644 (file)
index 0000000..6f416e8
--- /dev/null
@@ -0,0 +1,48 @@
+/* PR debug/42662 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+struct S { unsigned long s[17]; };
+
+static inline void
+foo (struct S *r, struct S *a, unsigned n)
+{
+  unsigned b = n / 8;
+  r->s[0] = (b >= 1 ? : a->s[1 - b]);
+}
+
+static inline void
+bar (struct S *r, struct S *a)
+{
+  r->s[0] = a->s[0] << 1;
+}
+
+static inline void
+baz (struct S *r, struct S *a, struct S *b)
+{
+  unsigned c = 0;
+  int i;
+  for (i = 0; i < 3; ++i)
+    {
+      unsigned long d = a->s[i];
+      long e = d + b->s[i];
+      if (c)
+       ++e == 0;
+      c = e < d;
+      r->s[i] = e;
+    }
+}
+
+void
+test (struct S *r, int s, int d)
+{
+  struct S u;
+  if (s)
+    {
+      bar (&u, r);
+      foo (r, r, 3);
+      baz (r, r, &u);
+    }
+  u.s[0] = d;
+  baz (r, r, &u);
+}