angr.analyses.decompiler.peephole_optimizations.fp_exact_identities¶
- class angr.analyses.decompiler.peephole_optimizations.fp_exact_identities.FPExactIdentities¶
Bases:
PeepholeOptimizationExprBaseFloating-point simplifications that are value-exact (bit for bit, for every input):
x * 1.0and1.0 * x->x: exact for every x, including ±0, ±inf and NaN, in any rounding mode.(Exp2(y) - 1.0) + 1.0->Exp2(y): x87f2xm1; fld1; faddp.Exp2comes only from f2xm1, which the converter lowers toExp2(y) - 1.0; f2xm1 is defined only for y in [-1, 1], so e = exp2(y) lies in [0.5, 2]. By Sterbenz’s lemma e - 1.0 is then exact, and (e - 1.0) + 1.0 = e is representable, so the add is exact as well: the folded expression has the same value as the unfolded one in the operation’s type. (The hardware rounds 2^y - 1 to extended precision before adding 1, so either C form may differ from the machine result in the last bit; the fold does not change that.)
Not folded, since they are not exact:
(x - 1.0) + 1.0for arbitrary x (absorbs tiny x, rounds huge x), and-(a - b)->b - a(a == b gives -0.0 vs +0.0).- NAME = 'Fold value-exact floating-point identities'¶
- expr_classes = (<class 'angr.ailment.expression.BinaryOp'>,)¶