Skip to content

Commit

Permalink
change assert to regular check-and-early-exit
Browse files Browse the repository at this point in the history
  • Loading branch information
paul0403 committed Dec 20, 2024
1 parent 7330335 commit 1f70360
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mlir/lib/Quantum/Transforms/PropagateSimpleStatesAnalysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ class PropagateSimpleStatesAnalysis {
// get state from parent and gate
StringRef gate = cast<quantum::CustomOp>(op).getGateName();
Value parent = op->getOperand(0);
assert(qubitValues.contains(parent));

// non basis states stay as non basis states
if (qubitValues[parent] == QubitState::NOT_A_BASIS) {
// Unknown parent state, child state is thus also unknown
if (!qubitValues.contains(parent) || isOther(qubitValues[parent])) {
qubitValues[res] = QubitState::NOT_A_BASIS;
return;
}
Expand All @@ -179,9 +178,7 @@ class PropagateSimpleStatesAnalysis {

// A valid FSM transition gate
// Special treatment for S+ gate from |L> and |R>
if (((qubitValues[parent] == QubitState::LEFT) ||
(qubitValues[parent] == QubitState::RIGHT)) &&
(gate == "S")) {
if ((isLeft(qubitValues[parent]) || isRight(qubitValues[parent])) && gate == "S") {
if (op->hasAttr("adjoint")) {
switch (qubitValues[parent]) {
case QubitState::LEFT:
Expand Down

0 comments on commit 1f70360

Please sign in to comment.