[all-commits] [llvm/llvm-project] ca879f: RegisterCoalescer: Don't mark a remat def dead whe...

Matt Arsenault via All-commits all-commits at lists.llvm.org
Wed Sep 23 23:44:42 PDT 2026


  Branch: refs/heads/users/arsenm/register-coalescer/dont-mark-remat-def-dead-live-super-reg
  Home:   https://github.com/llvm/llvm-project
  Commit: ca879ff8a0fcc06496a47415d627ed409906c354
      https://github.com/llvm/llvm-project/commit/ca879ff8a0fcc06496a47415d627ed409906c354
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-09-24 (Thu, 24 Sep 2026)

  Changed paths:
    M llvm/lib/CodeGen/RegisterCoalescer.cpp
    M llvm/test/CodeGen/X86/coalesce-commute-partial-def-implicit-read.mir
    M llvm/test/CodeGen/X86/masked-udiv.ll
    M llvm/test/CodeGen/X86/min-legal-vector-width.ll
    A llvm/test/CodeGen/X86/rematerialize-sub-super-reg-dead-flags.mir
    M llvm/test/CodeGen/X86/rematerialize-sub-super-reg.mir
    M llvm/test/CodeGen/X86/statepoint-invoke-ra-inline-spiller.mir
    M llvm/test/CodeGen/X86/statepoint-invoke-ra-remove-back-copies.mir
    M llvm/test/CodeGen/X86/statepoint-invoke-ra.mir
    M llvm/test/CodeGen/X86/statepoint-ra.ll
    M llvm/test/CodeGen/X86/statepoint-vreg-details.ll
    M llvm/test/CodeGen/X86/udiv_fix.ll
    M llvm/test/CodeGen/X86/udiv_fix_sat.ll
    M llvm/test/CodeGen/X86/vector-idiv-strictfp.ll
    M llvm/test/CodeGen/X86/vector-idiv-udiv-512.ll

  Log Message:
  -----------
  RegisterCoalescer: Don't mark a remat def dead when the copy destination covers it

When rematerializing into a physical register that is not exactly the copy's
destination, reMaterializeDef marks the rematerialized def dead and adds an
implicit-def of the copy destination. That is only correct when the rematerialized
instruction defines more than the copy asked for, so the extra part really is unused.

It is wrong when the def is covered by the copy destination, since then it is
part of that live value:

  undef %0.sub_32bit:gr64 = MOV32ri -11
  $rax = COPY %0

  ; coalesces to
  dead $eax = MOV32ri -11, implicit-def $rax

$eax is the live low half of $rax, so it must not be dead. Only set the dead
flag when the def has register units the copy destination does not cover.
This makes the dead flags consistent with what LiveVariables would produce
in these scenarios.

Co-Authored-By: Claude Opus 5 <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