logoalt Hacker News

Superoptimizing an FPU Emulator

18 points • by dverlaeckt80 • last Friday at 1:08 PM • 2 comments • view on HN

Comments

neerajsi • today at 4:41 AM

I was curious about whether one of the count bits instructions can help. Of course I'm lazy now and asked an llm to check... The llm noticed that the articles solution includes a floating point subtract in the end. This is fine since the target is wasm which has fsub/fadd, but was initially odd to see in a floating point emulator.

Apparently a ctz solution is a bit longer, but doesn't cross from the floating to integer domain at all, so might be better in the overall algorithm. There are hidden implicit floating to int convert instructions.

This was a really cool little problem!

azhenley • today at 5:04 AM

I shared a toy superoptimizer I made a few years ago: https://news.ycombinator.com/item?id=36117950

It was a really fun project!