[llvm] [VPlan] Add initial CFG simplification, removing BranchOnCond true. (PR #106748)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 05:35:41 PDT 2024
================
@@ -1017,9 +1017,17 @@ void VPlan::execute(VPTransformState *State) {
"middle block has unexpected successors");
VPBasicBlock *ScalarPhVPBB = cast<VPBasicBlock>(
MiddleSuccs.size() == 1 ? MiddleSuccs[0] : MiddleSuccs[1]);
- assert(!isa<VPIRBasicBlock>(ScalarPhVPBB) &&
- "scalar preheader cannot be wrapped already");
- replaceVPBBWithIRVPBB(ScalarPhVPBB, ScalarPh);
+ if (!isa<VPIRBasicBlock>(ScalarPhVPBB)) {
+ replaceVPBBWithIRVPBB(ScalarPhVPBB, ScalarPh);
+ } else {
+ // There is no edge to the scalar pre-header in VPlan. Phis in ScalarPh have
+ // been created during skeleton construction, so remove the incoming values
+ // from the middle block here.
+ // TODO: Remove this once phis in the scalar preheader are managed in VPlan
+ // directly.
+ for (auto &Phi : ScalarPh->phis())
----------------
david-arm wrote:
Does this change somehow relate to the change in `simplifyCFG`? Perhaps I'm missing something, but they seem unrelated.
This seems to be relying upon the assumption that if ScalarPh is already a IRVPBB, then there is no path from the middle block to the scalar.ph block. I can't see that assumption tested or documented anywhere. Also, given that we've just extracted `ScalarPhVPBB` from a successor of `MiddleVPBB` it seems a little contradictory?
https://github.com/llvm/llvm-project/pull/106748
More information about the llvm-commits
mailing list