[llvm] [MachinePipeliner] Make Recurrence MII More Accurate (PR #105475)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 22:36:38 PDT 2024


================
@@ -1680,13 +1680,19 @@ void SwingSchedulerDAG::Circuits::createAdjacencyStructure(
         Added.set(N);
       }
     }
-    // A chain edge between a store and a load is treated as a back-edge in the
-    // adjacency matrix.
+    // Order edges of the following:
+    // 1. Load -> Store
+    // 2. Store -> Load
+    // are treated as a back-edge in the adjacency matrix.
+    // Store after store was handled above.
     for (auto &PI : SUnits[i].Preds) {
-      if (!SUnits[i].getInstr()->mayStore() ||
+      if (PI.getKind() != SDep::Order ||
           !DAG->isLoopCarriedDep(&SUnits[i], PI, false))
         continue;
-      if (PI.getKind() == SDep::Order && PI.getSUnit()->getInstr()->mayLoad()) {
+      if ((SUnits[i].getInstr()->mayLoad() &&
+           PI.getSUnit()->getInstr()->mayStore()) ||
+          (SUnits[i].getInstr()->mayStore() &&
+           PI.getSUnit()->getInstr()->mayLoad())) {
----------------
kasuga-fj wrote:

Thank you for your trying and investigating! 
I haven't investigated the details, but I think several things are happening that lead to the problem you encountered. The root cause, I guess, is that the newly added back-edges are not taken into account in the processes after finding circuits. I think it takes some effort to fix these problems, so I agree with you that this should be fixed by other patches.

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


More information about the llvm-commits mailing list