Skip to content

Commit fd5ef9c

Browse files
committed
Simplifier: push member expressions inside a let
There are a couple of key patterns involving members that we can understand, such as member-of-typecast and member-of-byte-extract, neither of which work properly if we have an intervening let expression.
1 parent 52fc545 commit fd5ef9c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/util/simplify_expr_struct.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,21 @@ bool simplify_exprt::simplify_member(exprt &expr)
289289

290290
return false;
291291
}
292+
else if(op.id() == ID_let)
293+
{
294+
// Push a member operator inside a let binding, to avoid the let bisecting
295+
// structures we otherwise know how to analyse, such as
296+
// (let x = 1 in ({x, x})).field1 --> let x = 1 in ({x, x}.field1) -->
297+
// let x = 1 in x
298+
member_exprt pushed_in_member = to_member_expr(expr);
299+
pushed_in_member.op() = to_let_expr(op).where();
300+
expr = op;
301+
to_let_expr(expr).where() = pushed_in_member;
302+
to_let_expr(expr).type() = to_let_expr(expr).where().type();
303+
304+
simplify_rec(expr);
305+
return false;
306+
}
292307

293308
return true;
294309
}

0 commit comments

Comments
 (0)