Skip to content

OptimizeSwapBeforeMeasure removes classically conditioned SwapGate #6192

@kdk

Description

@kdk

Information

  • Qiskit Terra version:
  • Python version:
  • Operating system:

What is the current behavior?

From https://travis-ci.com/github/Qiskit/qiskit-terra/jobs/495770351#L997:

>>> qc = qk.QuantumCircuit.from_qasm_str('''
OPENQASM 2.0;
include "qelib1.inc";
qreg q3134[2];
creg c137[1];
cx q3134[1],q3134[0];
h q3134[1];
if(c137==1) swap q3134[1],q3134[0];
measure q3134[1] -> c137[0];
''')
>>> qc.draw()
         ┌───┐               
q3134_0: ┤ X ├────────X──────
         └─┬─┘┌───┐   │   ┌─┐
q3134_1: ──■──┤ H ├───X───┤M├
              └───┘┌──╨──┐└╥┘
 c137: 1/══════════╡ = 1 ╞═╩═
                   └─────┘ 0 
>>> qk.transpile(qc, optimization_level=3).draw()
         ┌───┐     ┌─┐
q3134_0: ┤ X ├─────┤M├
         └─┬─┘┌───┐└╥┘
q3134_1: ──■──┤ H ├─╫─
              └───┘ ║ 
 c137: 1/═══════════╩═
                    0 

Steps to reproduce the problem

What is the expected behavior?

Suggested solutions

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions