diff --git a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp --- a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp +++ b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp @@ -73,6 +73,10 @@ "csqrtf", "csqrt", benefit); patterns.add>(patterns.getContext(), "ctanhf", "ctanh", benefit); + patterns.add>(patterns.getContext(), + "ccosf", "ccos", benefit); + patterns.add>(patterns.getContext(), + "csinf", "csin", benefit); } namespace { diff --git a/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir b/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir --- a/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir +++ b/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir @@ -6,6 +6,8 @@ // CHECK-DAG: @csqrt(complex) -> complex // CHECK-DAG: @ctanhf(complex) -> complex // CHECK-DAG: @ctanh(complex) -> complex +// CHECK-DAG: @ccos(complex) -> complex +// CHECK-DAG: @csin(complex) -> complex // CHECK-LABEL: func @cpow_caller // CHECK-SAME: %[[FLOAT:.*]]: complex @@ -42,3 +44,27 @@ // CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]] return %float_result, %double_result : complex, complex } + +// CHECK-LABEL: func @ccos_caller +// CHECK-SAME: %[[FLOAT:.*]]: complex +// CHECK-SAME: %[[DOUBLE:.*]]: complex +func.func @ccos_caller(%float: complex, %double: complex) -> (complex, complex) { + // CHECK: %[[FLOAT_RESULT:.*]] = call @ccosf(%[[FLOAT]]) + %float_result = complex.cos %float : complex + // CHECK: %[[DOUBLE_RESULT:.*]] = call @ccos(%[[DOUBLE]]) + %double_result = complex.cos %double : complex + // CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]] + return %float_result, %double_result : complex, complex +} + +// CHECK-LABEL: func @csin_caller +// CHECK-SAME: %[[FLOAT:.*]]: complex +// CHECK-SAME: %[[DOUBLE:.*]]: complex +func.func @csin_caller(%float: complex, %double: complex) -> (complex, complex) { + // CHECK: %[[FLOAT_RESULT:.*]] = call @csinf(%[[FLOAT]]) + %float_result = complex.sin %float : complex + // CHECK: %[[DOUBLE_RESULT:.*]] = call @csin(%[[DOUBLE]]) + %double_result = complex.sin %double : complex + // CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]] + return %float_result, %double_result : complex, complex +} \ No newline at end of file