@@ -57,7 +57,7 @@ namespace {
5757mlir::Type elementTypeIfVector (mlir::Type type) {
5858 return llvm::TypeSwitch<mlir::Type, mlir::Type>(type)
5959 .Case <cir::VectorType, mlir::VectorType>(
60- [](auto p) { return p-> getElementType (); })
60+ [](auto p) { return p. getElementType (); })
6161 .Default ([](mlir::Type p) { return p; });
6262}
6363} // namespace
@@ -1043,11 +1043,11 @@ mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
10431043 mlir::ConversionPatternRewriter &rewriter) const {
10441044 assert (op.getType () == op.getInput ().getType () &&
10451045 " Unary operation's operand type and result type are different" );
1046- const mlir::Type type = op.getType ();
1047- const mlir::Type elementType = elementTypeIfVector (type);
1048- const bool isVector = mlir::isa<cir::VectorType>(type);
1049- const mlir::Type llvmType = getTypeConverter ()->convertType (type);
1050- const mlir::Location loc = op.getLoc ();
1046+ mlir::Type type = op.getType ();
1047+ mlir::Type elementType = elementTypeIfVector (type);
1048+ bool isVector = mlir::isa<cir::VectorType>(type);
1049+ mlir::Type llvmType = getTypeConverter ()->convertType (type);
1050+ mlir::Location loc = op.getLoc ();
10511051
10521052 // Integer unary operations: + - ~ ++ --
10531053 if (mlir::isa<cir::IntType>(elementType)) {
@@ -1089,23 +1089,12 @@ mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
10891089 // bit-wise compliment operator, implemented as an XOR with -1.
10901090 mlir::Value minusOne;
10911091 if (isVector) {
1092- // Creating a vector object with all -1 values is easier said than
1093- // done. It requires a series of insertelement ops.
1094- const mlir::Type llvmElementType =
1095- getTypeConverter ()->convertType (elementType);
1096- const mlir::Value minusOneInt = rewriter.create <mlir::LLVM::ConstantOp>(
1097- loc, llvmElementType, mlir::IntegerAttr::get (llvmElementType, -1 ));
1098- minusOne = rewriter.create <mlir::LLVM::UndefOp>(loc, llvmType);
1099-
11001092 const uint64_t numElements =
11011093 mlir::dyn_cast<cir::VectorType>(type).getSize ();
1102- for (uint64_t i = 0 ; i < numElements; ++i) {
1103- const mlir::Value indexValue =
1104- rewriter.create <mlir::LLVM::ConstantOp>(loc,
1105- rewriter.getI64Type (), i);
1106- minusOne = rewriter.create <mlir::LLVM::InsertElementOp>(
1107- loc, minusOne, minusOneInt, indexValue);
1108- }
1094+ std::vector<int32_t > values (numElements, -1 );
1095+ mlir::DenseIntElementsAttr denseVec = rewriter.getI32VectorAttr (values);
1096+ minusOne =
1097+ rewriter.create <mlir::LLVM::ConstantOp>(loc, llvmType, denseVec);
11091098 } else {
11101099 minusOne = rewriter.create <mlir::LLVM::ConstantOp>(
11111100 loc, llvmType, mlir::IntegerAttr::get (llvmType, -1 ));
0 commit comments