[clang] [mlir] [mlir][llvm] Fix metadata and alignment on masked memory intrinsics (PR #221879)
Tobias Gysi via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 06:30:46 PDT 2026
================
@@ -1363,112 +1378,215 @@ def LLVM_GetActiveLaneMaskOp
}
/// Create a call to Masked Load intrinsic.
-def LLVM_MaskedLoadOp : LLVM_OneResultIntrOp<"masked.load"> {
- let arguments = (ins LLVM_AnyPointer:$data, LLVM_VectorOf<I1>:$mask,
- Optional<LLVM_AnyVector>:$pass_thru, I32Attr:$alignment,
- UnitAttr:$nontemporal);
+def LLVM_MaskedLoadOp
+ : LLVM_OneResultIntrOp<"masked.load", /*overloadedResults=*/[],
+ /*overloadedOperands=*/[], /*traits=*/[],
+ /*requiresAccessGroup=*/1, /*requiresAliasAnalysis=*/1> {
+ dag args = (ins LLVM_AnyPointer:$data, LLVM_VectorOf<I1>:$mask,
+ Optional<LLVM_AnyVector>:$pass_thru,
+ OptionalAttr<I64Attr>:$alignment, UnitAttr:$nontemporal);
+ let arguments = !con(args, baseArgs);
let results = (outs LLVM_AnyVector:$res);
+ let builders = [
+ OpBuilder<(ins "Type":$res, "Value":$data, "Value":$mask,
+ "Value":$pass_thru, "uint64_t":$alignment,
+ CArg<"bool", "false">:$nontemporal), [{
+ build($_builder, $_state, res, data, mask, pass_thru,
+ $_builder.getI64IntegerAttr(alignment),
+ nontemporal ? $_builder.getUnitAttr() : nullptr,
+ /*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
+ /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
+ }]>
+ ];
let assemblyFormat =
"operands attr-dict `:` functional-type(operands, results)";
string llvmBuilder = [{
+ // An absent alignment attribute means the ABI alignment of the type, which
+ // LLVM spells as an absent align parameter attribute. The IRBuilder helper
+ // always attaches one, so remove it again in that case.
+ llvm::Align alignment =
----------------
gysit wrote:
Right, there is a more generic builder but it requires much more code to set that one up. So this turned out to be the more "elegant" solution.
https://github.com/llvm/llvm-project/pull/221879
More information about the cfe-commits
mailing list