This patch delays the fix-up step for external induction variable users until after the dominator tree has been properly updated. This should fix PR30742. The SCEVExpander in InductionDescriptor::transform can generate code in the wrong location if the dominator tree is not up-to-date.
I'm not quite sure if the is the right approach or not. In particular, we use InductionDescriptor::transform in other locations before the dominator tree has been updated. Maybe this isn't a problem because the vector loop is still detached from the dominator tree? In any case, I made an attempt to keep the dominator tree up-to-date at the outset when creating the structure of the vector loop, but that caused the SCEVExpander to generate worse code (the expander was either crashing or creating a new canonical induction variable for every loop). The use of InductionDescriptor::transform when fixing the external induction variable users may be unique in that the insertion point is outside the loop (it's in the middle block). I'm not sure if this would make a difference, though. Please take a look.
Reference: https://llvm.org/bugs/show_bug.cgi?id=30742