[llvm] [LoadStoreVectorizer] Propagate alignment through contiguous chain (PR #145733)

Drew Kersnar via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 08:52:31 PDT 2025


================
@@ -0,0 +1,450 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes=load-store-vectorizer -S < %s | FileCheck %s
+
+; The IR has the first float3 labeled with align 16, and that 16 should
+; be propagated such that the second set of 4 values
+; can also be vectorized together.
----------------
dakersnar wrote:

> I don't think this needs to be expensive? I'd expect the implementation in InferAlignments would basically look like this: Walk the block and for all accesses on constant offset GEPs remember the largest implied alignment for the base (without offset) and use that to increase alignment on future accesses with the same base.

This is interesting. I can explore this idea to see how feasible it is. I think if we wanted something that could perform as well as this LSV optimization, it need to call getUnderlyingObject and getConstantOffset for each load/store. I can look into the time complexity of that, but my hunch is it would still end up O(n^2).

The problem is that I think if we want to avoid those expensive calls and limit the analysis to "shallow" geps that offset directly off of aligned base pointers, we will miss a lot of cases. There are transformations like StraightLineStrengthReduce that build chains of geps that increase the instruction depth needed to find the underlying object.

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


More information about the llvm-commits mailing list