This patch fixes problems reported in PR51981.
When rotating a loop it isn't enough to just forget SCEV for that
loop nest. When rotating we might clone some instructions from the
old header into the preheader, and insert new PHI nodes to merge
values together. There could be users of the original value that are
updated to use the PHI result. And those users were not necessarily
depending on a PHI node earlier, so they weren't cleaned up when just
forgetting all SCEV:s for the loop nest. So we need to explicitly
forget those values to avoid invalid cached SCEV expressions.
I think that at least SE could be made a reference instead of a pointer here. At least loop-rotate always fetches ScalarEvolution nowadays (but probably also DominatorTree).
So we could get rid of the conditional checks if SE is non-null.
Maybe I'll fix that in a separate patch later. Unless someone beats me to it.