[PATCH] D150855: MachineCombiner: consider all uses in getLatency()

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 04:13:37 PDT 2023


barannikov88 added a comment.

Shouldn't there be any test changes?
I'm not familiar with this pass and can't help with further review.



================
Comment at: llvm/lib/CodeGen/MachineCombiner.cpp:286
+            NewRoot, NewRoot->findRegisterDefOperandIdx(MO.getReg()), &UseInstr,
+            UseInstr.findRegisterUseOperandIdx(MO.getReg()));
+      } else {
----------------
(Assuming iterating over all uses is necessary.)
If the register is used by a single instruction multiple times, `findRegisterUseOperandIdx` will always find the first use.
I think `UseMO : MRI->use_[nodbg_]operands(MO.getReg())` should be used instead in the `for` loop, and `UseMO.getOperandNo()` here.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150855



More information about the llvm-commits mailing list