From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 52D7D3858D3C; Tue, 17 May 2022 15:44:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52D7D3858D3C MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Macleod To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-564] Check for equivalence after merging relations. X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: 61a6923e8917b6efcf349515a00a485dfd5b42e4 X-Git-Newrev: 6101a276c34b94f692206739d98aa7faf2e7b2ad Message-Id: <20220517154455.52D7D3858D3C@sourceware.org> Date: Tue, 17 May 2022 15:44:55 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2022 15:44:55 -0000 https://gcc.gnu.org/g:6101a276c34b94f692206739d98aa7faf2e7b2ad commit r13-564-g6101a276c34b94f692206739d98aa7faf2e7b2ad Author: Andrew MacLeod Date: Mon May 16 21:39:30 2022 -0400 Check for equivalence after merging relations. 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. Diff: --- gcc/testsuite/gcc.dg/pr105458.c | 20 ++++++++++++++++++++ gcc/value-relation.cc | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr105458.c b/gcc/testsuite/gcc.dg/pr105458.c new file mode 100644 index 00000000000..eb58bf21f32 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105458.c @@ -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 (;;) + { + } + } +} + diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index a93565109f9..85d159f5d96 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -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,