Skip to content

Conversation

@pow2clk
Copy link
Contributor

@pow2clk pow2clk commented Dec 3, 2025

After losing all its type information to annotateMatrix, createMatrix had no purpose and would have resulted in all calls being merged as redundant, however, some means of uniquely identifying a matrix is needed that annotateMatrix can't do because it needs to be generated for parameters as well as locals and globals (assuming we allow globals).

Previous handles for resources have had global variables that are able to uniquely identify them and workgraph handles have had parameters to the entry functions. Lacking either of these, it was impossible to distinguish allocas created for the initial declaration of a matrix and one that was created for a parameter that should get merged when inlining that function. By generating a unique createMatrix call where the local variable is declared or in the entry block for global variables.

Addresses some issues in #696 though not in the way I initially proposed there

After losing all its type information to annotateMatrix, createMatrix had no purpose and would have resulted in all calls being merged as redundant, however, some means of uniquely identifying a matrix is needed that annotateMatrix can't do because it needs to be generated for parameters as well as locals and globals (assuming we allow globals).

Previous handles for resources have had global variables that are able to uniquely identify them and workgraph handles have had parameters to the entry functions. Lacking either of these, it was impossible to distinguish allocas created for the initial declaration of a matrix and one that was created for a parameter that should get merged when inlining that function. By generating a unique createMatrix call where the local variable is declared or in the entry block for global variables.

Addresses some issues in microsoft#696 though not in the way I initially proposed there
@pow2clk pow2clk changed the title Revise createMatrix to create a unique reference [0035] Revise createMatrix to create a unique reference Dec 3, 2025
@damyanp
Copy link
Member

damyanp commented Jan 14, 2026

@pow2clk - I think that things have moved on enough that we should probably close this PR?

@pow2clk
Copy link
Contributor Author

pow2clk commented Jan 14, 2026

While I acknowledge the spec has moved in some direction since this began its languishing period, I don't think another solution to the problem it solves has been proposed. With no parameters, the create function needs to be marked read/write to prevent invalid deduplication. This prevents removal of unused create calls. Even if they are mangled to match the mangled handle proposed, read/write is still needed to prevent merging creation of matrices with identical types.

@damyanp
Copy link
Member

damyanp commented Jan 14, 2026

Ok - please resolve the conflicts with this PR so we can get it reviewed and merged.

@llvm-beanz
Copy link
Collaborator

The alternate approach to this is in #769, which removes the createMatrix op entirely.

@pow2clk
Copy link
Contributor Author

pow2clk commented Jan 14, 2026

I hadn't looked it over much. It definitely does. Closing.

@pow2clk pow2clk closed this Jan 14, 2026
@github-project-automation github-project-automation bot moved this to Triaged in HLSL Triage Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Triaged

Development

Successfully merging this pull request may close these issues.

3 participants