[llvm] [VPlan] Simplify the computation of the block entry mask. (PR #173265)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 07:28:04 PST 2026


================
@@ -128,16 +138,22 @@ VPValue *VPPredicator::createEdgeMask(VPBasicBlock *Src, VPBasicBlock *Dst) {
   return setEdgeMask(Src, Dst, EdgeMask);
 }
 
-VPValue *VPPredicator::createBlockInMask(VPBasicBlock *VPBB) {
+void VPPredicator::createIncomingEdgeMasks(VPBasicBlock *VPBB) {
   // Start inserting after the block's phis, which be replaced by blends later.
   Builder.setInsertPoint(VPBB, VPBB->getFirstNonPhi());
+  for (auto *Predecessor : SetVector<VPBlockBase *>(
----------------
Mel-Chen wrote:

Unfortunately, this leads to some regressions. 80c3a951ccd04760ad4ccbcbff5d11bed28e4294
This is caused by the following logic in simplifyRecipe:
```
if (match(Def, m_LogicalAnd(m_LogicalAnd(m_VPValue(X), m_VPValue(Y)),
                           m_VPValue(Z))) &&
    X->hasMoreThanOneUniqueUser())
  return Def->replaceAllUsesWith(
      Builder.createLogicalAnd(X, Builder.createLogicalAnd(Y, Z)));
```
Since this reduces the number of users of X, the condition `X->hasMoreThanOneUniqueUser()` becomes problematic. One possible direction might be to allow this transformation whenever X is loop invariant.

In any case, this requires another patch to fix.

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


More information about the llvm-commits mailing list