[Mlir-commits] [mlir] 72ee11a - [mlir][complex] Convert complex.conj to libm
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Jun 19 17:39:22 PDT 2022
Author: lewuathe
Date: 2022-06-20T09:38:50+09:00
New Revision: 72ee11a8cf6493cfd1ac4e4cf44d701139459357
URL: https://github.com/llvm/llvm-project/commit/72ee11a8cf6493cfd1ac4e4cf44d701139459357
DIFF: https://github.com/llvm/llvm-project/commit/72ee11a8cf6493cfd1ac4e4cf44d701139459357.diff
LOG: [mlir][complex] Convert complex.conj to libm
Add conversion for complex.conj to libm call
Reviewed By: bixia
Differential Revision: https://reviews.llvm.org/D127473
Added:
Modified:
mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
index 739603a245551..c973489938461 100644
--- a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
+++ b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
@@ -77,6 +77,8 @@ void mlir::populateComplexToLibmConversionPatterns(RewritePatternSet &patterns,
"ccosf", "ccos", benefit);
patterns.add<ScalarOpToLibmCall<complex::SinOp>>(patterns.getContext(),
"csinf", "csin", benefit);
+ patterns.add<ScalarOpToLibmCall<complex::ConjOp>>(patterns.getContext(),
+ "conjf", "conj", benefit);
}
namespace {
diff --git a/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir b/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir
index 48655bb1ce8e7..f0cbe37f000e7 100644
--- a/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir
+++ b/mlir/test/Conversion/ComplexToLibm/convert-to-libm.mlir
@@ -8,6 +8,7 @@
// CHECK-DAG: @ctanh(complex<f64>) -> complex<f64>
// CHECK-DAG: @ccos(complex<f64>) -> complex<f64>
// CHECK-DAG: @csin(complex<f64>) -> complex<f64>
+// CHECK-DAG: @conj(complex<f64>) -> complex<f64>
// CHECK-LABEL: func @cpow_caller
// CHECK-SAME: %[[FLOAT:.*]]: complex<f32>
@@ -67,4 +68,16 @@ func.func @csin_caller(%float: complex<f32>, %double: complex<f64>) -> (complex<
%double_result = complex.sin %double : complex<f64>
// CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]]
return %float_result, %double_result : complex<f32>, complex<f64>
+}
+
+// CHECK-LABEL: func @conj_caller
+// CHECK-SAME: %[[FLOAT:.*]]: complex<f32>
+// CHECK-SAME: %[[DOUBLE:.*]]: complex<f64>
+func.func @conj_caller(%float: complex<f32>, %double: complex<f64>) -> (complex<f32>, complex<f64>) {
+ // CHECK: %[[FLOAT_RESULT:.*]] = call @conjf(%[[FLOAT]])
+ %float_result = complex.conj %float : complex<f32>
+ // CHECK: %[[DOUBLE_RESULT:.*]] = call @conj(%[[DOUBLE]])
+ %double_result = complex.conj %double : complex<f64>
+ // CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]]
+ return %float_result, %double_result : complex<f32>, complex<f64>
}
\ No newline at end of file
More information about the Mlir-commits
mailing list