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

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 07:50:06 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:

Updated, but should base on https://github.com/llvm/llvm-project/pull/184359.
BTW, the fix is different from what I originally had in mind. My initial idea was that for (X && Y) && Z, as long as Z is loop-invariant and X is not, we could try rewriting it as (Y && Z) && X, where X is not restricted to being the header mask. This would allow us to hoist Y && Z to the preheader if Y is also loop-invariant.

But, I haven’t yet verified whether this transformation introduces any differences.

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


More information about the llvm-commits mailing list