Antimetabole
According to Wikipedia:
In rhetoric, antimetabole […] is the repetition of words in successive clauses, but in transposed order; for example, “I know what I like, and I like what I know”.
That Wikipedia entry provides a bunch more examples.
My mind immediately went to a bit from the Mad Tea Party, in Alice’s Adventures in Wonderland:
“Then you should say what you mean,” the March Hare went on.
“I do,” Alice hastily replied; “at least—at least I mean what I say—that’s the same thing, you know.”
“Not the same thing a bit!” said the Hatter. “Why, you might just as well say that ‘I see what I eat’ is the same thing as ‘I eat what I see’!”
“You might just as well say,” added the March Hare, “that ‘I like what I get’ is the same thing as ‘I get what I like’!”
“You might just as well say,” added the Dormouse, who seemed to be talking in his sleep, “that ‘I breathe when I sleep’ is the same thing as ‘I sleep when I breathe’!”
“It is the same thing with you,” said the Hatter[…]