[llvm] [CodeGen] Do not include undef registers in the set of used ops (PR #80367)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 18:49:45 PST 2024


https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/80367

>From 3cb0f58668867ba58666187ade35d095cfb488d2 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Thu, 1 Feb 2024 19:23:55 -0500
Subject: [PATCH] [CodeGen] Do not include undef registers in the set of used
 ops

Undef registers are no-ops, and therefore do not have any dependency associated with them, nor should undef registers be counted as a used op.
---
 llvm/lib/CodeGen/MachineSink.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index e7e8f60268348..a87be5120e59b 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -1979,11 +1979,10 @@ static bool hasRegisterDependency(MachineInstr *MI,
       }
       DefedRegsInCopy.push_back(Reg);
 
-      // FIXME: instead of isUse(), readsReg() would be a better fix here,
-      // For example, we can ignore modifications in reg with undef. However,
-      // it's not perfectly clear if skipping the internal read is safe in all
-      // other targets.
-    } else if (MO.isUse()) {
+      // FIXME: It's not perfectly clear if skipping the internal read is safe
+      // in all other targets. If it is, we can replace this condition with
+      // MO.readReg()
+    } else if (!MO.isUndef()) {
       if (!ModifiedRegUnits.available(Reg)) {
         HasRegDependency = true;
         break;



More information about the llvm-commits mailing list