Skip to content

Commit f088b99

Browse files
committed
[mlir][LLVMIR] Use the correct way to determine if it's a scalable vector
One of the ShuffleVectorOp::build functions checks if the incoming vector operands is scalable vector by casting its type to mlir::VectorType first. However, in some cases the operand is not necessarily mlir::VectorType (e.g. it might be a LLVMVectorType). This patch fixes this issue by using the dedicated `LLVM::isScalableVectorType` function to determine if the incoming vector is scalable vector or not. Differential Revision: https://reviews.llvm.org/D125818
1 parent 3b91657 commit f088b99

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,9 +2049,9 @@ void LLVM::ShuffleVectorOp::build(OpBuilder &b, OperationState &result,
20492049
Value v1, Value v2, ArrayAttr mask,
20502050
ArrayRef<NamedAttribute> attrs) {
20512051
auto containerType = v1.getType();
2052-
auto vType = LLVM::getVectorType(
2053-
LLVM::getVectorElementType(containerType), mask.size(),
2054-
containerType.cast<VectorType>().isScalable());
2052+
auto vType = LLVM::getVectorType(LLVM::getVectorElementType(containerType),
2053+
mask.size(),
2054+
LLVM::isScalableVectorType(containerType));
20552055
build(b, result, vType, v1, v2, mask);
20562056
result.addAttributes(attrs);
20572057
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: mlir-translate --import-llvm %s | FileCheck %s
2+
3+
; CHECK: llvm.func @shufflevector_crash
4+
define void @shufflevector_crash(<2 x i32*> %arg0) {
5+
; CHECK: llvm.shufflevector %{{.+}}, %{{.+}} [1 : i32, 0 : i32] : !llvm.vec<2 x ptr<i32>>, !llvm.vec<2 x ptr<i32>>
6+
%1 = shufflevector <2 x i32*> %arg0, <2 x i32*> undef, <2 x i32> <i32 1, i32 0>
7+
ret void
8+
}

0 commit comments

Comments
 (0)