Currently, DT is not consistent during vector code generation. It's partially updated during code generation and there is a big fix up at the end. Moreover DT updates has strong dependence on fixed structure of vector loop. This is bad for at least two reasons. For upcoming change https://reviews.llvm.org/D71053 we should be able to skip some parts of code generation meaning that vector code structure is not fixed any more.
Second, there is an existing TODO in the code for this:
- // FIXME: After creating the structure of the new loop, the dominator tree is
- // no longer up-to-date, and it remains that way until we update it
- // here. An out-of-date dominator tree is problematic for SCEV,
- // because SCEVExpander uses it to guide code generation. The
- // vectorizer use SCEVExpanders in several places. Instead, we should
- // keep the dominator tree up-to-date as we go.
With this change DT is updated as we go and always reflects current CFG. That means transformations dependent on DT should work correctly now. In addition we can easily skip any part of vector code generation without breaking DT consistency.
Change unrelated to keeping the DT up to date?