In case you think this is something revelatory, it should be noted that such a thing exists for z/OS, specifically to deal with COBOL code. IBM makes the Automatic Binary Optimizer (ABO) which does something similar (optimizes binary code) but has a very different motivation: in some cases, organizations have lost the source and can’t recompile it to get improvements. In other cases, the code is so old that it is cheaper to optimize the binary rather than pay developers to work on the code. This falls under the “compiler migration” terminology used in IBM’s marketing.
I know this because I worked with people who worked on ABO at IBM. ABO is (or at least was) a money maker there.