angr.analyses.decompiler.optimization_passes.x87_fprem_loop

class angr.analyses.decompiler.optimization_passes.x87_fprem_loop.X87FpremLoopSimplifier

Bases: OptimizationPass

Collapse the x87 remainder loop L: fprem[1]; fnstsw ax; sahf; jp L into a single fmod() / remainder().

fprem and fprem1 only reduce the exponent difference by up to 63 per step and set C2 while the remainder is partial; the loop repeats them until C2 is clear, which yields the complete IEEE remainder. The self-loop block is turned into a straight-line block: PRem/PRem1 already stand for the complete operation, and C2 is clear when the loop exits. The status intrinsic stays only where something after the loop reads its quotient bits.

ARCHES = ['X86', 'AMD64']
PLATFORMS = None
STAGE: OptimizationPassStage = 6
NAME = 'Collapse x87 fprem/fprem1 loops'
DESCRIPTION = 'Collapse the x87 remainder loop ``L: fprem[1]; fnstsw ax; sahf; jp L`` into a single fmod() / remainder().\n\n    fprem and fprem1 only reduce the exponent difference by up to 63 per step and set C2 while the remainder is\n    partial; the loop repeats them until C2 is clear, which yields the complete IEEE remainder. The self-loop block is\n    turned into a straight-line block: PRem/PRem1 already stand for the complete operation, and C2 is clear when the\n    loop exits. The status intrinsic stays only where something after the loop reads its quotient bits.'
__init__(*args, **kwargs)