I've never seen anyone actually do it, mostly because modeling the problem is more work than just doing it.
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.
Which is what the parent post was talking about, the rare superoptimizer.
In fact there's several different single operations you can build them all out of: https://en.wikipedia.org/wiki/One-instruction_set_computer#I...
So you take your assembly instructions, write a sufficiently good model of assembly instructions<>bit operations, write a cost model (byte size of the assembly works as a cheap one), and then search for assembly instructions that perform the equivalent operation and minimize the cost model.
Like here: https://theory.stanford.edu/~aiken/publications/papers/asplo...
Answer: Verilog or VHDL. And these all synthesize down to AND/OR/XOR gates and eventually converted into NAND gates only.
Every assembly language statement is either data movement, or logic, or some combination of the two.
-------
We are talking about SAT solvers and superoptimizers. Are you at all familiar with this domain? Or have you even done a basic search on what the subject matter is?
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.