[llvm] [RISCV][TII] Add and use new hook to optimize/canonicalize instructions after MachineCopyPropagation (PR #137973)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 09:28:48 PDT 2025
================
@@ -510,6 +510,16 @@ class TargetInstrInfo : public MCInstrInfo {
return false;
}
+ /// If possible, converts the instruction to a more 'optimized'/canonical
+ /// form. Returns true if the instruction was modified.
+ ///
+ /// This function is only called after register allocation. The MI will be
+ /// modified in place. This is called by passes such as
+ /// MachineCopyPropagation, where their mutation of the MI operands may
+ /// expose opportunities to convert the instruction to a simpler form (e.g.
+ /// a load of 0).
+ virtual bool optimizeInstruction(MachineInstr &MI) const { return false; }
----------------
arsenm wrote:
Name is way too general for a very narrowly applied optimization. Can't this just go in a separate post-RA pass
https://github.com/llvm/llvm-project/pull/137973
More information about the llvm-commits
mailing list