Unverified Commit 1e46589f by Enkelmann Committed by GitHub

Simplify more cases of trivial expressions (#346)

parent 44ec840b
...@@ -268,6 +268,25 @@ fn trivial_expression_substitution() { ...@@ -268,6 +268,25 @@ fn trivial_expression_substitution() {
rhs: Box::new(setup.rax_variable.clone()), rhs: Box::new(setup.rax_variable.clone()),
} }
); );
// Test (x - const_1) - const_2 = x - (const_1 + const_2)
let mut expr = Expression::BinOp {
lhs: Box::new(Expression::BinOp {
lhs: Box::new(setup.rax_variable.clone()),
op: BinOpType::IntSub,
rhs: Box::new(Expression::Const(Bitvector::from_i64(3))),
}),
op: BinOpType::IntSub,
rhs: Box::new(Expression::Const(Bitvector::from_i64(4))),
};
expr.substitute_trivial_operations();
assert_eq!(
expr,
Expression::BinOp {
lhs: Box::new(setup.rax_variable.clone()),
op: BinOpType::IntSub,
rhs: Box::new(Expression::Const(Bitvector::from_i64(7)))
}
);
} }
#[test] #[test]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment