]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Check for equivalence after merging relations.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 17 May 2022 01:39:30 +0000 (21:39 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 17 May 2022 15:43:32 +0000 (11:43 -0400)
When registering a relation, we need to merge with any existing relation
before checking if it was an equivalence... otherwise it was not being
handled properly.

gcc/
PR tree-optimization/105458
* value-relation.cc (path_oracle::register_relation): Merge, then check
for equivalence.

gcc/testsuite/
* gcc.dg/pr105458.c: New.

gcc/testsuite/gcc.dg/pr105458.c [new file with mode: 0644]
gcc/value-relation.cc

diff --git a/gcc/testsuite/gcc.dg/pr105458.c b/gcc/testsuite/gcc.dg/pr105458.c
new file mode 100644 (file)
index 0000000..eb58bf2
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR tree-optimization/105458 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fexpensive-optimizations -fno-tree-dominator-opts " } */
+
+void
+yj (int j4)
+{
+  int t3;
+
+  for (t3 = 0; t3 < 6; ++t3)
+    {
+      short int v4 = t3;
+
+      if (v4 == j4 || v4 > t3)
+        for (;;)
+          {
+          }
+    }
+}
+
index a93565109f97b2273ba2ef90b3055601e9cb9e28..85d159f5d96f3453f6ce1a8d988b028644d7d5c6 100644 (file)
@@ -1384,16 +1384,16 @@ path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1,
       fprintf (dump_file, " (root: bb%d)\n", bb->index);
     }
 
+  relation_kind curr = query_relation (bb, ssa1, ssa2);
+  if (curr != VREL_VARYING)
+    k = relation_intersect (curr, k);
+
   if (k == VREL_EQ)
     {
       register_equiv (bb, ssa1, ssa2);
       return;
     }
 
-  relation_kind curr = query_relation (bb, ssa1, ssa2);
-  if (curr != VREL_VARYING)
-    k = relation_intersect (curr, k);
-
   bitmap_set_bit (m_relations.m_names, SSA_NAME_VERSION (ssa1));
   bitmap_set_bit (m_relations.m_names, SSA_NAME_VERSION (ssa2));
   relation_chain *ptr = (relation_chain *) obstack_alloc (&m_chain_obstack,