From what I've seen (in talks for a general physics audience, but I'm not in the field of quantum computing), all or most quantum algorithms are fixed sequences of instructions applied to registers made of qbits. These instructions are built from quantum logic gates (e.g. Hadamard, Pauli, CNOT), just as classical computer instructions like "ADD" are built from half-adders and full-adders, and ultimately from classical logic gates like AND, OR, NOT, or just NAND.
Conditional jump instructions, such as JZ ("jump if zero") and JNE ("jump if not equal") in x86, are important in classical computing, without which I don't think it would be possible to implement the familiar if
, else
, for
, and while
of high-level languages. If the "instruction pointer" (e.g. the EIP register in x86) in a quantum computer has a classical value, then I would conclude that data-dependent jumps are not possible, since querying the value of a qbit would destroy its coherence. But am I wrong about the architecture of current or future quantum computers—is the instruction pointer itself made of qbits? That is, can the position in the instruction sequence be part of a quantum superposition? Can one quantum arithmetic-logic unit be on different instruction steps at the same time?
I have seen statements that quantum computers can run classical algorithms. Some classical algorithms require data-dependent jumps. Or is it the case that quantum algorithms can jump if the states are $|0\rangle$ and $|1\rangle$ (i.e. already on the measurement basis) but not a mixed $a|0\rangle + b|1\rangle$, just as cloning is possible for some states, but not arbitrary states?
I haven't found obvious counter-examples; e.g. Wikipedia's description of Grover's algorithm appears to lack data-dependent jumps. (It says "repeat N times," but N is assigned externally. A compiler could unroll that loop.) On the other hand, the LanQ quantum imperative programming language includes a while
statement, which suggests that it can do data-dependent jumps, if the expr
in while (expr)
can have a superimposed value.
If I'm thinking about this correctly and quantum algorithms can't make data-dependent jumps, it seems similar to SIMD programming, in which we would effectively perform if
statements by masking part of the data, rather than by jumping over instructions, and certain kinds of loops aren't possible. Am I thinking about it correctly?