[llvm] [LAA] Use computeConstantDifference() (PR #103725)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 09:29:40 PDT 2024


preames wrote:

Off topic, but I'm wondering if we should revisit this interface.  The notion of a constant difference (i.e. getPointersDiff) is restrictive, particularly once we get into any type of revec situation with scalable vectors.  (As we're not doing this today, this is mostly a long term concern.)

The two uses I can find of this interface in LAA are in sortPtrAccesses, and isConsecutiveAccess.  

For the later, I'd expect one stride to A and then doing a equality comparison would be much faster (when we fallback to SCEV), and likely more general (since stride doesn't have to be constant).  For non-constant type sizes, there's also a missing optimization for when B = gep i8, A, sizeof(element).

For the former, another way to frame this (in SCEV) would be to find the underlying base pointer (which must be the same for the difference to be defined), and then compute each offset against that.

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


More information about the llvm-commits mailing list