[llvm] [VPlan] Simplify VPPhi with all-equal incoming (PR #157414)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 03:17:37 PDT 2025


artagnon wrote:

> It looks like there is a new crash with the change the reproducer from https://llvm.godbolt.org/z/rsavGTGhK crashes

Thanks for finding this crash! I think this patch is unworkable until the epilogue is fully modeled in VPlan. We do some out-of-band fixing up of scalar resume values, and this relies on the scalar phi being present:

```cpp
  // Fix induction resume values from the additional bypass block.
  IRBuilder<> BypassBuilder(BypassBlock, BypassBlock->getFirstInsertionPt());
  for (const auto &[IVPhi, II] : LVL.getInductionVars()) {
    auto *Inc = cast<PHINode>(IVPhi->getIncomingValueForBlock(PH));
    //                  ^~~~~~~~~~~
    //
    Value *V = createInductionAdditionalBypassValues(
        IVPhi, II, BypassBuilder, ExpandedSCEVs, MainVectorTripCount,
        LVL.getPrimaryInduction());
    // TODO: Directly add as extra operand to the VPResumePHI recipe.
    Inc->setIncomingValueForBlock(BypassBlock, V);
  }
```

We could create a fresh PHINode, but I think we'd be piling up one hack on top of another.

https://github.com/llvm/llvm-project/pull/157414


More information about the llvm-commits mailing list