[all-commits] [llvm/llvm-project] 5d2c4e: RegisterPressure: Detect dead physreg defs from Li...

Matt Arsenault via All-commits all-commits at lists.llvm.org
Mon Sep 21 06:02:31 PDT 2026


  Branch: refs/heads/users/arsenm/codegen/pressurediff-dead-physreg-superreg
  Home:   https://github.com/llvm/llvm-project
  Commit: 5d2c4e85b1a513886f008c407e264618e9c9e3f8
      https://github.com/llvm/llvm-project/commit/5d2c4e85b1a513886f008c407e264618e9c9e3f8
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-09-21 (Mon, 21 Sep 2026)

  Changed paths:
    M llvm/include/llvm/CodeGen/RegisterPressure.h
    M llvm/lib/CodeGen/RegisterPressure.cpp
    M llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.cpp
    M llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
    M llvm/lib/Target/AMDGPU/GCNRegPressure.h
    M llvm/test/CodeGen/X86/masked-udiv.ll
    M llvm/test/CodeGen/X86/min-legal-vector-width.ll
    A llvm/test/CodeGen/X86/misched-pressure-dead-physreg-superreg.mir
    M llvm/test/CodeGen/X86/ssub_sat_plus.ll
    M llvm/test/CodeGen/X86/statepoint-ra.ll
    M llvm/test/CodeGen/X86/statepoint-vreg-unlimited-tied-opnds.ll
    M llvm/test/CodeGen/X86/udiv_fix.ll
    M llvm/test/CodeGen/X86/udiv_fix_sat.ll
    M llvm/test/CodeGen/X86/usub_sat_plus.ll
    M llvm/test/CodeGen/X86/vector-idiv-strictfp.ll
    M llvm/test/CodeGen/X86/vector-idiv-udiv-512.ll
    M llvm/test/CodeGen/X86/xmulo.ll

  Log Message:
  -----------
  RegisterPressure: Detect dead physreg defs from LiveIntervals

This reverts the remainder of #222627, which was partially reverted by
on dead flags. This is a prerequisite to deleting LiveVariables.

When constructing the PressureDiff for an instruction during scheduling
DAG construction, dead defs were only recognized from the dead flag on the
operand. This implicitly relied on preprocessing done by LiveVariables to
fixup inconsistent dead flags with overlapping registers in other operands.
Dead flags have no verifier-enforced rules and are thus unreliable.

Before LiveVariables, consider this example:

  dead $eax = MOV32r0 implicit-def dead $eflags, implicit-def $rax
  ; $rax is never used

$rax is never used, but only the $eax def is dead-flagged and the overlapping
implicit-def $rax is not. The shared $eax register units are covered by the
non-dead $rax def and so are counted as live defs. That shared unit is then
decremented on recede without a matching increment, tripping the "PSet
overflow/underflow" assertion in getUpwardPressureDelta.

Operand dead flags only describe physreg liveness reliably when
LiveVariables produced them. For a wide def that is only partly used,
HandlePhysRegKill marks the superregister def dead and adds a separate,
explicitly non-dead def of the used sub-register. In the example, LiveVariables
fixes up the flags to liven $eax, and make $rax dead:

  $eax = MOV32r0 implicit-def dead $eflags, implicit-def dead $rax

The rule is a regunit unit is dead iff every def covering it is dead. When
LiveVariables does not run, the superregister dead flag is simply missing and
the flags no longer describe liveness.

Detect dead defs from LiveIntervals instead, matching what the pressure
tracker already does on the recede path. We need to not take a conservative no
answer if getCachedRegUnit doesn't already have the computed interval, so add
a parameter to not use the cache. This is the source of most of the churn, which
needs to de-constify the LiveIntervals passed around.

I'm somewhat dissatisfied with relying on LiveIntervals and ignoring the flags. I'm
separately working on adding some verifier rules for dead flags, though I'm not
sure that will be sufficient to avoid this.

Co-authored-by: Claude claude-opus-4.8 <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list