Skip to content

Comments

Generalized affine expression decomposition for SGPR promotion#945

Draft
panditsa wants to merge 1 commit intoiree-org:mainfrom
panditsa:affine-simplification
Draft

Generalized affine expression decomposition for SGPR promotion#945
panditsa wants to merge 1 commit intoiree-org:mainfrom
panditsa:affine-simplification

Conversation

@panditsa
Copy link
Contributor

Add an N-way uniformity decomposition pass that splits any affine expression into additive components by symbol class (workgroup, induction variable, thread). This allows the LLVM backend to keep uniform contributions in SGPRs and fold them into hardware instruction fields (e.g. buffer_load soffset), reducing VGPR pressure.

Key changes:

  • symbol_utils.py: add decompose_affine_by_uniformity(), a general N-way decomposition with cascade validation for cross-class terms
  • emitter.py: add get_uniformity_classes() and gen_sympy_index_decomposed() so any handler can decompose arbitrary affine maps at the emitter level
  • read_write.py: replace _split_index_three_way with the general utility, add _compute_linear_offset/_apply_uniform_offsets helpers, and apply the decomposition to handle_read, handle_write, and handle_gather_to_lds

Add an N-way uniformity decomposition pass that splits any affine
expression into additive components by symbol class (workgroup,
induction variable, thread). This allows the LLVM backend to keep
uniform contributions in SGPRs and fold them into hardware instruction
fields (e.g. buffer_load soffset), reducing VGPR pressure.

Key changes:
- symbol_utils.py: add decompose_affine_by_uniformity(), a general
  N-way decomposition with cascade validation for cross-class terms
- emitter.py: add get_uniformity_classes() and
  gen_sympy_index_decomposed() so any handler can decompose arbitrary
  affine maps at the emitter level
- read_write.py: replace _split_index_three_way with the general
  utility, add _compute_linear_offset/_apply_uniform_offsets helpers,
  and apply the decomposition to handle_read, handle_write, and
  handle_gather_to_lds

Co-authored-by: Cursor <cursoragent@cursor.com>
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