Tech News
← Home  ·  All topics

Fpu Emulator

2 GoKawiil briefs on this topic · RSS for fpu emulator

Developer uses brute-force superoptimization to simplify FPU bit-twiddling function

A developer building a floating-point library needed a function returning the lowest set bit of a float's mantissa, but the straightforward bitwise algorithm failed on powers of two, requiring a slow conditional branch. Unable to find a branch-free formula by hand, they built a brute-force search that tests short sequences of integer operations against representative test cases, adding counterexamples when a candidate formula fails.

Developer publishes vectorized CLZ/CTZ bit-counting technique using floating-point tricks

A developer building an FPU emulator devised a way to compute leading-zero and trailing-zero bit counts using floating-point exponent manipulation instead of native CLZ/CTZ CPU instructions, and found the approach can be vectorized across multiple integers at once using SIMD (u64x4). Benchmarks on the author's Haswell CPU showed the vectorized version running at 0.45 ns per iteration versus 1 ns for scalar code, with a separate test on Alder Lake by Ian Qvist showing 0.29 ns versus 0.85 ns.