[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
Thu May 1 05:46:58 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:
+  case RISCV::XOR:
+      // Normalize:
----------------
asb wrote:

I did run clang-format, but it turns out this file had an issue of a previous `// clang-format off` not having a matching `// clang-format on` to re-enable it. I've fixed that issue in https://github.com/llvm/llvm-project/commit/3376071a24b772446d2f2241e4370b6d0cba6947 and reformatted.

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


More information about the llvm-commits mailing list