Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise SSA transformation for OpenQASM 3 variables #40

Open
mhillenbrand opened this issue Feb 9, 2023 · 0 comments
Open

Revise SSA transformation for OpenQASM 3 variables #40

mhillenbrand opened this issue Feb 9, 2023 · 0 comments

Comments

@mhillenbrand
Copy link
Contributor

Description

qss-compiler expresses variable references and assignments in OpenQASM 3 source code as MLIR operations that directly reflect these references and assignments in the initial MLIR -- that is, the initial MLIR uses memory semantics for variables. For later optimization, it is beneficial to resolve these operations with memory semantics such that the use of a variable directly uses the SSA value that has been assigned to the variable at that point.

Currently, the compiler uses the pass VariableElimination towards that goal. That pass takes a detour through the affine dialect and its scalar replacement pass. As a downside, that approach currently cannot resolve variable memory semantics around control flow.

We should revise the VariableElimination pass to fully resolve the OpenQASM 3 variable operations into SSA form.

Tasks

  • Identify test cases first.
  • Revise the VariableElimination pass.

Acceptance Criteria

  • New test cases check corner cases.

Proposal

  • The transformation could be integrated into quirgen. Yet, it should remain its own pass to facilitate debugging and unit testing.
  • Consider Marc M. Brandis, Hanspeter Mössenböck

Notes

  • The paper Marc M. Brandis, Hanspeter Mössenböck: Single-pass generation of static single-assignment form for structured languages describes an algorithm for transforming structured control flow into SSA form in a single pass and may serve as a starting point. The algorithm generates "classical SSA" with phi nodes, while MLIR has block and region arguments (and yield values), so there's some transformation required.
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

No branches or pull requests

1 participant