Let $k$ be an algebraically closed field (in my application, it is characteristic zero, but this probably doesn't matter so much), and let $P: k \to k$, $Q: k \to k$ be polynomials of one variable. Then $P(x)-Q(y)$ is a polynomial of two variables $x,y$. Generically, one expects this polynomial to be irreducible, but there are some exceptional cases where it becomes reducible. For instance, if $P=Q$ and $P,Q$ have degree greater than $1$, then $P(x)-Q(y)$ contains $x-y$ as a nontrivial factor. More generally, if $P = R \circ \tilde P$ and $Q = R \circ \tilde Q$ for some polynomials $\tilde P, \tilde Q, R$ with $R$ having degree greater than $1$, then $P(x)-Q(y)$ contains $\tilde P(x)-\tilde Q(y)$ as a nontrivial factor.

My (somewhat vague) question is whether there is a way to classify all the pairs of polynomials $P, Q$ in which $P(x)-Q(y)$ becomes reducible. Of course, this has a tautological answer - it is those $P, Q$ for which one can factorise $P(x)-Q(y) = R(x,y) S(x,y)$ for some polynomials $R,S$ - but I am looking for a criterion which is somehow simpler to verify than the general problem of determining whether an arbitrary polynomial of two variables is irreducible. Ideally it should have the flavour of "the only obstructions to irreducibility are the obvious ones". One could naively conjecture that the above examples are in fact the only reducible examples; indeed I could not produce any other examples, but this is likely a failure of my own imagination.

I have this vague picture of viewing the curve $\{ (x,y): P(x)=Q(y)\}$ as a relative product of the curves $\{ (x,z): z = P(x) \}$ and $\{ (y,z): z = Q(y) \}$ over the $z$-axis, so that the irreducibility of the former should somehow relate to the structure of the latter two factors (and in particular, in the location and nature of the singular points of the projection maps to the $z$-axis), but I don't know how to make this precise. (Maybe I should have paid more attention to Riemann surfaces as a student...)

Actually, I'm ultimately interested in the multidimensional version of this question, namely to give a criterion for when the algebraic set $\{ (x,y) \in k^d \times k^d: P(x)=Q(y) \}$ is an irreducible variety, where $P, Q: k^d \to k^m$ are polynomial maps, but given that even the $d=m=1$ case seems to be non-trivial, I thought I should focus on that first.