aboutsummaryrefslogtreecommitdiff
path: root/gcc/rtl-ssa/accesses.cc
diff options
context:
space:
mode:
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.
//