================ @@ -7842,6 +7853,61 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) { VPValue *SrcMask = getBlockInMask(Src); + if (auto *SI = dyn_cast<SwitchInst>(Src->getTerminator())) { + assert(!OrigLoop->isLoopExiting(Src) && + all_of(successors(Src), + [this](BasicBlock *Succ) { + return OrigLoop->getHeader() != Succ; + }) && + "unsupported switch either exiting loop or continuing to header"); + // Create masks where the terminator in Src is a switch. We create mask for + // all edges at the same time. This is more efficient, as we can create and + // collect compares for all cases once. + VPValue *Cond = getVPValueOrAddLiveIn(SI->getCondition(), Plan); + BasicBlock *DefaultDst = SI->getDefaultDest(); + MapVector<BasicBlock *, SmallVector<VPValue *>> Map; + for (auto &C : SI->cases()) { + auto I = Map.insert({C.getCaseSuccessor(), {}}); ---------------- ayalz wrote:
```suggestion // Cases whose destination is the same as default are redundant and can be ignored - they will get there anyhow. if (C.getCaseSuccessor() == DefaultDst) continue; auto I = Map.insert({C.getCaseSuccessor(), {}}); ``` https://github.com/llvm/llvm-project/pull/99808 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits