Skip to content

Commit d1f849a

Browse files
committed
[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.
1 parent 6d614a8 commit d1f849a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7130,6 +7130,13 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(unsigned MinVF,
71307130
SmallPtrSet<Instruction *, 4> DeadInstructions;
71317131
collectTriviallyDeadInstructions(DeadInstructions);
71327132

7133+
// Add assume instructions we need to drop to DeadInstructions, to prevent
7134+
// them from being added to the VPlan.
7135+
// TODO: We only need to drop assumes in blocks that get flattend. If the
7136+
// control flow is preserved, we should keep them.
7137+
auto &ConditionalAssumes = Legal->getConditionalAssumes();
7138+
DeadInstructions.insert(ConditionalAssumes.begin(), ConditionalAssumes.end());
7139+
71337140
DenseMap<Instruction *, Instruction *> &SinkAfter = Legal->getSinkAfter();
71347141
// Dead instructions do not need sinking. Remove them from SinkAfter.
71357142
for (Instruction *I : DeadInstructions)
@@ -7192,13 +7199,6 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
71927199
// visit each basic block after having visited its predecessor basic blocks.
71937200
// ---------------------------------------------------------------------------
71947201

7195-
// Add assume instructions we need to drop to DeadInstructions, to prevent
7196-
// them from being added to the VPlan.
7197-
// TODO: We only need to drop assumes in blocks that get flattend. If the
7198-
// control flow is preserved, we should keep them.
7199-
auto &ConditionalAssumes = Legal->getConditionalAssumes();
7200-
DeadInstructions.insert(ConditionalAssumes.begin(), ConditionalAssumes.end());
7201-
72027202
// Create a dummy pre-entry VPBasicBlock to start building the VPlan.
72037203
VPBasicBlock *VPBB = new VPBasicBlock("Pre-Entry");
72047204
auto Plan = std::make_unique<VPlan>(VPBB);

0 commit comments

Comments
 (0)