diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -9569,9 +9569,10 @@ return; } - // A store of a loop varying value to a loop invariant address only - // needs only the last copy of the store. - if (isa(UI) && getOperand(1)->isLiveIn()) { + // A store of a loop varying value to a uniform address only needs the last + // copy of the store. + if (isa(UI) && + vputils::isUniformAfterVectorization(getOperand(1))) { auto Lane = VPLane::getLastLaneForVF(State.VF); State.ILV->scalarizeInstruction(UI, this, VPIteration(State.UF - 1, Lane), State);