[DAGCombiner] Factor duplicated rotate code into a separate function

No functional change intended.