[PATCH] D59565: Allow machine dce to remove uses in the same instruction

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 15:09:17 PDT 2019


rampitec added inline comments.


================
Comment at: lib/CodeGen/DeadMachineInstructionElim.cpp:84-85
       } else {
-        if (!MRI->use_nodbg_empty(Reg))
-          // This def has a non-debug use. Don't delete the instruction!
-          return false;
+        for (const MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
+          if (MO.getParent() != MI)
+            // This def has a non-debug use. Don't delete the instruction!
----------------
arsenm wrote:
> This needs a search limit in case of huge numbers of uses?
> This can also use use_nodbg_instructions
It does need a limit. The only way it can run into a very long loop if all huge amount of uses will belong to the same instruction. Otherwise it will immediately return false at the first use from any other place.


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

https://reviews.llvm.org/D59565





More information about the llvm-commits mailing list