Skip to content

RIFLA: Support emitting constant Result arrays#3277

Draft
swernli wants to merge 4 commits into
mainfrom
swernli/rifla-result-arrays
Draft

RIFLA: Support emitting constant Result arrays#3277
swernli wants to merge 4 commits into
mainfrom
swernli/rifla-result-arrays

Conversation

@swernli
Copy link
Copy Markdown
Collaborator

@swernli swernli commented Jun 1, 2026

This change supports the emission of constant Result arrays for Adaptive RIFLA QIR generation. To do so, we needed the compiler to see arrays of result values as "dynamic constant" expressions, which required a change to how Result values are handled during RCA and Partial Eval. Previously, any Result value coming back from an intrinsic operation was treated a dynamic variable, even though they are really just identifiers. This updates that logic to recognized results as identifiers, the same way qubits are identifiers, and moves the source of dynamic variables in RCA to the actual comparison of results rather than being inherent to the result itself. To make sure this quality propagates across function call boundaries appropriately, RCA was updated to differentiate between call arguments that are static vs dynamic constant vs dynamic variable, where previously it only checked for dynamic variable and treated constant and static as the same.

In addition, this also includes an update to RCA that adds a new capability to recognize when a static Result value (One or Zero) is used as the output from a dynamic expression, since that cannot be emitted into QIR. The new check detects this at analysis time so the error is visible in the editor before the user tries to emit QIR (if applicable).

This change supports the emission of constant `Result` arrays for Adaptive RIFLA QIR generation. To do so, we needed the compiler to see arrays of result values as "dynamic constant" expressions, which required a change to how `Result` values are handled during RCA and Partial Eval. Previously, any `Result` value coming back from an intrinsic operation was treated a dynamic variable, even though they are really just identifiers. This updates that logic to recognized results as identifiers, the same way qubits are identifiers, and moves the source of dynamic variables in RCA to the actual comparison of results rather than being inherent to the result itself. To make sure this quality propagates across function call boundaries appropriately, RCA was updated to differentiate between call arguments that are static vs dynamic constant vs dynamic variable, where previously it only checked for dynamic variable and treated constant and static as the same.

In addition, this also includes an update to RCA that adds a new capability to recognize when a static `Result` value (`One` or `Zero`) is used as the output from a dynamic expression, since that cannot be emitted into QIR. The new check detects this at analysis time so the error is visible in the editor before the user tries to emit QIR (if applicable).
@swernli swernli marked this pull request as draft June 2, 2026 16:24
@swernli
Copy link
Copy Markdown
Collaborator Author

swernli commented Jun 2, 2026

Converting to draft for now. I found some test holes, new corner cases, and existing bugs that I'd like to get cleaned up and resolved first.

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