From d1f849a284d9d180c23b9455aa3c68a3b462b1f0 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 28 Jan 2020 08:46:27 -0800 Subject: [PATCH] [LV] Hoist code to mark conditional assumes as dead to caller (NFC). This is a follow-up suggested in D73423. It is sufficient to just add the conditional assumes to DeadInstructions once. --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 707979f6b..e1446ce 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7130,6 +7130,13 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(unsigned MinVF, SmallPtrSet DeadInstructions; collectTriviallyDeadInstructions(DeadInstructions); + // Add assume instructions we need to drop to DeadInstructions, to prevent + // them from being added to the VPlan. + // TODO: We only need to drop assumes in blocks that get flattend. If the + // control flow is preserved, we should keep them. + auto &ConditionalAssumes = Legal->getConditionalAssumes(); + DeadInstructions.insert(ConditionalAssumes.begin(), ConditionalAssumes.end()); + DenseMap &SinkAfter = Legal->getSinkAfter(); // Dead instructions do not need sinking. Remove them from SinkAfter. for (Instruction *I : DeadInstructions) @@ -7192,13 +7199,6 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes( // visit each basic block after having visited its predecessor basic blocks. // --------------------------------------------------------------------------- - // Add assume instructions we need to drop to DeadInstructions, to prevent - // them from being added to the VPlan. - // TODO: We only need to drop assumes in blocks that get flattend. If the - // control flow is preserved, we should keep them. - auto &ConditionalAssumes = Legal->getConditionalAssumes(); - DeadInstructions.insert(ConditionalAssumes.begin(), ConditionalAssumes.end()); - // Create a dummy pre-entry VPBasicBlock to start building the VPlan. VPBasicBlock *VPBB = new VPBasicBlock("Pre-Entry"); auto Plan = std::make_unique(VPBB); -- 2.7.4