[llvm] [MachineLICM] Fix the check for high register pressure (PR #118780)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 02:14:48 PST 2024


https://github.com/mgudim created https://github.com/llvm/llvm-project/pull/118780

We should be checking the register pressure change in MI's parent block before hoisting the instruction.

>From 37383dab8f05cc57388fddc28bb19611c445a372 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at gmail.com>
Date: Thu, 5 Dec 2024 05:09:09 -0500
Subject: [PATCH] [MachineLICM] Fix the check for high register pressure

We should be checking the register pressure change in MI's parent block
before hoisting the instruction.
---
 llvm/lib/CodeGen/MachineLICM.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index d21059189b1844..973b0627ce15ae 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -1250,6 +1250,8 @@ bool MachineLICMImpl::CanCauseHighRegPressure(
     if (CheapInstr && !HoistCheapInsts)
       return true;
 
+    if (static_cast<int>(RegPressure[Class]) + RPIdAndCost.second >= Limit)
+      return true;
     for (const auto &RP : BackTrace)
       if (static_cast<int>(RP[Class]) + RPIdAndCost.second >= Limit)
         return true;



More information about the llvm-commits mailing list