Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify subtractions with ptr #197

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ let rec binop ty (op : binop) (hte1 : t) (hte2 : t) : t =
binop ty Rem addr hte2
| Add, _, Ptr { base; offset } ->
ptr base (binop (Ty_bitv 32) Add offset hte1)
| Sub, _, Ptr { base; offset } ->
binop ty Sub hte1 (binop (Ty_bitv 32) Add (value (Num (I32 base))) offset)
| (Add | Or), Val (Num (I32 0l)), _ -> hte2
| (And | Div | DivU | Mul | Rem | RemU), Val (Num (I32 0l)), _ -> hte1
| (Add | Or), _, Val (Num (I32 0l)) -> hte1
Expand Down