Skip to content

Commit

Permalink
Fix removal of unnecessary checks
Browse files Browse the repository at this point in the history
Ref. None
  • Loading branch information
treiher committed Jul 10, 2024
1 parent 5806f2b commit 3ecdfd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions rflx/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ def preconditions(self, _variable_id: Generator[ID, None, None]) -> list[Cond]:
return []

def to_z3_expr(self) -> z3.BoolRef:
raise NotImplementedError
if isinstance(self.type_, rty.AnyInteger):
return z3.And(
z3.Int(str(self.identifier)) >= z3.IntVal(self.type_.bounds.lower),
z3.Int(str(self.identifier)) <= z3.IntVal(self.type_.bounds.upper),
)
return z3.BoolVal(val=True)

def _update_str(self) -> None:
initialization = f" = {self.expression}" if self.expression else ""
Expand Down Expand Up @@ -1914,7 +1919,7 @@ def remove_unnecessary_checks(statements: Sequence[Stmt], manager: ProofManager)
),
],
)
facts.append(s)
facts.append(s)

results = manager.check()

Expand Down
1 change: 0 additions & 1 deletion tests/unit/ir_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,5 @@ def test_add_required_checks() -> None:
ir.Assign("Z", ir.IntVal(0), INT_TY),
ir.VarDecl("T_1", rty.BASE_INTEGER),
ir.Assign("T_1", ir.Sub(ir.IntVal(100), ir.IntVal(1)), rty.BASE_INTEGER),
ir.Check(ir.LessEqual(ir.IntVar("Z", INT_TY), ir.IntVar("T_1", rty.BASE_INTEGER))),
ir.Assign("C", ir.Add(ir.IntVar("Z", INT_TY), ir.IntVal(1)), INT_TY),
]

0 comments on commit 3ecdfd0

Please sign in to comment.