Skip to content

Use Result comparison as source of dynamism in RCA#3355

Open
swernli wants to merge 5 commits into
mainfrom
swernli/result-comparison-source-of-dynamism
Open

Use Result comparison as source of dynamism in RCA#3355
swernli wants to merge 5 commits into
mainfrom
swernli/result-comparison-source-of-dynamism

Conversation

@swernli

@swernli swernli commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

This change adjusts how Result values are treated in Runtime Capability Analysis, shifting them from being treated as dynamic variable values by default to treating them as dynamic constant values. This matches the behavior for Qubit variables, as both are identifiers in QIR. Instead of counting on the Result value returned from measurement intrinsics as the source of dynamism, RCA instead tracks when a Result value is used in a comparison and marks the resulting Bool value as a dynamic variable. This more directly maps to how dynamism enters a program and sets the stage for emitting constant Result arrays into the QIR in the same fashion as Qubit arrays. This builds off of the work in #3349 as we now track the difference between dynamic constants and dyanmic variables across function call boundaries, allowing RCA to properly detect comparison of dynamic constant results throughout the program.

Additionally, this changes how cyclic callables are analyzed in RCA, allowing for more advanced handling and emission as IR functions. The cyclic callable pre-analysis is removed in favor of assumptions for return values from cyclic invocations during normal analysis. Combining this with partial eval handling of some intrinsic functions also fixes #3357.

@swernli swernli requested a review from idavis as a code owner June 18, 2026 05:55
swernli added 2 commits June 18, 2026 16:23
This change adjusts how `Result` values are treated in Runtime Capability Analysis, shifting them from being treated as dynamic variable values by default to treating them as dynamic constant values. This matches the behavior for `Qubit` variables, as both are identifiers in QIR. Instead of counting on the `Result` value returned from measurement intrinsics as the source of dynamism, RCA instead tracks when a `Result` value is used in a comparison and marks the resulting `Bool` value as a dynamic variable. This more directly maps to how dynamism enters a program, and sets the stage for emitting constant `Result` arrays into the QIR in the same fashion as `Qubit` arrays.
This builds off of the work in #3349 as we now track the difference between dynamic constants and dyanmic variables across function call boundaries, allowing RCA to properly detect comparison of dynamic constant results throughout the program.
@swernli swernli force-pushed the swernli/result-comparison-source-of-dynamism branch from e1f6e2e to 9a51a12 Compare June 19, 2026 03:36
@swernli swernli requested a review from minestarks as a code owner June 19, 2026 03:36
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.

Std.StatePreparation.PreparePureStateD doesn't work in Base target profile

1 participant