[llvm] [llvm][CodeGen] Update checking method of loop-carried phi in window scheduler (PR #96288)

Hua Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 05:01:32 PDT 2024


=?utf-8?b?4oCcYWtpcmF0aWFu4oCd?= <akiratian at tencent.com>,
=?utf-8?b?4oCcYWtpcmF0aWFu4oCd?= <akiratian at tencent.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/96288 at github.com>


================
@@ -192,22 +192,37 @@ bool WindowScheduler::initialize() {
     return false;
   }
   // Check each MI in MBB.
-  SmallVector<Register, 8> PhiDefs;
+  SmallSet<Register, 8> PrevDefs;
+  SmallSet<Register, 8> PrevUses;
+  auto IsLoopCarried = [&](MachineInstr &Phi) {
+    // Two cases are checked here: (1)The virtual register defined by the
+    // preceding phi is used by the succeeding phi;(2)The preceding phi uses the
+    // virtual register defined by the succeeding phi.
+    auto Def = Phi.getOperand(0);
+    if (Def.isReg()) {
+      if (PrevUses.count(Def.getReg()))
+        return true;
+      PrevDefs.insert(Def.getReg());
+    }
+    for (unsigned I = 1, E = Phi.getNumOperands(); I != E; I += 2) {
+      auto Use = Phi.getOperand(I);
+      if (Use.isReg()) {
----------------
huaatian wrote:

Updated

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


More information about the llvm-commits mailing list