================ @@ -2037,4 +2037,37 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure, let hasFolder = 1; } + +//===----------------------------------------------------------------------===// +// VecSplat +//===----------------------------------------------------------------------===// + +// cir.vec.splat is a separate operation from cir.vec.create because more +// efficient LLVM IR can be generated for it, and because some optimization and +// analysis passes can benefit from knowing that all elements of the vector +// have the same value. + +def VecSplatOp : CIR_Op<"vec.splat", [Pure, + TypesMatchWith<"type of 'value' matches element type of 'result'", "result", + "value", "cast<VectorType>($_self).getElementType()">]> { + + let summary = "Convert a scalar into a vector"; + let description = [{ + The `cir.vec.splat` operation creates a vector value from a scalar value. + All elements of the vector have the same value, that of the given scalar. + + ```mlir + %value = cir.const #cir.int<3> : !s32i + %value_vec = cir.vec.splat %value : !s32i, !cir.vector<4 x !s32i> ---------------- bcardosolopes wrote:
Same comment from the other PR: this operation can also benefit from a folder, fine if it comes into a later PR, but you should probably start to put in the PR description that you are deferring it. https://github.com/llvm/llvm-project/pull/139827 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits