From 3f36b9b456ac4bfa695e253926daa87cd9838550 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 6 Apr 2023 21:16:37 +0100 Subject: [PATCH] [LV] Move conditional MaskForGaps construction to load case. Conditionally setting MaskForGaps is only needed for loads. This avoid re-computing MaskForGaps for stores. Suggested as independent cleanup in D147467. --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index e686508..d5b22f9 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2668,14 +2668,15 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup( State.setDebugLocFromInst(Instr); Value *PoisonVec = PoisonValue::get(VecTy); - Value *MaskForGaps = nullptr; - if (Group->requiresScalarEpilogue() && !Cost->isScalarEpilogueAllowed()) { - MaskForGaps = createBitMaskForGaps(Builder, VF.getKnownMinValue(), *Group); - assert(MaskForGaps && "Mask for Gaps is required but it is null"); - } - // Vectorize the interleaved load group. if (isa(Instr)) { + Value *MaskForGaps = nullptr; + if (Group->requiresScalarEpilogue() && !Cost->isScalarEpilogueAllowed()) { + MaskForGaps = + createBitMaskForGaps(Builder, VF.getKnownMinValue(), *Group); + assert(MaskForGaps && "Mask for Gaps is required but it is null"); + } + // For each unroll part, create a wide load for the group. SmallVector NewLoads; for (unsigned Part = 0; Part < UF; Part++) { @@ -2743,7 +2744,8 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup( auto *SubVT = VectorType::get(ScalarTy, VF); // Vectorize the interleaved store group. - MaskForGaps = createBitMaskForGaps(Builder, VF.getKnownMinValue(), *Group); + Value *MaskForGaps = + createBitMaskForGaps(Builder, VF.getKnownMinValue(), *Group); assert((!MaskForGaps || useMaskedInterleavedAccesses(*TTI)) && "masked interleaved groups are not allowed."); assert((!MaskForGaps || !VF.isScalable()) && -- 2.7.4