As per discussion in https://reviews.llvm.org/D122857#3483861, https://reviews.llvm.org/D122857#3483912,
the print output of loop cache analysis sometimes has a non-deterministic order (and therefore we have been using CHECK-DAG in its lit tests).
This patch changes the sorting of LoopCosts to llvm::stable_sort() where we compare loop cost numbers and sort the loops. In case of the same loop cost numbers, llvm::stable_sort() now would output a deterministic loop order.
Comments on this patch are appreciated :)
nit: there should be no need to use llvm:: as this is already in the llvm namespace.