Chiasmus is a rhetorical device where identical words and phrases repeat in a reversed order.
From A Poet’s Glossary
The following additional definition of the term chiasmus is reprinted from A Poet's Glossary by Edward Hirsch.
[The word chiasmus in] Greek [means] “a diagonal arrangement” or “placing cross-wise.” The rhetorical device chiasmus is named after the Greek letter X and suggests a criss-crossing of sentence members, a grammatically balanced statement of contrasting or opposing ideas or sounds.
Quintilian (first century C.E.) provided an example: “Write quickly and you will never write well; write well and you will soon write quickly.” Samuel Johnson (1709-1784) said, “Those whose lot it is to ramble can seldom write, and those who know how to write very seldom ramble.” Chiasmus was probably a Semitic inheritance in Greek culture, like the alphabet, and figures prominently both in the Hebrew Bible and the New Testament. It takes a specialized form in the figure known as antimetabole (“turn about”), which is used when identical words or phrases repeat in reversed order, as when Alexander Pope writes in The Rape of the Lock (1712-1714):
Yet graceful ease, and sweetness void of pride,
Might hide her faults, if belles had faults to hide.