Skip to content

Commit 3b3371f

Browse files
committed
Simplify subtractions with ptr
1 parent a210546 commit 3b3371f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/expr.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ let rec binop ty (op : binop) (hte1 : t) (hte2 : t) : t =
288288
binop ty Rem addr hte2
289289
| Add, _, Ptr { base; offset } ->
290290
ptr base (binop (Ty_bitv 32) Add offset hte1)
291+
| Sub, _, Ptr { base; offset } ->
292+
binop ty Sub hte1 (binop (Ty_bitv 32) Add (value (Num (I32 base))) offset)
291293
| (Add | Or), Val (Num (I32 0l)), _ -> hte2
292294
| (And | Div | DivU | Mul | Rem | RemU), Val (Num (I32 0l)), _ -> hte1
293295
| (Add | Or), _, Val (Num (I32 0l)) -> hte1

0 commit comments

Comments
 (0)