by astrange · 1y ago · 0 comments
I've never seen anyone actually do it, mostly because modeling the problem is more work than just doing it.
Could you elaborate please? How would you approach this problem, using a SAT solver? All I know is that a SAT solver tells you whether a certain formula of ANDs and ORs is true. I don't know how it could be useful in this case.
SAT solvers can prove that some (shorter) sequences are equivalent to other (longer) sequences. But it takes a brute force search.
IIRC, these super optimizing SAT solvers can see patterns and pick 'Multiply' instructions as part of their search. So it's more than traditional SAT. But it's still... At the end of the day.... A SAT equivalence problem.
Have you ever seen a WallaceTree multiplier? A good sequence that shows how XOR and AND gates can implement multiply.
Now, if multiply + XOR gets the new function you want, it's likely better than whatever the original compiler output.
Also of course all instructions are MOV anyway. https://github.com/xoreaxeaxeax/movfuscator
The most ffmpeg has had to do in this area is that some CPUs had very slow unaligned memory loads and some didn't.