Skip to content

🎨 Allow repeated memref.loads of the same qubit #1893

Description

@denialhaag

Currently, the QCProgramBuilder does not allow repeated memref.loads of the same qubit:

if (regionStack.size() == 1) {
llvm::reportFatalUsageError(
"Qubit cannot be loaded in the main function region");
}
for (Region* curr : regionStack) {
if (loadedQubits[curr][memref].contains(index)) {
llvm::reportFatalUsageError("Qubit already loaded in enclosing region");
}
}

We should look into whether we can relax this. MLIR might have built-in canonicalization patterns that remove redundant memref.loads.

This change would also allow us to simplify the translation from OpenQASM 3 to QC. For some more details, see #1862 (comment) and the comments below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MLIRAnything related to MLIRenhancementImprovement of existing feature

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions