diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
| commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
| tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
vendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp index df96f67288f1..379988733312 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp @@ -94,13 +94,15 @@ void PlainCFGBuilder::fixPhiNodes() { for (auto *Phi : PhisToFix) { assert(IRDef2VPValue.count(Phi) && "Missing VPInstruction for PHINode."); VPValue *VPVal = IRDef2VPValue[Phi]; - assert(isa<VPInstruction>(VPVal) && "Expected VPInstruction for phi node."); - auto *VPPhi = cast<VPInstruction>(VPVal); + assert(isa<VPWidenPHIRecipe>(VPVal) && + "Expected WidenPHIRecipe for phi node."); + auto *VPPhi = cast<VPWidenPHIRecipe>(VPVal); assert(VPPhi->getNumOperands() == 0 && "Expected VPInstruction with no operands."); - for (Value *Op : Phi->operands()) - VPPhi->addOperand(getOrCreateVPOperand(Op)); + for (unsigned I = 0; I != Phi->getNumOperands(); ++I) + VPPhi->addIncoming(getOrCreateVPOperand(Phi->getIncomingValue(I)), + BB2VPBB[Phi->getIncomingBlock(I)]); } } @@ -210,13 +212,13 @@ void PlainCFGBuilder::createVPInstructionsForVPBB(VPBasicBlock *VPBB, continue; } - VPInstruction *NewVPInst; + VPValue *NewVPV; if (auto *Phi = dyn_cast<PHINode>(Inst)) { // Phi node's operands may have not been visited at this point. We create // an empty VPInstruction that we will fix once the whole plain CFG has // been built. - NewVPInst = cast<VPInstruction>(VPIRBuilder.createNaryOp( - Inst->getOpcode(), {} /*No operands*/, Inst)); + NewVPV = new VPWidenPHIRecipe(Phi); + VPBB->appendRecipe(cast<VPWidenPHIRecipe>(NewVPV)); PhisToFix.push_back(Phi); } else { // Translate LLVM-IR operands into VPValue operands and set them in the @@ -227,11 +229,11 @@ void PlainCFGBuilder::createVPInstructionsForVPBB(VPBasicBlock *VPBB, // Build VPInstruction for any arbitraty Instruction without specific // representation in VPlan. - NewVPInst = cast<VPInstruction>( + NewVPV = cast<VPInstruction>( VPIRBuilder.createNaryOp(Inst->getOpcode(), VPOperands, Inst)); } - IRDef2VPValue[Inst] = NewVPInst; + IRDef2VPValue[Inst] = NewVPV; } } @@ -253,7 +255,13 @@ VPRegionBlock *PlainCFGBuilder::buildPlainCFG() { assert((PreheaderBB->getTerminator()->getNumSuccessors() == 1) && "Unexpected loop preheader"); VPBasicBlock *PreheaderVPBB = getOrCreateVPBB(PreheaderBB); - createVPInstructionsForVPBB(PreheaderVPBB, PreheaderBB); + for (auto &I : *PreheaderBB) { + if (I.getType()->isVoidTy()) + continue; + VPValue *VPV = new VPValue(&I); + Plan.addExternalDef(VPV); + IRDef2VPValue[&I] = VPV; + } // Create empty VPBB for Loop H so that we can link PH->H. VPBlockBase *HeaderVPBB = getOrCreateVPBB(TheLoop->getHeader()); // Preheader's predecessors will be set during the loop RPO traversal below. |
