From b49d7abb7b289b73af0485c50c642216a5509eaa Mon Sep 17 00:00:00 2001 From: Erik Eckstein Date: Fri, 22 Aug 2014 01:18:39 +0000 Subject: fix: SLPVectorizer crashes for unreachable blocks containing not schedulable instructions. In unreachable blocks it's legal to have instructions like "%x = op %x". Such instuctions are not schedulable. Therefore the SLPVectorizer has to check for unreachable blocks and ignore them. Fixes bug 20646. llvm-svn: 216256 --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp') diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 9fea4450a10..3aced0b4c40 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -976,6 +976,14 @@ void BoUpSLP::buildTree_rec(ArrayRef VL, unsigned Depth) { Instruction *VL0 = cast(VL[0]); BasicBlock *BB = cast(VL0)->getParent(); + if (!DT->isReachableFromEntry(BB)) { + // Don't go into unreachable blocks. They may contain instructions with + // dependency cycles which confuse the final scheduling. + DEBUG(dbgs() << "SLP: bundle in unreachable block.\n"); + newTreeEntry(VL, false); + return; + } + // Check that every instructions appears once in this bundle. for (unsigned i = 0, e = VL.size(); i < e; ++i) for (unsigned j = i+1; j < e; ++j) -- cgit v1.2.3