[llvm] [VPlan] Fold common edges away in convertPhisToBlends (PR #150368)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 10:02:09 PDT 2025


================
@@ -226,6 +232,19 @@ void VPPredicator::createSwitchEdgeMasks(VPInstruction *SI) {
   setEdgeMask(Src, DefaultDst, DefaultMask);
 }
 
+VPValue *VPPredicator::findCommonEdgeMask(const VPPhi *PhiR) const {
+  VPValue *EdgeMask = getEdgeMask(PhiR->getIncomingBlock(0), PhiR->getParent());
+  VPValue *CommonEdgeMask;
+  if (!EdgeMask ||
+      !match(EdgeMask, m_LogicalAnd(m_VPValue(CommonEdgeMask), m_VPValue())))
+    return nullptr;
+  for (const VPBasicBlock *InVPBB : drop_begin(PhiR->incoming_blocks()))
+    if (!match(getEdgeMask(InVPBB, PhiR->getParent()),
----------------
lukel97 wrote:

There used to be an assertion that either all the edge masks had to be null or none of them were, but it was removed in a previous refactoring here: https://github.com/llvm/llvm-project/pull/138472#discussion_r2258733919

I think we can add back the assertion here, I'll add it to this PR

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


More information about the llvm-commits mailing list