else
cleanup_dst(n);
} else {
- if (n.bc.op_ptr->flags & (CF_CLAUSE | CF_BRANCH | CF_LOOP))
+ if ((sh.dce_flags & DF_EXPAND) &&
+ (n.bc.op_ptr->flags & (CF_CLAUSE | CF_BRANCH | CF_LOOP)))
n.expand();
}
return true;
}
void dce_cleanup::cleanup_dst(node& n) {
- cleanup_dst_vec(n.dst);
+ if (!cleanup_dst_vec(n.dst) && remove_unused &&
+ !n.dst.empty() && !(n.flags & NF_DONT_KILL) && n.parent)
+ n.remove();
}
bool dce_cleanup::visit(container_node& n, bool enter) {
- if (enter) {
+ if (enter)
cleanup_dst(n);
- } else {
-
- }
return true;
}
-void dce_cleanup::cleanup_dst_vec(vvec& vv) {
+bool dce_cleanup::cleanup_dst_vec(vvec& vv) {
+ bool alive = false;
+
for (vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) {
value* &v = *I;
if (!v)
continue;
- if (v->is_dead())
+ if (v->gvn_source && v->gvn_source->is_dead())
+ v->gvn_source = NULL;
+
+ if (v->is_dead() || (remove_unused && !v->is_rel() && !v->uses))
v = NULL;
+ else
+ alive = true;
}
+
+ return alive;
}
} // namespace r600_sb