Skip to content

Commit c6df5f8

Browse files
committed
Use replaceOpWithNewOp and remove extra cast
1 parent 23f211a commit c6df5f8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ mlir::LogicalResult CIRToLLVMVecSplatOpLowering::matchAndRewrite(
19321932
// element in the vector. Start with an undef vector. Insert the value into
19331933
// the first element. Then use a `shufflevector` with a mask of all 0 to
19341934
// fill out the entire vector with that value.
1935-
const auto vecTy = mlir::cast<cir::VectorType>(op.getType());
1935+
const cir::VectorType vecTy = op.getType();
19361936
const mlir::Type llvmTy = typeConverter->convertType(vecTy);
19371937
const mlir::Location loc = op.getLoc();
19381938
const mlir::Value poison = rewriter.create<mlir::LLVM::PoisonOp>(loc, llvmTy);
@@ -1950,20 +1950,16 @@ mlir::LogicalResult CIRToLLVMVecSplatOpLowering::matchAndRewrite(
19501950
if (auto intAttr = dyn_cast<mlir::IntegerAttr>(constValue.getValue())) {
19511951
mlir::DenseIntElementsAttr denseVec = mlir::DenseIntElementsAttr::get(
19521952
mlir::cast<mlir::ShapedType>(llvmTy), intAttr.getValue());
1953-
1954-
const mlir::Value indexValue = rewriter.create<mlir::LLVM::ConstantOp>(
1955-
loc, denseVec.getType(), denseVec);
1956-
rewriter.replaceOp(op, indexValue);
1953+
rewriter.replaceOpWithNewOp<mlir::LLVM::ConstantOp>(
1954+
op, denseVec.getType(), denseVec);
19571955
return mlir::success();
19581956
}
19591957

19601958
if (auto fpAttr = dyn_cast<mlir::FloatAttr>(constValue.getValue())) {
19611959
mlir::DenseFPElementsAttr denseVec = mlir::DenseFPElementsAttr::get(
19621960
mlir::cast<mlir::ShapedType>(llvmTy), fpAttr.getValue());
1963-
1964-
const mlir::Value indexValue = rewriter.create<mlir::LLVM::ConstantOp>(
1965-
loc, denseVec.getType(), denseVec);
1966-
rewriter.replaceOp(op, indexValue);
1961+
rewriter.replaceOpWithNewOp<mlir::LLVM::ConstantOp>(
1962+
op, denseVec.getType(), denseVec);
19671963
return mlir::success();
19681964
}
19691965
}

0 commit comments

Comments
 (0)