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

Matt Arsenault via All-commits all-commits at lists.llvm.org
Fri Oct 2 09:10:23 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d9d72d603296da6188c8c8c1f56e6c515a4818a6
      https://github.com/llvm/llvm-project/commit/d9d72d603296da6188c8c8c1f56e6c515a4818a6
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-10-02 (Fri, 02 Oct 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 (#226037)

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