[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
Thu May 1 08:06:57 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:

That had been my suggestion, but I agree that's not really a net positive.  I think I'd misread the code and thought your second if only applied to OR

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


More information about the llvm-commits mailing list