[llvm] [CodeGen] Improve compilation time with VLIWMachineScheduler (PR #66942)

Dávid Ferenc Szabó via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 11:52:23 PDT 2023


https://github.com/dfszabo created https://github.com/llvm/llvm-project/pull/66942

A straight forward improvement which can already achieve 2x speed up in some cases like the one here: https://github.com/llvm/llvm-project/issues/65946.


>From 8547248656603f4500ad531efd0fec9b6c3b8675 Mon Sep 17 00:00:00 2001
From: dszabo <szabodavidferenc at gmail.com>
Date: Wed, 20 Sep 2023 19:45:38 +0200
Subject: [PATCH] [CodeGen] Improve compilation time with VLIWMachineScheduler

---
 llvm/include/llvm/CodeGen/VLIWMachineScheduler.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h b/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h
index bd12baa6afaba67..112ff6df034450d 100644
--- a/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h
+++ b/llvm/include/llvm/CodeGen/VLIWMachineScheduler.h
@@ -165,8 +165,9 @@ class ConvergingVLIWScheduler : public MachineSchedStrategy {
       // a slightly different heuristic for small and large functions. For small
       // functions, it's important to use the height/depth of the instruction.
       // For large functions, prioritizing by height or depth increases spills.
-      CriticalPathLength = DAG->getBBSize() / SchedModel->getIssueWidth();
-      if (DAG->getBBSize() < 50)
+      const auto BBSize = DAG->getBBSize();
+      CriticalPathLength = BBSize / SchedModel->getIssueWidth();
+      if (BBSize < 50)
         // We divide by two as a cheap and simple heuristic to reduce the
         // critcal path length, which increases the priority of using the graph
         // height/depth in the scheduler's cost computation.



More information about the llvm-commits mailing list