[llvm] [CodeGen] IMPLICIT_DEF must not contribute to Weight in LICM register cost computation (PR #196500)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 25 00:47:32 PDT 2026


================
@@ -969,6 +969,11 @@ MachineLICMImpl::calcRegisterCost(const MachineInstr *MI, bool ConsiderSeen,
     if (MO.isDef())
       RCCost = W.RegWeight;
     else {
+      // IMPLICIT_DEF contributes zero register pressure, so a vreg whose
+      // unique def is IMPLICIT_DEF must not reduce tracked pressure.
+      if (MachineInstr *DefMI = MRI->getUniqueVRegDef(Reg);
----------------
pratikashar wrote:

"Process Implicit Definitions" is enqueued by `TargetPassConfig::addOptimizedRegAlloc()` and runs before PHI elimination. In this pass, IMPLICIT_DEF instructions defining virtual registers are removed and their uses are replaced with undef attribute on the use MachineOperand.

Do you still think there may be issues wrt liveness with this change?

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


More information about the llvm-commits mailing list