Skip to content

Commit

Permalink
Simplify subtractions with ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Aug 27, 2024
1 parent a210546 commit 3b3371f
Showing 1 changed file with 2 additions and 0 deletions.
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

0 comments on commit 3b3371f

Please sign in to comment.