[llvm] [GlobalISel][Localizer] Allow localization of a small number of repeated phi uses. (PR #77566)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 01:22:13 PST 2024


================
@@ -164,19 +166,23 @@ bool Localizer::localizeIntraBlock(LocalizedSetVecT &LocalizedInstrs) {
       if (!UseMI.isPHI())
         Users.insert(&UseMI);
     }
-    // If all the users were PHIs then they're not going to be in our block,
-    // don't try to move this instruction.
-    if (Users.empty())
-      continue;
-
     MachineBasicBlock::iterator II(MI);
-    ++II;
-    while (II != MBB.end() && !Users.count(&*II))
+    // If all the users were PHIs then they're not going to be in our block, we
+    // may still benefit from sinking, especially since the value might be live
+    // across a call.
+    if (Users.empty()) {
+      // Make sure we don't sink in between
+      // two terminator sequences by scanning forward, not backward.
----------------
arsenm wrote:

weird line break 

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


More information about the llvm-commits mailing list