This is an archive of the discontinued LLVM Phabricator instance.

Restrict vector.type_cast to only cast to aligned multi-dim vectors
Needs ReviewPublic

Authored by Origami404 on Jan 21 2023, 3:18 AM.

Details

Summary

Apply vector.type_cast to multi-dim memref<a... x b x T> where T is a
scalar type and b is not a power of 2 can produce MLIR vectors that will
be translated to a non-aligned aggregated LLVM vectors in memory. This
can cause confusing behaviors when accessing the element of the vector.

This commit adds checking for such cases and forbid them.

Link: https://discourse.llvm.org/t/restrict-vector-type-cast-to-only-cast-to-alignable-multi-dim-vectors/67811

Diff Detail

Event Timeline

Origami404 created this revision.Jan 21 2023, 3:18 AM
Herald added a project: Restricted Project. · View Herald Transcript
Origami404 published this revision for review.Jan 21 2023, 3:38 AM
ftynse added a subscriber: ftynse.Jan 23 2023, 4:03 AM

I'd avoid using "alignable" in the documentation, this is an obscure concept that wouldn't be properly defined in MLIR. One could argue, e.g., that any bitsize divisible by 256 is alignable on a machine with 256-bit vectors. Just say explicitly that the innermost size must be a power of 2.

Adjust doc and diag