Skip to content

[RISCV][Vortex] Bank-aware register allocation hints: keep an instruc… - #4

Open
jel221 wants to merge 1 commit into
vortexgpgpu:vortex_3.xfrom
jel221:feature/register-bank-hints
Open

jel221 wants to merge 1 commit into
vortexgpgpu:vortex_3.xfrom
jel221:feature/register-bank-hints

Conversation

@jel221

@jel221 jel221 commented Nov 17, 2026

Copy link
Copy Markdown

Human comment:
vortexgpgpu/vortex#479
This makes register bank conflicts rare in the compiler to justify reducing the operand collector.

AI-generated comment:

Summary

Bank-aware register allocation hints for XVortex. The Vortex operand collector reads source registers from 4 single-ported banks, selected by the low two bits of the register number (x0 is not read). Two sources of one instruction in the same bank cost an extra read cycle. This change makes the register allocator prefer, for each virtual register, a physical register in a different bank from the other sources it is read with.

How it works (RISCVRegisterInfo::getRegAllocationHints → addVortexBankHints):

  • For every non-debug use of the virtual register, count per bank the other explicit source operands of that instruction that already have a physical register (GPR and FPR16/32/64; x0 excluded).
  • If any are counted, append the allocation order as hints, stable-sorted by that bank count, so registers in the least-used bank come first.
  • Existing hints (copy and two-address hints) stay first. Reserved registers are skipped. A callee-saved register nothing uses yet keeps its place after the hints, so the pass never adds a save and restore to avoid a conflict.
  • Runs only when the subtarget has +xvortex and the base hints are not hard. -riscv-vortex-bank-hints=false turns it off.

It is a hint, not a constraint: the allocator still takes whatever is free, and no instruction count changes.

Results

Static count of instructions whose register sources share a bank (Vortex regression kernels as built by their Makefiles, XLEN 32):

Kernel Before After
stencil3d 33 15
dotproduct 6 2
sgemm 6 2
sort 4 1

The same register read twice (e.g. fmul ft0, fa0, fa0) also conflicts, and no allocation can fix it. jacobi's remaining conflicts are in the prebuilt soft-double library calls.

Cycles (rtlsim, 64 warps, 4 issue slices, 32 threads, 8 kernels): about −1% geomean with 2 or 4 operand collectors per issue slice (conv3 −4%), no change with 1 per slice.

Tests

  • New llvm/test/CodeGen/RISCV/xvortex-bank-hints.ll: a stencil FMA chain, 3 same-bank source pairs before, 0 after.
  • Six existing xvortex tests regenerated with update_llc_test_checks.py; register names only (xvortex-group-bitcast, -group-extract-subvector, -group-i1-mem, -group-lanes, xvortex-wide-dag-merge, -wide-lsv-llc). With the option off they pass unchanged.
  • All Vortex lit tests pass. 28 non-Vortex RISC-V lit tests fail with and without this change on vortex_3.x; none use +xvortex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant