forked from OSchip/llvm-project
[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
This commit is contained in:
parent
3b91657c7b
commit
f088b99eac
|
@ -2049,9 +2049,9 @@ void LLVM::ShuffleVectorOp::build(OpBuilder &b, OperationState &result,
|
|||
Value v1, Value v2, ArrayAttr mask,
|
||||
ArrayRef<NamedAttribute> attrs) {
|
||||
auto containerType = v1.getType();
|
||||
auto vType = LLVM::getVectorType(
|
||||
LLVM::getVectorElementType(containerType), mask.size(),
|
||||
containerType.cast<VectorType>().isScalable());
|
||||
auto vType = LLVM::getVectorType(LLVM::getVectorElementType(containerType),
|
||||
mask.size(),
|
||||
LLVM::isScalableVectorType(containerType));
|
||||
build(b, result, vType, v1, v2, mask);
|
||||
result.addAttributes(attrs);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
; RUN: mlir-translate --import-llvm %s | FileCheck %s
|
||||
|
||||
; CHECK: llvm.func @shufflevector_crash
|
||||
define void @shufflevector_crash(<2 x i32*> %arg0) {
|
||||
; CHECK: llvm.shufflevector %{{.+}}, %{{.+}} [1 : i32, 0 : i32] : !llvm.vec<2 x ptr<i32>>, !llvm.vec<2 x ptr<i32>>
|
||||
%1 = shufflevector <2 x i32*> %arg0, <2 x i32*> undef, <2 x i32> <i32 1, i32 0>
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue