@@ -138,10 +138,10 @@ mlir::LLVM::FCmpPredicate convertCmpKindToFCmpPredicate(cir::CmpOpKind kind) {
138
138
// / If the given type is a vector type, return the vector's element type.
139
139
// / Otherwise return the given type unchanged.
140
140
mlir::Type elementTypeIfVector (mlir::Type type) {
141
- if ( auto VecType = mlir::dyn_cast<cir::VectorType >(type)) {
142
- return VecType. getElementType ();
143
- }
144
- return type ;
141
+ return llvm::TypeSwitch<mlir::Type, mlir::Type >(type)
142
+ . Case <cir::VectorType, mlir::VectorType>(
143
+ []( auto p) { return p. getElementType (); })
144
+ . Default ([](mlir::Type p) { return p; }) ;
145
145
}
146
146
147
147
mlir::LLVM::Visibility
@@ -2763,13 +2763,10 @@ mlir::LogicalResult CIRToLLVMBinOpLowering::matchAndRewrite(
2763
2763
cir::VectorType, mlir::IntegerType>(type)) &&
2764
2764
" operand type not supported yet" );
2765
2765
2766
- auto llvmTy = getTypeConverter ()->convertType (op.getType ());
2767
- mlir::Type llvmEltTy =
2768
- mlir::isa<mlir::VectorType>(llvmTy)
2769
- ? mlir::cast<mlir::VectorType>(llvmTy).getElementType ()
2770
- : llvmTy;
2771
- auto rhs = adaptor.getRhs ();
2772
- auto lhs = adaptor.getLhs ();
2766
+ mlir::Type llvmTy = getTypeConverter ()->convertType (op.getType ());
2767
+ mlir::Type llvmEltTy = elementTypeIfVector (llvmTy);
2768
+ mlir::Value rhs = adaptor.getRhs ();
2769
+ mlir::Value lhs = adaptor.getLhs ();
2773
2770
2774
2771
type = elementTypeIfVector (type);
2775
2772
0 commit comments