[llvm] [LoadStoreVectorizer] Propagate alignment through contiguous chain (PR #145733)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 22 09:18:39 PDT 2025
================
@@ -21,6 +21,43 @@
using namespace llvm;
+static bool tryToPropagateAlign(Function &F, const DataLayout &DL) {
+ bool Changed = false;
+
+ for (BasicBlock &BB : F) {
+ // We need to reset the map for each block because alignment information
+ // can't be propagated across blocks. This is because control flow could
+ // be dependent on the address at runtime, making an alignment assumption
+ // within one block not true in another. Some sort of dominator tree
+ // approach could be better, but restricting within a basic block is correct
+ // too.
+ DenseMap<Value *, Align> BestBasePointerAligns;
+ for (Instruction &I : BB) {
+ if (auto *PtrOp = getLoadStorePointerOperand(&I)) {
+ Align LoadStoreAlign = getLoadStoreAlignment(&I);
+ APInt OffsetFromBase = APInt(
+ DL.getIndexSizeInBits(PtrOp->getType()->getPointerAddressSpace()),
----------------
nikic wrote:
```suggestion
DL.getIndexTypeSizeInBits(PtrOp->getType()),
```
https://github.com/llvm/llvm-project/pull/145733
More information about the llvm-commits
mailing list