void dce(Method m){
  Deque<Block> code=dfs(m.entry.to);
  cp(code);
  BitSet marked=new BitSet();
  for (  Block b : code)   for (  Expr e : b)   if (hasSideEffect(e))   dce_mark(marked,e);
  for (  Block b : code)   for (Iterator<Expr> i=b.iterator(); i.hasNext(); )   if (!marked.get(i.next().id)) {
    i.remove();
  }
}

void dce ( Method m ) { Deque < Block > code = dfs ( m . entry . to ) ; cp ( code ) ; BitSet marked = new BitSet ( ) ; for ( Block b : code ) for ( Expr e : b ) if ( hasSideEffect ( e ) ) dce_mark ( marked , e ) ; for ( Block b : code ) for ( Iterator < Expr > i = b . iterator ( ) ; i . hasNext ( ) ; ) if ( ! marked . get ( i . next ( ) . id ) ) { i . remove ( ) ; } }
dead code elimination . first perform copy propagation and then remove any expressions not used by the essential expressions that have side effects .
