LoopVectorize: LoopSimplify can't canonicalize loops with an indirectbr in it, don...
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 24 May 2013 18:05:35 +0000 (18:05 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 24 May 2013 18:05:35 +0000 (18:05 +0000)
Fixes PR16139.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182656 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/lcssa-crash.ll

index f88ebfd015a9bcad774ba14cf82811bfeafa6f17..f6c4dea04c11d164ef6d1b3716ee89a1683c9b61 100644 (file)
@@ -2428,7 +2428,10 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() {
 }
 
 bool LoopVectorizationLegality::canVectorize() {
-  assert(TheLoop->getLoopPreheader() && "No preheader!!");
+  // We must have a loop in canonical form. Loops with indirectbr in them cannot
+  // be canonicalized.
+  if (!TheLoop->getLoopPreheader())
+    return false;
 
   // We can only vectorize innermost loops.
   if (TheLoop->getSubLoopsVector().size())
index 06b3b08aa0e3e7290487143ab0d79d88f022e197..de6be548490c5d57f6daa779862a7e37fb44d53e 100644 (file)
@@ -27,3 +27,14 @@ for.end.i.i.i:
   unreachable
 }
 
+; PR16139
+define void @test2(i8* %x) {
+entry:
+  indirectbr i8* %x, [ label %L0, label %L1 ]
+
+L0:
+  br label %L0
+
+L1:
+  ret void
+}