@@ -949,47 +949,20 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
949
949
}
950
950
}
951
951
952
- // / Replace \p VPBB with a VPIRBasicBlock wrapping \p IRBB. All recipes from \p
953
- // / VPBB are moved to the end of the newly created VPIRBasicBlock. VPBB must
954
- // / have a single predecessor, which is rewired to the new VPIRBasicBlock. All
955
- // / successors of VPBB, if any, are rewired to the new VPIRBasicBlock.
956
- static void replaceVPBBWithIRVPBB (VPBasicBlock *VPBB, BasicBlock *IRBB) {
957
- VPIRBasicBlock *IRVPBB = VPBB->getPlan ()->createVPIRBasicBlock (IRBB);
958
- for (auto &R : make_early_inc_range (*VPBB)) {
959
- assert (!R.isPhi () && " Tried to move phi recipe to end of block" );
960
- R.moveBefore (*IRVPBB, IRVPBB->end ());
961
- }
962
-
963
- VPBlockUtils::reassociateBlocks (VPBB, IRVPBB);
964
- // VPBB is now dead and will be cleaned up when the plan gets destroyed.
965
- }
966
-
967
952
// / Generate the code inside the preheader and body of the vectorized loop.
968
953
// / Assumes a single pre-header basic-block was created for this. Introduce
969
954
// / additional basic-blocks as needed, and fill them all.
970
955
void VPlan::execute (VPTransformState *State) {
971
956
// Initialize CFG state.
972
957
State->CFG .PrevVPBB = nullptr ;
973
958
State->CFG .ExitBB = State->CFG .PrevBB ->getSingleSuccessor ();
974
- BasicBlock *VectorPreHeader = State->CFG .PrevBB ;
975
- State->Builder .SetInsertPoint (VectorPreHeader->getTerminator ());
976
959
977
960
// Disconnect VectorPreHeader from ExitBB in both the CFG and DT.
961
+ BasicBlock *VectorPreHeader = State->CFG .PrevBB ;
978
962
cast<BranchInst>(VectorPreHeader->getTerminator ())->setSuccessor (0 , nullptr );
979
963
State->CFG .DTU .applyUpdates (
980
964
{{DominatorTree::Delete, VectorPreHeader, State->CFG .ExitBB }});
981
965
982
- // Replace regular VPBB's for the vector preheader, middle and scalar
983
- // preheader blocks with VPIRBasicBlocks wrapping their IR blocks. The IR
984
- // blocks are created during skeleton creation, so we can only create the
985
- // VPIRBasicBlocks now during VPlan execution rather than earlier during VPlan
986
- // construction.
987
- BasicBlock *MiddleBB = State->CFG .ExitBB ;
988
- BasicBlock *ScalarPh = MiddleBB->getSingleSuccessor ();
989
- replaceVPBBWithIRVPBB (getVectorPreheader (), VectorPreHeader);
990
- replaceVPBBWithIRVPBB (getMiddleBlock (), MiddleBB);
991
- replaceVPBBWithIRVPBB (getScalarPreheader (), ScalarPh);
992
-
993
966
LLVM_DEBUG (dbgs () << " Executing best plan with VF=" << State->VF
994
967
<< " , UF=" << getUF () << ' \n ' );
995
968
setName (" Final VPlan" );
@@ -998,6 +971,8 @@ void VPlan::execute(VPTransformState *State) {
998
971
// Disconnect the middle block from its single successor (the scalar loop
999
972
// header) in both the CFG and DT. The branch will be recreated during VPlan
1000
973
// execution.
974
+ BasicBlock *MiddleBB = State->CFG .ExitBB ;
975
+ BasicBlock *ScalarPh = MiddleBB->getSingleSuccessor ();
1001
976
auto *BrInst = new UnreachableInst (MiddleBB->getContext ());
1002
977
BrInst->insertBefore (MiddleBB->getTerminator ());
1003
978
MiddleBB->getTerminator ()->eraseFromParent ();
0 commit comments