[llvm] [VPlan] Insert VPBlendRecipes in post order. NFC (PR #201782)

Andrei Elovikov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 09:26:33 PDT 2026


eas wrote:

> > I guess this is fine for now, so I definitely wouldn't want to block it, but I have a feeling RPOT would be better if we ever try to preserve some "uniform" branches as that would require placing SSA-phis sometimes.
> 
> Do you mean as in for partial control flow linearisation? I don't think we need to insert new phis, only adjust existing ones by replacing the incoming values with blends where control flow was linearized. Is there any reason why post order wouldn't work for that?

```
        BB0
       Uni = ...; (so that branching wouldn't be UB even if BB1.Div == all-true)
         |
      BB1 (Div)
        /  \    
     BB2 BB3 (Uni)
       |   |       \
       | Expensive1 Expensive 2
       \     |      /
       MergeBB (phi)
```

Into

```
  BB0
  BB1
  BB3
  / \
 E1 E2 (both are sill masked with !BB1.Div)
   \ /
   NewBB (new SSA phi)
   |
  BB2
   |
  MergeBB (blend)
```

One could argue that we can go BB1->BB2->BB3, but it's dictated by the RPOT and you can simply mirror image the CFG to still have the linearization order where BB2 is processed last.

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


More information about the llvm-commits mailing list