@Override
    public void performCSE() throws Exception {
        Instruction i = getDominating();
        while(i != null) {
            if(this.isCommonSubexpression(i)) {
                this.delete((Instruction)i.getSubstitute());
                return;
            } else if (i instanceof Store) {
                Store s = (Store)i;
                if(this.getVariable().equals(s.getVariable())) {
                    return;     // any store to the same variable kills the search
                }
            } else if (i instanceof Call && global) {
                // global variables can be modified by function calls,
                // so kill search on call if global
                return;
            } else if (i instanceof Kill) {
                Identifier killVar = ((Kill)i).getVariable();
                if(killVar.equals(this.getVariable())) {
                    return;
                }
            }
            i = i.getDominating();
        }
    }