[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
Mon Oct 14 01:07:59 PDT 2024


david-arm wrote:

> It indeed might be simpler to start with this and later fold into the vector loop region, if needed (I think I did some small experiments a while ago, and the fused version in the loop latch was marginally faster for the config I tested)

I took a look at the other version, thanks for posting! I haven't tested this yet on a typical std::find loop, in particular the xalancbmk benchmark example, but I expect that for loops that take a long time to exit this is fine as the extra work of the compare and branch will be minimal. However, there are examples of loops that look for a mismatch (such as in xz or 7z):

```
  while (i++ != end)
    if (a[i] != b[i])
      break;
```

where the max number of iterations is small and the split middle block approach will be costly. We currently won't vectorise the mismatch loop in xz anyway because the LoopIdiomVectorize pass pre-empts LoopVectorize and should generate an efficient predicated vector loop. However, it's worth bearing in mind that early exit loops with low trip counts are also fairly common.

For what it's worth @fhahn I have a downstream version of https://github.com/llvm/llvm-project/pull/88385 working with the version posted here.

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


More information about the llvm-commits mailing list