aboutsummaryrefslogtreecommitdiff
path: root/gcc/rtl-ssa/accesses.cc
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2025-09-02 15:58:26 -0700
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2025-09-02 15:58:26 -0700
commit071b4126c613881f4cb25b4e5c39032964827f88 (patch)
tree7ed805786566918630d1d617b1ed8f7310f5fd8e /gcc/rtl-ssa/accesses.cc
parent845d23f3ea08ba873197c275a8857eee7edad996 (diff)
parentcaa1c2f42691d68af4d894a5c3e700ecd2dba080 (diff)
downloadgcc-devel/gfortran-test.zip
gcc-devel/gfortran-test.tar.gz
gcc-devel/gfortran-test.tar.bz2
Merge branch 'master' into gfortran-testdevel/gfortran-test
Diffstat (limited to 'gcc/rtl-ssa/accesses.cc')
-rw-r--r--gcc/rtl-ssa/accesses.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc
index 3d92997..0415e97 100644
--- a/gcc/rtl-ssa/accesses.cc
+++ b/gcc/rtl-ssa/accesses.cc
@@ -1087,6 +1087,38 @@ rtl_ssa::lookup_use (splay_tree<use_info *> &tree, insn_info *insn)
return tree.lookup (compare);
}
+// See the comment above the declaration.
+use_lookup
+function_info::find_use (set_info *def, insn_info *insn)
+{
+ gcc_assert (!insn->is_debug_insn ());
+ use_info *first = def->first_nondebug_insn_use ();
+ if (!first)
+ // There are no uses. The comparison result is pretty meaningless
+ // in this case.
+ return { nullptr, -1 };
+
+ // See whether the first use matches.
+ if (*insn <= *first->insn ())
+ {
+ int comparison = (insn == first->insn () ? 0 : -1);
+ return { first, comparison };
+ }
+
+ // See whether the last use matches.
+ use_info *last = def->last_nondebug_insn_use ();
+ if (*insn >= *last->insn ())
+ {
+ int comparison = (insn == last->insn () ? 0 : 1);
+ return { last, comparison };
+ }
+
+ // Resort to using a splay tree to search for the result.
+ need_use_splay_tree (def);
+ int comparison = lookup_use (def->m_use_tree, insn);
+ return { def->m_use_tree.root ()->value (), comparison };
+}
+
// Add USE to USE->def ()'s list of uses. inserting USE immediately before
// BEFORE. USE is not currently in the list.
//