[PATCH] D130769: [RISCV] Combine and remove redundant ADD/SUB instructions

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 17:15:11 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVAddSubCombiner.cpp:118
+    MachineInstr *CurrentInstr = &*MBBI;
+    if (Opcode != CheckedInstr->getOpcode()) {
+      return false;
----------------
Drop curly braces


================
Comment at: llvm/lib/Target/RISCV/RISCVAddSubCombiner.cpp:129
+      if (ResultImm != 0) {
+        // Combine instructions to one.
+        DebugLoc DL = CheckedInstr->getDebugLoc();
----------------
Can we update the immediate for MBBI instead of creating a new instruction?


================
Comment at: llvm/lib/Target/RISCV/RISCVAddSubCombiner.cpp:168
+      auto RegisterUsageIter = ModificationRegisterMonitor.find(MBBI->getOperand(2).getReg());
+      if ( RegisterUsageIter != ModificationRegisterMonitor.end()) {
+        for (const auto &Users : RegisterUsageIter->second) {
----------------
Extra space here


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130769/new/

https://reviews.llvm.org/D130769



More information about the llvm-commits mailing list