From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 0DE1A3857821; Fri, 22 Oct 2021 10:49:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DE1A3857821 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4626] Disregard incoming equivalences to a path when defining a new one. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: fe8475c500939011b90504304aec61bf6f48ac7d X-Git-Newrev: 8a0faddadd159c19fe79572619ea6466eeed0135 Message-Id: <20211022104930.0DE1A3857821@sourceware.org> Date: Fri, 22 Oct 2021 10:49:30 +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: Fri, 22 Oct 2021 10:49:30 -0000 https://gcc.gnu.org/g:8a0faddadd159c19fe79572619ea6466eeed0135 commit r12-4626-g8a0faddadd159c19fe79572619ea6466eeed0135 Author: Aldy Hernandez Date: Tue Oct 19 20:57:49 2021 +0200 Disregard incoming equivalences to a path when defining a new one. The equivalence oracle creates a new equiv set at each def point, killing any incoming equivalences, however in the path sensitive oracle we create brand new equivalences at each PHI: BB4: BB8: x_5 = PHI Here we note that x_5 == y_8 at the end of the path. The current code is intersecting this new equivalence with previously known equivalences coming into the path. This is incorrect, as this is a new definition. This patch kills any known equivalence before we register a new one. This hasn't caused problems so far, but upcoming changes to the pipeline has us threading more aggressively and triggering corner cases where this causes incorrect code. I have tested this patch with the usual regstrap cycle. I have also hacked a compiler comparing the old and new behavior to see if we were previously threading paths where the decision was made due to invalid equivalences. Luckily, there were no such paths, but there were 22 paths in a set of .ii files where disregarding incoming relations allowed us to thread the path. This is a miniscule improvement, but we moved a handful of thredable paths earlier in the pipeline, which is always good. Tested on x86-64 Linux. Co-authored-by: Andrew MacLeod gcc/ChangeLog: * gimple-range-path.cc (path_range_query::compute_phi_relations): Kill any global relations we may know before registering a new one. * value-relation.cc (path_oracle::killing_def): New. * value-relation.h (path_oracle::killing_def): New. Diff: --- gcc/gimple-range-path.cc | 10 +++++++++- gcc/value-relation.cc | 23 +++++++++++++++++++++++ gcc/value-relation.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 694271306a7..557338993ae 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -698,7 +698,15 @@ path_range_query::compute_phi_relations (basic_block bb, basic_block prev) tree arg = gimple_phi_arg_def (phi, i); if (gimple_range_ssa_p (arg)) - m_oracle->register_relation (entry, EQ_EXPR, arg, result); + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " from bb%d:", bb->index); + + // Throw away any previous relation. + get_path_oracle ()->killing_def (result); + + m_oracle->register_relation (entry, EQ_EXPR, arg, result); + } break; } diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index ac5f3f9afc0..2acf375ca9a 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -1285,6 +1285,29 @@ path_oracle::register_equiv (basic_block bb, tree ssa1, tree ssa2) bitmap_ior_into (m_equiv.m_names, b); } +// Register killing definition of an SSA_NAME. + +void +path_oracle::killing_def (tree ssa) +{ + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, " Registering killing_def (path_oracle) "); + print_generic_expr (dump_file, ssa, TDF_SLIM); + fprintf (dump_file, "\n"); + } + + bitmap b = BITMAP_ALLOC (&m_bitmaps); + bitmap_set_bit (b, SSA_NAME_VERSION (ssa)); + equiv_chain *ptr = (equiv_chain *) obstack_alloc (&m_chain_obstack, + sizeof (equiv_chain)); + ptr->m_names = b; + ptr->m_bb = NULL; + ptr->m_next = m_equiv.m_next; + m_equiv.m_next = ptr; + bitmap_ior_into (m_equiv.m_names, b); +} + // Register relation K between SSA1 and SSA2, resolving unknowns by // querying from BB. diff --git a/gcc/value-relation.h b/gcc/value-relation.h index 53cefbfa7dc..97be3251144 100644 --- a/gcc/value-relation.h +++ b/gcc/value-relation.h @@ -222,6 +222,7 @@ public: ~path_oracle (); const_bitmap equiv_set (tree, basic_block); void register_relation (basic_block, relation_kind, tree, tree); + void killing_def (tree); relation_kind query_relation (basic_block, tree, tree); relation_kind query_relation (basic_block, const_bitmap, const_bitmap); void reset_path ();