Skip to content

Commit bc1d1ec

Browse files
committed
Use replaceOpWithNewOp and remove extra cast
1 parent 6097632 commit bc1d1ec

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
@@ -1892,7 +1892,7 @@ mlir::LogicalResult CIRToLLVMVecSplatOpLowering::matchAndRewrite(
18921892
// element in the vector. Start with an undef vector. Insert the value into
18931893
// the first element. Then use a `shufflevector` with a mask of all 0 to
18941894
// fill out the entire vector with that value.
1895-
const auto vecTy = mlir::cast<cir::VectorType>(op.getType());
1895+
const cir::VectorType vecTy = op.getType();
18961896
const mlir::Type llvmTy = typeConverter->convertType(vecTy);
18971897
const mlir::Location loc = op.getLoc();
18981898
const mlir::Value poison = rewriter.create<mlir::LLVM::PoisonOp>(loc, llvmTy);
@@ -1910,20 +1910,16 @@ mlir::LogicalResult CIRToLLVMVecSplatOpLowering::matchAndRewrite(
19101910
if (auto intAttr = dyn_cast<mlir::IntegerAttr>(constValue.getValue())) {
19111911
mlir::DenseIntElementsAttr denseVec = mlir::DenseIntElementsAttr::get(
19121912
mlir::cast<mlir::ShapedType>(llvmTy), intAttr.getValue());
1913-
1914-
const mlir::Value indexValue = rewriter.create<mlir::LLVM::ConstantOp>(
1915-
loc, denseVec.getType(), denseVec);
1916-
rewriter.replaceOp(op, indexValue);
1913+
rewriter.replaceOpWithNewOp<mlir::LLVM::ConstantOp>(
1914+
op, denseVec.getType(), denseVec);
19171915
return mlir::success();
19181916
}
19191917

19201918
if (auto fpAttr = dyn_cast<mlir::FloatAttr>(constValue.getValue())) {
19211919
mlir::DenseFPElementsAttr denseVec = mlir::DenseFPElementsAttr::get(
19221920
mlir::cast<mlir::ShapedType>(llvmTy), fpAttr.getValue());
1923-
1924-
const mlir::Value indexValue = rewriter.create<mlir::LLVM::ConstantOp>(
1925-
loc, denseVec.getType(), denseVec);
1926-
rewriter.replaceOp(op, indexValue);
1921+
rewriter.replaceOpWithNewOp<mlir::LLVM::ConstantOp>(
1922+
op, denseVec.getType(), denseVec);
19271923
return mlir::success();
19281924
}
19291925
}

0 commit comments

Comments
 (0)