[clang] [CIR] Upstream splat op for VectorType (PR #139827)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Fri May 30 10:48:32 PDT 2025
================
@@ -2141,4 +2141,36 @@ def VecCmpOp : CIR_Op<"vec.cmp", [Pure, SameTypeOperands]> {
}];
}
-#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
+//===----------------------------------------------------------------------===//
+// VecSplatOp
+//===----------------------------------------------------------------------===//
+
+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.
+
+ It's 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.
+
+ ```mlir
+ %value = cir.const #cir.int<3> : !s32i
+ %value_vec = cir.vec.splat %value : !s32i, !cir.vector<4 x !s32i>
+ ```
+ }];
+
+ let arguments = (ins CIR_AnyType:$value);
+ let results = (outs CIR_VectorType:$result);
+
+ let assemblyFormat = [{
+ $value `:` type($value) `,` qualified(type($result)) attr-dict
+ }];
+}
+
+#endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
----------------
AmrDeveloper wrote:
Not sure about the icon, but i think yes, i will check and update it now
https://github.com/llvm/llvm-project/pull/139827
More information about the cfe-commits
mailing list