Skip to content

Commit c8c323b

Browse files
committed
!fixup address latest comments, thanks!
1 parent 379ce90 commit c8c323b

File tree

5 files changed

+519
-19
lines changed

5 files changed

+519
-19
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6462,7 +6462,7 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
64626462
Instruction::ICmp,
64636463
ToVectorTy(Switch->getCondition()->getType(), VF),
64646464
ToVectorTy(Type::getInt1Ty(I->getContext()), VF),
6465-
CmpInst::BAD_ICMP_PREDICATE, CostKind);
6465+
CmpInst::ICMP_EQ, CostKind);
64666466
}
64676467
case Instruction::PHI: {
64686468
auto *Phi = cast<PHINode>(I);
@@ -7867,11 +7867,13 @@ void VPRecipeBuilder::createSwitchEdgeMasks(SwitchInst *SI) {
78677867
BasicBlock *DefaultDst = SI->getDefaultDest();
78687868
MapVector<BasicBlock *, SmallVector<VPValue *>> Dst2Compares;
78697869
for (auto &C : SI->cases()) {
7870+
BasicBlock *Dst = C.getCaseSuccessor();
7871+
assert(!EdgeMaskCache.contains({Src, Dst}) && "Edge masks already created");
78707872
// Cases whose destination is the same as default are redundant and can be
78717873
// ignored - they will get there anyhow.
7872-
if (C.getCaseSuccessor() == DefaultDst)
7874+
if (Dst == DefaultDst)
78737875
continue;
7874-
auto I = Dst2Compares.insert({C.getCaseSuccessor(), {}});
7876+
auto I = Dst2Compares.insert({Dst, {}});
78757877
VPValue *V = getVPValueOrAddLiveIn(C.getCaseValue(), Plan);
78767878
I.first->second.push_back(Builder.createICmp(CmpInst::ICMP_EQ, Cond, V));
78777879
}

llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ class VPRecipeBuilder {
134134
/// Returns the *entry* mask for the block \p BB.
135135
VPValue *getBlockInMask(BasicBlock *BB) const;
136136

137-
/// Create masks for all cases with destination different than the default
138-
/// destination, and a mask for the default destination.
137+
/// Create an edge mask for every destination of cases and/or default.
139138
void createSwitchEdgeMasks(SwitchInst *SI);
140139

141140
/// A helper function that computes the predicate of the edge between SRC

0 commit comments

Comments
 (0)