Skip to content

✨ Pull GPhaseOps out of multi-operation ctrl modifiers #1759

@denialhaag

Description

@denialhaag

Description

#1751 has dropped the condition that modifier bodies can only contain a single unitary operation followed by a yield operation.

We should add a canonicalization that pulls out GPhaseOps from multi-operation ctrl modifiers. For example,

%const = arith.constant 0.123 : f64
qc.ctrl(%c0, %c1) targets(%t0, %t1) {
  qc.gphase(%const)
  qc.rxx(%const) %t0, %t1 : !qc.qubit, !qc.qubit
}

is unrolled to

%const = arith.constant 0.123 : f64
qc.ctrl(%c0) targets(%c1) {
  qc.p(%const) %c1 : !qc.qubit
}
qc.ctrl(%c0, %c1) targets(%t0, %t1) {
  qc.rxx(%const) %t0, %t1 : !qc.qubit, !qc.qubit
}

Notice that we already have such a canonicalization for one-operation ctrl modifiers. It should be possible to adapt some of the existing code.

Acceptance criteria

  • The described canonicalization is implemented in QC and QCO
  • The two comments made in #1603 are taken into account

Metadata

Metadata

Assignees

No one assigned

    Labels

    MLIRAnything related to MLIRfeatureNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions