Skip to content

[mlir][vector] Use llvm::Align when constructing vector load and stores. #152207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mlir/include/mlir/Dialect/Vector/IR/VectorOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ struct VectorDim {
int64_t dim;
bool isScalable;
};

struct AlignmentBytes {
uint64_t alignment = 0;
AlignmentBytes() = default;
explicit AlignmentBytes(uint64_t alignment) : alignment(alignment) {};
explicit operator bool() const { return alignment; }
uint64_t getAlignment() const { return alignment; }
};

BroadcastableToResult
isBroadcastableTo(Type srcType, VectorType dstVectorType,
std::pair<VectorDim, VectorDim> *mismatchingDims = nullptr);
Expand Down
12 changes: 6 additions & 6 deletions mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1729,18 +1729,18 @@ def Vector_LoadOp : Vector_Op<"load", [
"Value":$base,
"ValueRange":$indices,
CArg<"bool", "false">:$nontemporal,
CArg<"uint64_t", "0">:$alignment), [{
CArg<"AlignmentBytes", "AlignmentBytes()">: $alignment), [{
return build($_builder, $_state, resultType, base, indices, nontemporal,
alignment != 0 ? $_builder.getI64IntegerAttr(alignment) :
alignment ? $_builder.getI64IntegerAttr(alignment.getAlignment()) :
nullptr);
}]>,
OpBuilder<(ins "TypeRange":$resultTypes,
"Value":$base,
"ValueRange":$indices,
CArg<"bool", "false">:$nontemporal,
CArg<"uint64_t", "0">:$alignment), [{
CArg<"AlignmentBytes", "AlignmentBytes()">: $alignment), [{
return build($_builder, $_state, resultTypes, base, indices, nontemporal,
alignment != 0 ? $_builder.getI64IntegerAttr(alignment) :
alignment ? $_builder.getI64IntegerAttr(alignment.getAlignment()) :
nullptr);
}]>
];
Expand Down Expand Up @@ -1847,9 +1847,9 @@ def Vector_StoreOp : Vector_Op<"store", [
"Value":$base,
"ValueRange":$indices,
CArg<"bool", "false">:$nontemporal,
CArg<"uint64_t", "0">:$alignment), [{
CArg<"AlignmentBytes", "AlignmentBytes()">:$alignment), [{
return build($_builder, $_state, valueToStore, base, indices, nontemporal,
alignment != 0 ? $_builder.getI64IntegerAttr(alignment) :
alignment ? $_builder.getI64IntegerAttr(alignment.getAlignment()) :
nullptr);
}]>
];
Expand Down