Skip to content

Commit 43af00d

Browse files
committed
Pass alignment from vector.expandload to llvm.intr.masked.expandload
1 parent f8a65e3 commit 43af00d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,14 @@ class VectorExpandLoadOpConversion
399399
Value ptr = getStridedElementPtr(rewriter, loc, memRefType,
400400
adaptor.getBase(), adaptor.getIndices());
401401

402+
// From:
403+
// https://llvm.org/docs/LangRef.html#llvm-masked-expandload-intrinsics
404+
// The pointer alignment defaults to 1.
405+
uint64_t alignment = expand.getAlignment().value_or(1);
406+
402407
rewriter.replaceOpWithNewOp<LLVM::masked_expandload>(
403-
expand, vtype, ptr, adaptor.getMask(), adaptor.getPassThru());
408+
expand, vtype, ptr, adaptor.getMask(), adaptor.getPassThru(),
409+
alignment);
404410
return success();
405411
}
406412
};

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

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

21502150
// -----
21512151

2152+
func.func @expand_load_op_with_alignment(%arg0: memref<?xindex>, %arg1: vector<11xi1>, %arg2: vector<11xindex>, %c0: index) -> vector<11xindex> {
2153+
%0 = vector.expandload %arg0[%c0], %arg1, %arg2 { alignment = 8 } : memref<?xindex>, vector<11xi1>, vector<11xindex> into vector<11xindex>
2154+
return %0 : vector<11xindex>
2155+
}
2156+
// CHECK-LABEL: func @expand_load_op_with_alignment
2157+
// CHECK: %{{.*}} = "llvm.intr.masked.expandload"(%{{.*}}, %{{.*}}, %{{.*}}) <{arg_attrs = [{llvm.align = 8 : i64}, {}, {}]}> : (!llvm.ptr, vector<11xi1>, vector<11xi64>) -> vector<11xi64>
2158+
2159+
// -----
2160+
21522161
//===----------------------------------------------------------------------===//
21532162
// vector.compressstore
21542163
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)