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.
Currently, the
QCProgramBuilderdoes not allow repeatedmemref.loads of the same qubit:core/mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp
Lines 162 to 170 in def69f1
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.