diff options
| author | Ajax <commial@gmail.com> | 2018-02-13 14:46:18 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2018-02-14 12:14:07 +0100 |
| commit | c887ab5c5da2c12ccb84be93da238a9c9be3e229 (patch) | |
| tree | 13ec520246b674dcb4880fe8e3213ca4442a2662 /miasm2/expression/simplifications_common.py | |
| parent | 0056026fa2f07b49d54236148ad5c528b18b381f (diff) | |
| download | miasm-c887ab5c5da2c12ccb84be93da238a9c9be3e229.tar.gz miasm-c887ab5c5da2c12ccb84be93da238a9c9be3e229.zip | |
A >> X >> Y => A >> (X+Y) ONLY IF X + Y does not overflow
Diffstat (limited to 'miasm2/expression/simplifications_common.py')
| -rw-r--r-- | miasm2/expression/simplifications_common.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py index 6eb5e804..6840a0ac 100644 --- a/miasm2/expression/simplifications_common.py +++ b/miasm2/expression/simplifications_common.py @@ -212,10 +212,15 @@ def simp_cst_propagation(e_s, expr): args0 = args[0].args[0] args = [args0, args1] - # A >> X >> Y => A >> (X+Y) + # A >> X >> Y => A >> (X+Y) if X + Y does not overflow + # To be sure, only consider the simplification when X.msb and Y.msb are 0 if (op_name in ['<<', '>>'] and args[0].is_op(op_name)): - args = [args[0].args[0], args[0].args[1] + args[1]] + X = args[0].args[1] + Y = args[1] + if (e_s(X.msb()) == ExprInt(0, 1) and + e_s(Y.msb()) == ExprInt(0, 1)): + args = [args[0].args[0], X + Y] # ((A & A.mask) if op_name == "&" and args[-1] == expr.mask: |