Index: lib/Transforms/Vectorize/LoadStoreVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -737,9 +737,18 @@ ArrayRef NewChain = getVectorizablePrefix(Chain); if (NewChain.empty()) { - // No vectorization possible. - InstructionsProcessed->insert(Chain.begin(), Chain.end()); - return false; + // No vectorization possible if the number of instructions + // is less than or equal to VF. + if (ChainSize <= VF) { + InstructionsProcessed->insert(Chain.begin(), Chain.end()); + return false; + } + // Split the chain and try each slice seperately in order + // to increase the number of vector instructions generated. + ArrayRef Left = Chain.slice(0, VF); + ArrayRef Right = Chain.slice(VF); + return vectorizeStoreChain(Left, InstructionsProcessed) | + vectorizeStoreChain(Right, InstructionsProcessed); } if (NewChain.size() == 1) { // Failed after the first instruction. Discard it and try the smaller chain. @@ -885,9 +894,18 @@ ArrayRef NewChain = getVectorizablePrefix(Chain); if (NewChain.empty()) { - // No vectorization possible. - InstructionsProcessed->insert(Chain.begin(), Chain.end()); - return false; + // No vectorization possible if the number of instructions + // is less than or equal to VF. + if (ChainSize <= VF) { + InstructionsProcessed->insert(Chain.begin(), Chain.end()); + return false; + } + // Split the chain and try each slice seperately in order + // to increase the number of vector instructions generated. + ArrayRef Left = Chain.slice(0, VF); + ArrayRef Right = Chain.slice(VF); + return vectorizeLoadChain(Left, InstructionsProcessed) | + vectorizeLoadChain(Right, InstructionsProcessed); } if (NewChain.size() == 1) { // Failed after the first instruction. Discard it and try the smaller chain.