private void pruneDeadInstructions() {
    HashSet<SsaInsn> deletedInsns = new HashSet<SsaInsn>();

    BitSet reachable = ssaMeth.computeReachability();
    ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks();
    int blockIndex = 0;

    while ((blockIndex = reachable.nextClearBit(blockIndex)) < blocks.size()) {
      SsaBasicBlock block = blocks.get(blockIndex);
      blockIndex++;

      // Prune instructions from unreachable blocks
      for (int i = 0; i < block.getInsns().size(); i++) {
        SsaInsn insn = block.getInsns().get(i);
        RegisterSpecList sources = insn.getSources();
        int sourcesSize = sources.size();

        // Delete this instruction completely if it has sources
        if (sourcesSize != 0) {
          deletedInsns.add(insn);
        }

        // Delete this instruction from all usage lists.
        for (int j = 0; j < sourcesSize; j++) {
          RegisterSpec source = sources.get(j);
          useList[source.getReg()].remove(insn);
        }

        // Remove this instruction result from the sources of any phis
        RegisterSpec result = insn.getResult();
        if (result == null) continue;
        for (SsaInsn use : useList[result.getReg()]) {
          if (use instanceof PhiInsn) {
            PhiInsn phiUse = (PhiInsn) use;
            phiUse.removePhiRegister(result);
          }
        }
      }
    }

    ssaMeth.deleteInsns(deletedInsns);
  }
Removes all instructions from every unreachable block.
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/DeadCodeRemover.java