Skip to content

Commit b5e0420

Browse files
committed
Pass alignment from vector.scatter to llvm.intr.masked.scatter
1 parent 38c4e55 commit b5e0420

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,9 @@ class VectorScatterOpConversion
354354
}
355355

356356
// Resolve alignment.
357-
unsigned align;
358-
if (failed(getVectorToLLVMAlignment(*this->getTypeConverter(), vType,
357+
unsigned align = scatter.getAlignment().value_or(0);
358+
if (!align &&
359+
failed(getVectorToLLVMAlignment(*this->getTypeConverter(), vType,
359360
memRefType, align, useVectorAlignment)))
360361
return rewriter.notifyMatchFailure(scatter,
361362
"could not resolve alignment");

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,17 @@ func.func @scatter_1d_into_2d_scalable(%arg0: memref<4x?xf32>, %arg1: vector<[4]
21182118
// CHECK: %[[P:.*]] = llvm.getelementptr %[[B]][%{{.*}}] : (!llvm.ptr, vector<[4]xi32>) -> vector<[4]x!llvm.ptr>, f32
21192119
// CHECK: llvm.intr.masked.scatter %{{.*}}, %[[P]], %{{.*}} {alignment = 4 : i32} : vector<[4]xf32>, vector<[4]xi1> into vector<[4]x!llvm.ptr>
21202120

2121+
// -----
2122+
2123+
func.func @scatter_with_alignment(%arg0: memref<?xf32>, %arg1: vector<3xi32>, %arg2: vector<3xi1>, %arg3: vector<3xf32>, %0: index) {
2124+
vector.scatter %arg0[%0][%arg1], %arg2, %arg3 { alignment = 8 } : memref<?xf32>, vector<3xi32>, vector<3xi1>, vector<3xf32>
2125+
return
2126+
}
2127+
2128+
// CHECK-LABEL: func @scatter_with_alignment
2129+
// CHECK: llvm.intr.masked.scatter %{{.*}}, %{{.*}}, %{{.*}} {alignment = 8 : i32} : vector<3xf32>, vector<3xi1> into vector<3x!llvm.ptr>
2130+
2131+
21212132
// -----
21222133

21232134
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)