[clang] [CIR] Upstream local initialization for VectorType (PR #138107)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 12:00:29 PDT 2025
================
@@ -1685,6 +1686,29 @@ mlir::LogicalResult CIRToLLVMStackRestoreOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMVecCreateOpLowering::matchAndRewrite(
+ cir::VecCreateOp op, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const {
+ // Start with an 'undef' value for the vector. Then 'insertelement' for
+ // each of the vector elements.
+ const auto vecTy = mlir::cast<cir::VectorType>(op.getType());
+ const mlir::Type llvmTy = typeConverter->convertType(vecTy);
+ const mlir::Location loc = op.getLoc();
+ mlir::Value result = rewriter.create<mlir::LLVM::PoisonOp>(loc, llvmTy);
+ assert(vecTy.getSize() == op.getElements().size() &&
+ "cir.vec.create op count doesn't match vector type elements count");
+
+ for (uint64_t i = 0; i < vecTy.getSize(); ++i) {
----------------
andykaylor wrote:
OK. We can possibly revisit this later. For constant values, it looks like it ends up as a single store in LLVM IR anyway.
https://github.com/llvm/llvm-project/pull/138107
More information about the cfe-commits
mailing list