memref.assume_alignment annotates the alignment of the source buffer
not the base pointer.
Put differently, prior to this patch memref.assume_alignment would lower
to llvm.assume %buffer.base.isAligned(X) whereas what we want is
llvm.assume (%buffer.base + %buffer.offset).isAligned(X).
In other words, we were missing to include the offset in the expression
checked by the llvm.assume.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp | ||
---|---|---|
372 | I was talking with @mravishankar offline and he pointed out that if we are aligned at (alignPtr + offset) then alignPtr must be aligned at least with the same alignment.
It sounded like useful information to lower. What do you guys think? |
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp | ||
---|---|---|
372 | To clarify this a bit. If you need an basePtr + offset to be aligned to a value v, you need both basePtr and offset to be aligned to v. Without that you cannot guarantee that basePtr + offset is always aligned to v for all values of basePtr. |
Looks good to me. It is strange that `memref.assume_alignment %0, 16 : memref<4x4xf16, strided<[?, ?], offset: ?>>` refers to the pointer after offset, and not the base. But I understand the reasoning here.
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp | ||
---|---|---|
372 | Thinking about it a little more, I think it is better to let the producers of memref.assume_alignment to separately generate one for the base pointer if they want. |
I was talking with @mravishankar offline and he pointed out that if we are aligned at (alignPtr + offset) then alignPtr must be aligned at least with the same alignment.
I.e., we could issue two assumes here:
It sounded like useful information to lower.
What do you guys think?