diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -270,10 +270,17 @@ return Callback.getOrCreateVectorValues(VPValue2Value[Def], Part); } - /// Get the generated Value for a given VPValue and given Part and Lane. Note - /// that as per-lane Defs are still created by ILV and managed in its ValueMap - /// this method currently just delegates the call to ILV. + /// Get the generated Value for a given VPValue and given Part and Lane. Value *get(VPValue *Def, const VPIteration &Instance) { + // If values have been set for this Def, extract the lane from the relevant + // part. + // TODO: Cache created scalar values. + if (Data.PerPartOutput.count(Def)) { + auto *VecPart = Data.PerPartOutput[Def][Instance.Part]; + return Builder.CreateExtractElement(VecPart, + Builder.getInt32(Instance.Lane)); + } + return Callback.getOrCreateScalarValue(VPValue2Value[Def], Instance); }