[llvm] [VPlan] Compute blend masks from minimum set of edge masks (PR #184838)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 02:28:32 PDT 2026
================
@@ -205,10 +210,81 @@ void VPPredicator::createSwitchEdgeMasks(const VPInstruction *SI) {
setEdgeMask(Src, DefaultDst, DefaultMask);
}
+DenseMap<const VPBasicBlock *, VPValue *>
+VPPredicator::computeBlendMasks(VPBasicBlock *VPBB) {
+ // First compute the set of ancestors which are reachable from multiple
+ // incoming blocks. This is where we can no longer determine the unique
+ // incoming edge.
+ SmallPtrSet<VPBlockBase *, 8> NonUnique;
+ DenseMap<VPBlockBase *, unsigned> Freq;
+ for (VPBlockBase *InVPBB : VPBB->predecessors()) {
+ for (VPBlockBase *VPBB : vp_inverse_depth_first_shallow(InVPBB)) {
+ Freq[VPBB]++;
+ if (Freq[VPBB] > 1)
+ NonUnique.insert(VPBB);
+ }
+ }
+
+ auto IsNonUnique = [&NonUnique](VPBlockBase *VPBB) {
----------------
fhahn wrote:
would be good to briefly document
https://github.com/llvm/llvm-project/pull/184838
More information about the llvm-commits
mailing list