[Mlir-commits] [mlir] [MLIR] Add sincos op to math dialect (PR #160772)

Ivan Butygin llvmlistbot at llvm.org
Tue Sep 30 00:17:48 PDT 2025


================
@@ -121,6 +121,38 @@ using CountTrailingZerosOpLowering =
                           LLVM::CountTrailingZerosOp>;
 using AbsIOpLowering = IntOpWithFlagLowering<math::AbsIOp, LLVM::AbsOp>;
 
+// A `sincos` is converted into `llvm.intr.sincos` followed by extractvalue ops.
+struct SincosOpLowering : public ConvertOpToLLVMPattern<math::SincosOp> {
+  using ConvertOpToLLVMPattern<math::SincosOp>::ConvertOpToLLVMPattern;
+
+  LogicalResult
+  matchAndRewrite(math::SincosOp op, OpAdaptor adaptor,
+                  ConversionPatternRewriter &rewriter) const override {
+    const auto &typeConverter = *this->getTypeConverter();
+    auto loc = op.getLoc();
+    auto operandType = adaptor.getOperand().getType();
+    auto llvmOperandType = typeConverter.convertType(operandType);
+    auto sinType = typeConverter.convertType(op.getSin().getType());
+    auto cosType = typeConverter.convertType(op.getCos().getType());
----------------
Hardcode84 wrote:

Please spell actual types here instead of `auto`.

https://github.com/llvm/llvm-project/pull/160772


More information about the Mlir-commits mailing list