angr.analyses.decompiler.peephole_optimizations.magic_div_simplifier¶
- class angr.analyses.decompiler.peephole_optimizations.magic_div_simplifier.MagicDivisionSimplifier¶
Bases:
PeepholeOptimizationExprBaseRestore divisions by constants that compilers lower into shifts and multiply-high sequences:
(x + ((x >>a (n-1)) >> (n-k))) >>a kand(x + (x >> (n-1))) >>a 1=>x /s 2**kx - ((x + <same bias>) & -2**k)=>x %s 2**k((x + hi(x * M)) >>a s) - (x >>a (n-1))and(hi(x * M) >>a s) - (x >>a (n-1))=>x /s dhi(x * M) >> s=>x /u d
where
hi(x * M)is the upper half of a double-width product. Each candidate divisor is checked by evaluating the matched sequence on sample inputs.- NAME = 'Simplify divisions by constants lowered to shifts and multiply-high'¶
- expr_classes = (<class 'angr.ailment.expression.BinaryOp'>, <class 'angr.ailment.expression.Convert'>)¶