@@ -148,7 +148,7 @@ struct ldp_bb_info
static const size_t obstack_alignment = sizeof (void *);
bb_info *m_bb;
- ldp_bb_info (bb_info *bb) : m_bb (bb)
+ ldp_bb_info (bb_info *bb) : m_bb (bb), m_emitted_tombstone (false)
{
obstack_specify_allocation (&m_obstack, OBSTACK_CHUNK_SIZE,
obstack_alignment, obstack_chunk_alloc,
@@ -164,7 +164,10 @@ struct ldp_bb_info
inline void cleanup_tombstones ();
private:
+ // Did we emit a tombstone insn for this bb?
+ bool m_emitted_tombstone;
obstack m_obstack;
+
inline splay_tree_node<access_record *> *node_alloc (access_record *);
template<typename Map>
@@ -1006,7 +1009,8 @@ fuse_pair (bool load_p,
insn_info *i1,
insn_info *i2,
base_cand &base,
- const insn_range_info &move_range)
+ const insn_range_info &move_range,
+ bool &emitted_tombstone_p)
{
auto attempt = crtl->ssa->new_change_attempt ();
@@ -1021,6 +1025,9 @@ fuse_pair (bool load_p,
insn_change::DELETE);
};
+ // Are we using a tombstone insn for this pair?
+ bool have_tombstone_p = false;
+
insn_info *first = (*i1 < *i2) ? i1 : i2;
insn_info *second = (first == i1) ? i2 : i1;
@@ -1217,6 +1224,7 @@ fuse_pair (bool load_p,
gcc_assert (validate_change (rti, ®_NOTES (rti),
NULL_RTX, true));
change->new_uses = use_array (nullptr, 0);
+ have_tombstone_p = true;
}
gcc_assert (change->new_defs.is_valid ());
gcc_assert (change->new_uses.is_valid ());
@@ -1283,6 +1291,7 @@ fuse_pair (bool load_p,
confirm_change_group ();
crtl->ssa->change_insns (changes);
+ emitted_tombstone_p |= have_tombstone_p;
return true;
}
@@ -1702,7 +1711,8 @@ try_fuse_pair (bool load_p,
unsigned access_size,
insn_info *i1,
insn_info *i2,
- base_info binfo)
+ base_info binfo,
+ bool &emitted_tombstone_p)
{
if (dump_file)
fprintf (dump_file, "analyzing pair (load=%d): (%d,%d)\n",
@@ -1991,7 +2001,7 @@ try_fuse_pair (bool load_p,
range.first->uid (), range.last->uid ());
}
- return fuse_pair (load_p, i1, i2, *base, range);
+ return fuse_pair (load_p, i1, i2, *base, range, emitted_tombstone_p);
}
// Erase [l.begin (), i] inclusive, respecting iterator order.
@@ -2047,7 +2057,8 @@ merge_pairs (insn_iter_t l_begin,
hash_set <insn_info *> &to_delete,
bool load_p,
unsigned access_size,
- base_info binfo)
+ base_info binfo,
+ bool &emitted_tombstone_p)
{
auto iter_l = l_begin;
auto iter_r = r_begin;
@@ -2076,7 +2087,8 @@ merge_pairs (insn_iter_t l_begin,
bool update_r = false;
result = try_fuse_pair (load_p, access_size,
- *iter_l, *iter_r, binfo);
+ *iter_l, *iter_r, binfo,
+ emitted_tombstone_p);
if (result)
{
update_l = update_r = true;
@@ -2153,7 +2165,8 @@ ldp_bb_info::try_form_pairs (insn_list_t *left_orig,
merge_pairs (left_orig->begin (), left_orig->end (),
right_copy.begin (), right_copy.end (),
*left_orig, right_copy,
- to_delete, load_p, access_size, binfo);
+ to_delete, load_p, access_size, binfo,
+ m_emitted_tombstone);
// If we formed all right candidates into pairs,
// then we can skip the next iteration.
@@ -2206,6 +2219,10 @@ ldp_bb_info::transform_for_base (base_info binfo,
void
ldp_bb_info::cleanup_tombstones ()
{
+ // No need to do anything if we didn't emit a tombstone insn for this bb.
+ if (!m_emitted_tombstone)
+ return;
+
insn_info *insn = m_bb->head_insn ();
while (insn)
{