[all-commits] [llvm/llvm-project] c8a78a: Greedy: Make eviction broken hint cost use CopyCos...

Matt Arsenault via All-commits all-commits at lists.llvm.org
Mon Sep 22 05:23:00 PDT 2025


  Branch: refs/heads/users/arsenm/greedy/use-class-copy-cost-evict-hint-break
  Home:   https://github.com/llvm/llvm-project
  Commit: c8a78ab0396e576a50d2e2ebfd4925a7039d4de1
      https://github.com/llvm/llvm-project/commit/c8a78ab0396e576a50d2e2ebfd4925a7039d4de1
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-09-22 (Mon, 22 Sep 2025)

  Changed paths:
    M llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
    M llvm/test/CodeGen/AMDGPU/llvm.amdgcn.image.dim.gfx90a.ll
    M llvm/test/CodeGen/RISCV/rvv/vloxseg-rv32.ll
    M llvm/test/CodeGen/RISCV/rvv/vloxseg-rv64.ll
    M llvm/test/CodeGen/RISCV/rvv/vluxseg-rv32.ll
    M llvm/test/CodeGen/RISCV/rvv/vluxseg-rv64.ll
    M llvm/test/CodeGen/RISCV/zilsd.ll

  Log Message:
  -----------
  Greedy: Make eviction broken hint cost use CopyCost units

Change the eviction advisor heuristic cost based on number of broken
hints to work in units of copy cost, rather than a magic number 1.
The intent is to allow breaking hints for cheap subregisters in favor
of more expensive register tuples.

The llvm.amdgcn.image.dim.gfx90a.ll change shows a simple example of
the case I am attempting to solve. Use of tuples in ABI contexts ends up
looking like this:

  %argN = COPY $vgprN
  %tuple = inst %argN
  $vgpr0 = COPY %tuple.sub0
  $vgpr1 = COPY %tuple.sub1
  $vgpr2 = COPY %tuple.sub2
  $vgpr3 = COPY %tuple.sub3

Since there are physreg copies in the input and output sequence,
both have hints to a physreg. The wider tuple hint on the output
should win though, since this satisfies 4 hints instead of 1.

This is the obvious part of a larger change to better handle
subregister interference with register tuples, and is not sufficient
to handle the original case I am looking at. There are several bugs here
that are proving tricky to untangle. In particular, there is a double
counting bug for all registers with multiple regunits; the cost of breaking
the interfering hint is added for each interfering virtual register,
which have repeat visits across regunits. Fixing this badly regresses
a number of RISCV tests, which seem to rely on overestimating the cost
in tryFindEvictionCandidate to avoid early-exiting the eviction
candidate loop.



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