aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-13 20:39:49 +0000
commitfe6060f10f634930ff71b7c50291ddc610da2475 (patch)
tree1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
parentb61bce17f346d79cecfd8f195a64b10f77be43b1 (diff)
parent344a3780b2e33f6ca763666c380202b18aab72a3 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
index df96f67288f1..379988733312 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
+++ b/contrib/llvm-project/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.