Created attachment 17462 [details] -loop-vectorize bug The attached program shows a failure in opt's loop vectorizer pass. I believe this failure has been present for several releases, and I have replicated it with trunk, 3.9, etc. % opt bug.bc -verify -disable-output % opt bug.bc -loop-vectorize -disable-output Instruction does not dominate all uses! %49 = select i1 %48, i32 1, i32 %47 %43 = add i32 %49, -7 LLVM ERROR: Broken function found, compilation aborted!
I believe the vectorizer must not be keeping the dominator tree up to date properly. It looks like a SCEVExpander is generating code in an unexpected place.
Patch submitted here: https://reviews.llvm.org/D28168
Fix committed in r291462. The patch delays the fix-up operation for external induction variable users until after the dominator tree has been updated. But we should work towards keeping the dominator tree up-to-date throughout the transformation, rather than updating it at the end.