]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Merge partial relation precisions properly
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 17 Oct 2022 23:00:49 +0000 (19:00 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 18 Oct 2022 00:58:00 +0000 (20:58 -0400)
When merging 2 groups of PE's, one group was simply being set to the
other instead of properly merging them.

PR tree-optimization/107273
gcc/
* value-relation.cc (equiv_oracle::add_partial_equiv): Merge
instead of copying precison of each member.

gcc/testsuite/
* gcc.dg/tree-ssa/pr107273-1.c: New.
* gcc.dg/tree-ssa/pr107273-2.c: New.

gcc/testsuite/gcc.dg/tree-ssa/pr107273-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr107273-2.c [new file with mode: 0644]
gcc/value-relation.cc

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr107273-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr107273-1.c
new file mode 100644 (file)
index 0000000..db2e2c0
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+int printf(const char *, ...);
+int a[1] = {1};
+short b, c = 5500;
+int d;
+long e;
+char f = 1;
+int main() {
+  while (1) {
+    long g = b < 1;
+    e = g;
+    break;
+  }
+  for (; f; f--) {
+    if (e) {
+      d = -(6L | -(c & 1000));
+    }
+    char h = d;
+    if (b)
+      b = 0;
+    if (d < 200)
+      while (1)
+        printf("%d", a[c]);
+    short i = h * 210;
+    c = i;
+  }
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr107273-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr107273-2.c
new file mode 100644 (file)
index 0000000..3374507
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-Os" } */
+
+int a, d, f;
+char b, g;
+unsigned i;
+int main() {
+  int c = 300, h = 40;
+  char e = 1;
+  for (; a < 1; a++) {
+    c = ~((i - ~c) | e);
+  L1:
+    e = f = c;
+    if (c)
+      if (c > -200)
+        e = g % (1 << h);
+    char k = 0;
+  L2:;
+  }
+  if (b) {
+    if (d)
+      goto L2;
+    if (!b)
+      goto L1;
+  }
+  return 0;
+}
index fed8a78723c3ceb818131e57f8503cc31c6f7dc5..178a245f41a6347cf4f8c19c832eeca18206d124 100644 (file)
@@ -380,7 +380,7 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
       EXECUTE_IF_SET_IN_BITMAP (pe1.members, 0, x, bi)
        {
          m_partial[x].ssa_base = op2;
-         m_partial[x].code = pe2.code;
+         m_partial[x].code = pe_min (m_partial[x].code, pe2.code);
        }
       bitmap_set_bit (pe1.members, v2);
       return;