Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -4673,6 +4673,11 @@ !isAccessInterleaved(&I) && !isLegalGatherOrScatter(&I)) continue; + // If the loaded value is truncated, consider the truncated type. + if (isa(&I) && I.hasOneUse() && + (isa(*I.user_begin()) || isa(*I.user_begin()))) + T = (*I.user_begin())->getType(); + MinWidth = std::min(MinWidth, (unsigned)DL.getTypeSizeInBits(T->getScalarType())); MaxWidth = std::max(MaxWidth,