[llvm] [VPlan] Introduce multi-branch recipe, use for multi-exit loops (WIP). (PR #109193)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 06:48:22 PDT 2024


david-arm wrote:

For what it's worth I already have a patch upstream that performs auto-vectorisation of early exit loops - https://github.com/llvm/llvm-project/pull/88385. It's out of date now because I've been trying to incrementally land bits of that patch and was waiting for a good chance to rebase. In that original patch I was also trying to hide some of the structure from VPlan, but I did it in a different way by keeping the early exiting VPBlock in VPlan and hiding the successor off to the side. This avoided requiring multiple successors from the VPRegionBlock. After discussion with and help from @huntergr-arm, I then came up with https://github.com/llvm/llvm-project/pull/108563 as an attempt to model the early exits more formerly in VPlan by mapping an early exiting VPBlock to a VPRegionBlock successor.

One of the problems I see with this patch is how to model VPLiveOuts correctly in a way that doesn't require a lot more special handling. With PR #88385, although not perfect and too huge in it's original form, I was hoping to move towards a model where we could reuse the existing VPLiveOut class and map incoming VPValues to incoming VPBlocks, which requires having individual exiting VPBlocks in the VPRegionBlock. The benefit of this approach was being able to reuse the existing plumbing to update PHI values correctly according to the block they exited from. I was even hoping to simplify `fixPhi` at some point so that we don't have to try so hard to figure out what the predecessor VPBlock is for normal exits.

I'm not sure what effect this patch has on plans for the cost model, since if I understand correctly we're moving towards a cost model based on the VPlan structure and its recipes?

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


More information about the llvm-commits mailing list