[llvm] [RISCV][TII] Add and use new hook to optimize/canonicalize instructions after MachineCopyPropagation (PR #137973)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 07:02:42 PDT 2025


asb wrote:

Thank you everyone. I believe all of the comments on the details of the implementation have been addressed an are reflected in the pushed version of the code. I have tweaked the commit message to clarify that the tail duplication that produces the opportunity for these transformations is from tail duplication performed in MachineBlockPlacement.

I believe the open issues are:
* Hook naming. Some ideas
  * simplifyInstruction (on the basis that it applies basic simplifications - e.g. to li or mv)
  * optimizeMutatedInstruction (on the basis that it is an optimisation intended to be run after an instruction's operands have been mutated an instruction, which may present new opportunities for simplifying)
  * yourIdeaHere - honestly, I don't have strong views!
* Whether this makes sense as a tweak to MCP as proposed, or a separate pass
  * It would be possible to add a target specific pass or add to a new one, but it does seem like this is relevant to targets beyond just RISC-V and requires only a minimal tweak to MCP, with an interface that could be used from other target-specific passes that might need it. So if the preference is to _not_ go this route, I'd like to better understand the argument against.

https://github.com/llvm/llvm-project/pull/137973


More information about the llvm-commits mailing list