summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/simplify-rtx.c3
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr42662.c48
4 files changed, 57 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 47491c08311..4d8cfb3cfd4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 5e384d4e8f4..7c79afbe5fd 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -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)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cc978cd3bd4..4bdc4819385 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..6f416e82676
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr42662.c
@@ -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);
+}