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

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 30 15:11:54 PDT 2025


================
@@ -3850,6 +3865,207 @@ MachineInstr *RISCVInstrInfo::commuteInstructionImpl(MachineInstr &MI,
   return TargetInstrInfo::commuteInstructionImpl(MI, NewMI, OpIdx1, OpIdx2);
 }
 
+bool RISCVInstrInfo::optimizeInstruction(MachineInstr &MI) const {
+  switch (MI.getOpcode()) {
+  default:
+    break;
+  case RISCV::OR:
----------------
preames wrote:

Just structure wise, not sure you gain much if anything by handling both of these together.  Particularly with Craig's commute suggestion, the shared code is pretty minimal.  

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


More information about the llvm-commits mailing list