Hi! About the constant propagation: I have a large generic that can benefit from it a lot but post-instantiation. Is this something that the new pass will still improve? Or does it only work pre-instantiation?
@Giovanni Bajo MIR optimizations are currently just pre-instantiation so it's unlikely to help. If you can provide a sample though, we can test and verify for sure.
Actually, let me walk some of that back. Even in a generic function, we can sometimes still perform optimizations in a generic context. If you can link to the code, I'd be happy to take a look. That may also give us some ideas for future improvements or other optimizations.
Also once it gets inlined into a less generic context we can optimize there
Giovanni Bajo MIR optimizations are currently just pre-instantiation so it's unlikely to help. If you can provide a sample though, we can test and verify for sure.
The code is a MIPS64 interpreter (part of my Nintendo64 emulator). The MIPS architecture consists of several generation where new opcodes were added (and sometimes removed) over the years. The interpreter core is a generic parametrized over a trait which describes the architecture. Since each architecture can basically disable specific opcodes, and (for performance reasons too long to explain) I don't have an enum representing each opcode, I ended up using a function called with literal strings.
Example of architecture disabling opcodes:
All the has_op function called are removed by LLVM optimizer, but I'm sure it generates lots of code that is then removed.