This is re-land of https://reviews.llvm.org/rL327362 with a fix and regression test.
The crash was due to it is possible that for found MDL loop, LHS or RHS may contain
an invariant unknown SCEV which does not dominate the MDL. Please see regression
test for an example.