cleanup_semantics() should remove repeated prim_from_bv(x)
This commit is contained in:
committed by
Jakob Stoklund Olesen
parent
11014ec544
commit
1ddee38895
@@ -57,21 +57,30 @@ def cleanup_semantics(r, outputs):
|
|||||||
new_defs = [] # type: List[Def]
|
new_defs = [] # type: List[Def]
|
||||||
subst_m = {v: v for v in r.vars()} # type: VarMap
|
subst_m = {v: v for v in r.vars()} # type: VarMap
|
||||||
definition = {} # type: Dict[Var, Def]
|
definition = {} # type: Dict[Var, Def]
|
||||||
|
prim_to_bv_map = {} # type: Dict[Var, Def]
|
||||||
|
|
||||||
# Pass 1: Remove redundant prim_to_bv
|
# Pass 1: Remove redundant prim_to_bv
|
||||||
for d in r.rtl:
|
for d in r.rtl:
|
||||||
inst = d.expr.inst
|
inst = d.expr.inst
|
||||||
|
|
||||||
if (inst == prim_to_bv):
|
if (inst == prim_to_bv):
|
||||||
if d.expr.args[0] in definition:
|
arg = d.expr.args[0]
|
||||||
assert isinstance(d.expr.args[0], Var)
|
df = d.defs[0]
|
||||||
def_loc = definition[d.expr.args[0]]
|
assert isinstance(arg, Var)
|
||||||
|
|
||||||
|
if arg in definition:
|
||||||
|
def_loc = definition[arg]
|
||||||
if def_loc.expr.inst == prim_from_bv:
|
if def_loc.expr.inst == prim_from_bv:
|
||||||
assert isinstance(def_loc.expr.args[0], Var)
|
assert isinstance(def_loc.expr.args[0], Var)
|
||||||
subst_m[d.defs[0]] = def_loc.expr.args[0]
|
subst_m[df] = def_loc.expr.args[0]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if arg in prim_to_bv_map:
|
||||||
|
subst_m[df] = prim_to_bv_map[arg].defs[0]
|
||||||
|
continue
|
||||||
|
|
||||||
|
prim_to_bv_map[arg] = d
|
||||||
|
|
||||||
new_def = d.copy(subst_m)
|
new_def = d.copy(subst_m)
|
||||||
|
|
||||||
for v in new_def.defs:
|
for v in new_def.defs:
|
||||||
|
|||||||
Reference in New Issue
Block a user