Skip to content

Commit 9a4e938

Browse files
committed
Pass alignment from vector.compressstore to llvm.compressstore
1 parent 455ffb6 commit 9a4e938

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,13 @@ class VectorCompressStoreOpConversion
421421
Value ptr = getStridedElementPtr(rewriter, loc, memRefType,
422422
adaptor.getBase(), adaptor.getIndices());
423423

424+
// From:
425+
// https://llvm.org/docs/LangRef.html#llvm-masked-compressstore-intrinsics
426+
// The pointer alignment defaults to 1.
427+
uint64_t alignment = compress.getAlignment().value_or(1);
428+
424429
rewriter.replaceOpWithNewOp<LLVM::masked_compressstore>(
425-
compress, adaptor.getValueToStore(), ptr, adaptor.getMask());
430+
compress, adaptor.getValueToStore(), ptr, adaptor.getMask(), alignment);
426431
return success();
427432
}
428433
};

mlir/test/Conversion/VectorToLLVM/vector-to-llvm-interface.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,15 @@ func.func @compress_store_op_index(%arg0: memref<?xindex>, %arg1: vector<11xi1>,
21772177

21782178
// -----
21792179

2180+
func.func @compress_store_op_with_alignment(%arg0: memref<?xindex>, %arg1: vector<11xi1>, %arg2: vector<11xindex>, %c0: index) {
2181+
vector.compressstore %arg0[%c0], %arg1, %arg2 { alignment = 8 } : memref<?xindex>, vector<11xi1>, vector<11xindex>
2182+
return
2183+
}
2184+
// CHECK-LABEL: func @compress_store_op_with_alignment
2185+
// CHECK: "llvm.intr.masked.compressstore"(%{{.*}}, %{{.*}}, %{{.*}}) <{arg_attrs = [{}, {llvm.align = 8 : i64}, {}]}> : (vector<11xi64>, !llvm.ptr, vector<11xi1>) -> ()
2186+
2187+
// -----
2188+
21802189
//===----------------------------------------------------------------------===//
21812190
// vector.splat
21822191
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)