Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1741,6 +1741,13 @@ continue; } + // Update LiveValues. + LiveValues.erase(PrevInst); + for (auto &J : PrevInst->operands()) { + if (isa(&*J) && ScalarToTreeEntry.count(&*J)) + LiveValues.insert(cast(&*J)); + } + DEBUG( dbgs() << "SLP: #LV: " << LiveValues.size(); for (auto *X : LiveValues) @@ -1749,13 +1756,6 @@ Inst->dump(); ); - // Update LiveValues. - LiveValues.erase(PrevInst); - for (auto &J : PrevInst->operands()) { - if (isa(&*J) && ScalarToTreeEntry.count(&*J)) - LiveValues.insert(cast(&*J)); - } - // Now find the sequence of instructions between PrevInst and Inst. BasicBlock::reverse_iterator InstIt(Inst->getIterator()), PrevInstIt(PrevInst->getIterator());