Some compilers have a spy optimizer that basically does just that, before it moves on to an assembly that represents IR, it has little opportunity for optimization.
Basically, you would like to do the same thing, from binary, machine code to machine code. Not the same tool, but the same process, consider the code size block and optimize it.
Now there is a problem that you will have to face, although, for example, you may have had some variables that were marked volatile in C, so they are very inefficiently used in binary format, the optimizer does not know what programmers want there, and can end up optimizing this is.
Of course, you can take it to IR and forward it again, nothing to stop you from doing this.
old_timer
source share