Skip to content

RIFLA: Support emission of loops over constant arrays#3101

Merged
swernli merged 4 commits intomainfrom
swernli/rifla-arrays
Apr 20, 2026
Merged

RIFLA: Support emission of loops over constant arrays#3101
swernli merged 4 commits intomainfrom
swernli/rifla-arrays

Conversation

@swernli
Copy link
Copy Markdown
Collaborator

@swernli swernli commented Apr 7, 2026

This updates the Adaptive_RIFLA profile to support emission of loops over arrays with constant, compile-time known content. Where the prior looping support only handled loops with iteration-invariant internals, this updates RCA, Partial Eval, RIR, and QIR codegen to allow for arrays with constant content stored in the global section to be the source of iteration values within a loop.

For now, only loops with variable types we already support work with this pattern, specifically loops over constant arrays of Bool, Int, and Double. Arrays of arrays are not supported, due to the lack of QIR compatible mechanism for dynamically querying the length of an array and Q# support for jagged arrays of arrays (ie: [[1.0], [2.0, 3.0]]). Follow up PRs will add support for iteration over constant arrays of new types like Qubit and Pauli. Arrays with dynamic contents will be handled later down the line.

This updates the `Adaptive_RIFLA` profile to support emission of loops over arrays with constant, compile-time known content. Where the prior looping support only handled loops with iteration-invariant internals, this updates RCA, Partial Eval, RIR, and QIR codegen to allow for arrays with constant content stored in the global section to be the source of iteration values within a loop.

For now, only loops with variable types we already support work with this pattern, specifically loops over constant arrays of `Bool`, `Int`, and `Double`. Arrays of arrays are not supported, due to the lack of QIR compatible mechanism for dynamically querying the length of an array and Q# support for jagged arrays of arrays (ie: `[[1.0], [2.0, 3.0]]`). Follow up PRs will add support for iteration over constant arrays of new types like `Qubit` and `Pauli`. Arrays with dynamic contents will be handled later down the line.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Change in memory usage detected by benchmark.

Memory Report for 76291c3

Test This Branch On Main Difference
compile core + standard lib 24572134 bytes 24572311 bytes -177 bytes

Comment thread source/compiler/qsc_rca/src/tests/loops.rs
Comment thread source/compiler/qsc_rir/src/passes/prune_unneeded_stores.rs Outdated
Comment thread source/compiler/qsc_partial_eval/src/lib.rs
@swernli swernli added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit 7bda4b1 Apr 20, 2026
12 checks passed
@swernli swernli deleted the swernli/rifla-arrays branch April 20, 2026 19:30
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.

3 participants