Skip to content

Commit 514cde7

Browse files
committed
Pass alignment from vector.gather to llvm.intr.masked.gather
1 parent b47eef6 commit 514cde7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,9 @@ class VectorGatherOpConversion
299299
}
300300

301301
// Resolve alignment.
302-
unsigned align;
303-
if (failed(getVectorToLLVMAlignment(*this->getTypeConverter(), vType,
302+
unsigned align = gather.getAlignment().value_or(0);
303+
if (!align &&
304+
failed(getVectorToLLVMAlignment(*this->getTypeConverter(), vType,
304305
memRefType, align, useVectorAlignment)))
305306
return rewriter.notifyMatchFailure(gather, "could not resolve alignment");
306307

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,16 @@ func.func @gather_1d_from_2d_scalable(%arg0: memref<4x?xf32>, %arg1: vector<[4]x
20422042

20432043
// -----
20442044

2045+
func.func @gather_with_alignment(%arg0: memref<?xf32>, %arg1: vector<3xi32>, %arg2: vector<3xi1>, %arg3: vector<3xf32>, %0: index) -> vector<3xf32> {
2046+
%1 = vector.gather %arg0[%0][%arg1], %arg2, %arg3 {alignment = 8} : memref<?xf32>, vector<3xi32>, vector<3xi1>, vector<3xf32> into vector<3xf32>
2047+
return %1 : vector<3xf32>
2048+
}
2049+
2050+
// CHECK-LABEL: func @gather_with_alignment
2051+
// CHECK: llvm.intr.masked.gather %{{.*}}, %{{.*}}, %{{.*}} {alignment = 8 : i32} : (vector<3x!llvm.ptr>, vector<3xi1>, vector<3xf32>) -> vector<3xf32>
2052+
2053+
// -----
2054+
20452055
//===----------------------------------------------------------------------===//
20462056
// vector.scatter
20472057
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)