[llvm] Adding the support for vectorization of loops with load based tripcount (PR #209390)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 01:17:02 PDT 2026


david-arm wrote:

It's worth noting that I think an alternative implementation was already proposed on 30th April 2026 prior to this PR: see https://github.com/llvm/llvm-project/pull/195027. If these really are different approaches to the same problem, it would be good if you and @pawan-nirpal-031 could work together on this?

Also, I haven't looked in detail at this PR yet I'm afraid, but in general I think a far more powerful approach would be to hoist and version the scalar loop much earlier on rather than waiting until the loop vectoriser. There are many reasons why this would be beneficial, but an obvious one is something like this:

```
  for (int i = 0; i < *Count; i++) {
    dst[i] = src[i];
  }
```

where *Count, dst[i] and src[i] are all of the same `int` type and therefore alias. This type of loop would normally be recognised as a `memcpy` idiom, but the load of `Count` in each iteration of the loop probably prevents that. Similarly for idioms like `memmove`, etc. In the above example the best optimisation is almost certainly the loop idiom recognition, rather than loop vectoriser.

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


More information about the llvm-commits mailing list