This is an archive of the discontinued LLVM Phabricator instance.

[Matrix] Use alignment info when lowering loads/stores.
ClosedPublic

Authored by fhahn on Jun 16 2020, 12:36 PM.

Details

Summary

This patch updates LowerMatrixIntrinsics to preserve the alignment
specified at the original load/stores and the align attribute for the
pointer argument of the column.major.load/store intrinsics.

We can always use the specified alignment for the load of the first
column. For subsequent columns, the alignment may need to be reduced.

For ConstantInt strides, compute the offset for the start of the column in
bytes and use commonAlignment to get the largest valid alignment.

For non-ConstantInt strides, we need to take the common alignment of the
initial alignment and the element alignment.

Diff Detail

Event Timeline

fhahn created this revision.Jun 16 2020, 12:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2020, 12:36 PM

Otherwise LGTM

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
778

This fast path should be checked before getting ElementAlign or ElementSize.

784

This should be commonAlignment(InitialAlign, ElementSize / 8). If you have an array of 8-byte objects, and the start is 8-byte-aligned, all the elements are 8-byte-aligned regardless of the natural alignment of the type.

Also, the right default assumption should always be that the DataLayout's built-in concept of type alignment is bad and wrong. Once there's an explicit alignment given in the IR, there is no reason that the DataLayout alignment should ever play a role in the calculation.

fhahn updated this revision to Diff 271301.Jun 17 2020, 2:05 AM

Thanks John!

Moved up early exit, use ElementSizeInBits / 8 instead of abi alignment of element type.

fhahn marked 2 inline comments as done.Jun 17 2020, 2:06 AM
fhahn added inline comments.
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
784

Done, thanks!

Thanks, LGTM.

rjmccall accepted this revision.Jun 17 2020, 9:12 AM
This revision is now accepted and ready to land.Jun 17 2020, 9:12 AM
fhahn updated this revision to Diff 271666.Jun 18 2020, 4:59 AM

Rebased after landing parent changes. Will commit soon.

This revision was automatically updated to reflect the committed changes.