[PATCH] D92069: [NFC] [TargetRegisterInfo] add one use check to lookThruCopyLike.

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 02:34:10 PST 2021


nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM now. Maybe give @echristo a bit of time to see if this adequately addresses his original concern.



================
Comment at: llvm/lib/CodeGen/TargetRegisterInfo.cpp:541-547
+    if (!MI->isCopyLike()) {
+      // Check if the final definition only has one user.
+      if (MRI->hasOneNonDBGUse(SrcReg))
+        return SrcReg;
+      else
+        return Register();
+    }
----------------
Minor nit: Stylistically, it is probably a bit neater to write this as:
```
// Found the real definition, return it if it has a single use.
if (!MI->isCopyLike())
  return MRI->hasOneNonDBGUse(SrcReg) ? SrcReg : Register();
```


================
Comment at: llvm/lib/CodeGen/TargetRegisterInfo.cpp:557
+
+    // Check if current definition is not virtual and has only one one user.
+    if (!CopySrcReg.isVirtual() || !MRI->hasOneNonDBGUse(CopySrcReg))
----------------
Maybe it is clearer as:
```
// Continue only if the next definition in the chain is for a virtual
// register that has a single use.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92069



More information about the llvm-commits mailing list