-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc][complex] Implement different flavors of the conj
function
#118671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libc Author: Shourya Goel (Sh0g0-1758) ChangesRefer section 7.3.9.4 of ISO/IEC 9899:2023 Patch is 29.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/118671.diff 26 Files Affected:
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index aa0b8ba0490e98..7b855e14a9e8eb 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -366,6 +366,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
+ libc.src.complex.conj
+ libc.src.complex.conjf
+ libc.src.complex.conjl
# fenv.h entrypoints
libc.src.fenv.feclearexcept
@@ -617,6 +620,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
# complex.h C23 _Complex _Float16 entrypoints
# libc.src.complex.crealf16
# libc.src.complex.cimagf16
+ # libc.src.complex.conjf16
# math.h C23 _Float16 entrypoints
libc.src.math.canonicalizef16
@@ -722,6 +726,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
# complex.h C23 _Complex _Float128 entrypoints
libc.src.complex.crealf128
libc.src.complex.cimagf128
+ libc.src.complex.conjf128
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 31d81de06fb6b0..babdf92bb56764 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -207,6 +207,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
+ libc.src.complex.conj
+ libc.src.complex.conjf
+ libc.src.complex.conjl
# fenv.h entrypoints
libc.src.fenv.feclearexcept
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index fedc5002d8c246..c7db77fe8875a2 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -365,6 +365,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
+ libc.src.complex.conj
+ libc.src.complex.conjf
+ libc.src.complex.conjl
# fenv.h entrypoints
libc.src.fenv.feclearexcept
@@ -620,6 +623,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
# complex.h C23 _Complex _Float128 entrypoints
libc.src.complex.crealf128
libc.src.complex.cimagf128
+ libc.src.complex.conjf128
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 5e9cc71279ab16..69ac5652fba2f3 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -366,6 +366,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.complex.cimag
libc.src.complex.cimagf
libc.src.complex.cimagl
+ libc.src.complex.conj
+ libc.src.complex.conjf
+ libc.src.complex.conjl
# fenv.h entrypoints
libc.src.fenv.feclearexcept
@@ -622,6 +625,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
# complex.h C23 _Complex _Float16 entrypoints
libc.src.complex.crealf16
libc.src.complex.cimagf16
+ libc.src.complex.conjf16
# math.h C23 _Float16 entrypoints
libc.src.math.canonicalizef16
@@ -731,6 +735,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
# complex.h C23 _Complex _Float128 entrypoints
# libc.src.complex.crealf128
# libc.src.complex.cimagf128
+ # libc.src.complex.conjf128
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
diff --git a/libc/docs/complex.rst b/libc/docs/complex.rst
index 1e74f16b60e660..3e375d5491640f 100644
--- a/libc/docs/complex.rst
+++ b/libc/docs/complex.rst
@@ -57,7 +57,7 @@ Functions
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| cimag | |check| | |check| | |check| | |check| | |check| | 7.3.9.2 | N/A |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| conj | | | | | | 7.3.9.4 | N/A |
+| conj | |check| | |check| | |check| | |check| | |check| | 7.3.9.4 | N/A |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| cproj | | | | | | 7.3.9.5 | N/A |
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/src/complex/CMakeLists.txt b/libc/src/complex/CMakeLists.txt
index 289cce5455af78..7306e2fe925e3a 100644
--- a/libc/src/complex/CMakeLists.txt
+++ b/libc/src/complex/CMakeLists.txt
@@ -24,3 +24,9 @@ add_complex_entrypoint_object(cimagf)
add_complex_entrypoint_object(cimagl)
add_complex_entrypoint_object(cimagf16)
add_complex_entrypoint_object(cimagf128)
+
+add_complex_entrypoint_object(conj)
+add_complex_entrypoint_object(conjf)
+add_complex_entrypoint_object(conjl)
+add_complex_entrypoint_object(conjf16)
+add_complex_entrypoint_object(conjf128)
diff --git a/libc/src/complex/conj.h b/libc/src/complex/conj.h
new file mode 100644
index 00000000000000..2ff82d27586202
--- /dev/null
+++ b/libc/src/complex/conj.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for conj --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CONJ_H
+#define LLVM_LIBC_SRC_COMPLEX_CONJ_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+_Complex double conj(_Complex double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CONJ_H
diff --git a/libc/src/complex/conjf.h b/libc/src/complex/conjf.h
new file mode 100644
index 00000000000000..6b3bd612e5bf7d
--- /dev/null
+++ b/libc/src/complex/conjf.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for conjf -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF_H
+#define LLVM_LIBC_SRC_COMPLEX_CONJF_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+_Complex float conjf(_Complex float x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CONJF_H
diff --git a/libc/src/complex/conjf128.h b/libc/src/complex/conjf128.h
new file mode 100644
index 00000000000000..587c979d315efb
--- /dev/null
+++ b/libc/src/complex/conjf128.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for conjf128 ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/macros/properties/complex_types.h"
+#include "src/__support/macros/properties/types.h"
+
+#if defined(LIBC_TYPES_HAS_CFLOAT128)
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF128_H
+#define LLVM_LIBC_SRC_COMPLEX_CONJF128_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+cfloat128 conjf128(cfloat128 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CONJF128_H
+
+#endif // LIBC_TYPES_HAS_CFLOAT128
diff --git a/libc/src/complex/conjf16.h b/libc/src/complex/conjf16.h
new file mode 100644
index 00000000000000..b15c5b3f61f4a0
--- /dev/null
+++ b/libc/src/complex/conjf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for conjf16 -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/macros/properties/complex_types.h"
+#include "src/__support/macros/properties/types.h"
+
+#if defined(LIBC_TYPES_HAS_CFLOAT16)
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CONJF16_H
+#define LLVM_LIBC_SRC_COMPLEX_CONJF16_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+cfloat16 conjf16(cfloat16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CONJF16_H
+
+#endif // LIBC_TYPES_HAS_CFLOAT16
diff --git a/libc/src/complex/conjl.h b/libc/src/complex/conjl.h
new file mode 100644
index 00000000000000..aec640f9433ac6
--- /dev/null
+++ b/libc/src/complex/conjl.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for conjl -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_COMPLEX_CONJL_H
+#define LLVM_LIBC_SRC_COMPLEX_CONJL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+_Complex long double conjl(_Complex long double x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_COMPLEX_CONJL_H
diff --git a/libc/src/complex/generic/CMakeLists.txt b/libc/src/complex/generic/CMakeLists.txt
index a3da781c602378..cc14f89122eddd 100644
--- a/libc/src/complex/generic/CMakeLists.txt
+++ b/libc/src/complex/generic/CMakeLists.txt
@@ -1,3 +1,72 @@
+add_entrypoint_object(
+ conj
+ SRCS
+ conj.cpp
+ HDRS
+ ../conj.h
+ COMPILE_OPTIONS
+ ${libc_opt_high_flag}
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.complex_type
+)
+
+add_entrypoint_object(
+ conjf
+ SRCS
+ conjf.cpp
+ HDRS
+ ../conjf.h
+ COMPILE_OPTIONS
+ ${libc_opt_high_flag}
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.complex_type
+)
+
+add_entrypoint_object(
+ conjl
+ SRCS
+ conjl.cpp
+ HDRS
+ ../conjl.h
+ COMPILE_OPTIONS
+ ${libc_opt_high_flag}
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.complex_type
+)
+
+add_entrypoint_object(
+ conjf16
+ SRCS
+ conjf16.cpp
+ HDRS
+ ../conjf16.h
+ COMPILE_OPTIONS
+ ${libc_opt_high_flag}
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.complex_type
+ libc.src.__support.macros.properties.types
+ libc.src.__support.macros.properties.complex_types
+)
+
+add_entrypoint_object(
+ conjf128
+ SRCS
+ conjf128.cpp
+ HDRS
+ ../conjf128.h
+ COMPILE_OPTIONS
+ ${libc_opt_high_flag}
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.complex_type
+ libc.src.__support.macros.properties.types
+ libc.src.__support.macros.properties.complex_types
+)
+
add_entrypoint_object(
creal
SRCS
diff --git a/libc/src/complex/generic/conj.cpp b/libc/src/complex/generic/conj.cpp
new file mode 100644
index 00000000000000..0d1376af34e9a0
--- /dev/null
+++ b/libc/src/complex/generic/conj.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of conj function -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/conj.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/complex_type.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(_Complex double, conj, (_Complex double x)) {
+ Complex<double> x_c = cpp::bit_cast<Complex<double>>(x);
+ return (x_c.real - x_c.imag * 1.0i);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/complex/generic/conjf.cpp b/libc/src/complex/generic/conjf.cpp
new file mode 100644
index 00000000000000..1d83a043f970de
--- /dev/null
+++ b/libc/src/complex/generic/conjf.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of conjf function ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/conjf.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/complex_type.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(_Complex float, conjf, (_Complex float x)) {
+ Complex<float> x_c = cpp::bit_cast<Complex<float>>(x);
+ return (x_c.real - x_c.imag * (_Complex float)1.0i);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/complex/generic/conjf128.cpp b/libc/src/complex/generic/conjf128.cpp
new file mode 100644
index 00000000000000..03114d331480b1
--- /dev/null
+++ b/libc/src/complex/generic/conjf128.cpp
@@ -0,0 +1,25 @@
+//===-- Implementation of conjf128 function -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/conjf128.h"
+#if defined(LIBC_TYPES_HAS_CFLOAT128)
+
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/complex_type.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(cfloat128, conjf128, (cfloat128 x)) {
+ Complex<float128> x_c = cpp::bit_cast<Complex<float128>>(x);
+ return (x_c.real - x_c.imag * (cfloat128)1.0i);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_CFLOAT128
diff --git a/libc/src/complex/generic/conjf16.cpp b/libc/src/complex/generic/conjf16.cpp
new file mode 100644
index 00000000000000..4c1ed0e60c1f2f
--- /dev/null
+++ b/libc/src/complex/generic/conjf16.cpp
@@ -0,0 +1,25 @@
+//===-- Implementation of conjf16 function --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/conjf16.h"
+#if defined(LIBC_TYPES_HAS_CFLOAT16)
+
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/complex_type.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(cfloat16, conjf16, (cfloat16 x)) {
+ Complex<float16> x_c = cpp::bit_cast<Complex<float16>>(x);
+ return (x_c.real - x_c.imag * (cfloat16)1.0i);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_CFLOAT16
diff --git a/libc/src/complex/generic/conjl.cpp b/libc/src/complex/generic/conjl.cpp
new file mode 100644
index 00000000000000..9e49217551c0d8
--- /dev/null
+++ b/libc/src/complex/generic/conjl.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of conjl function ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/complex/conjl.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/complex_type.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(_Complex long double, conjl, (_Complex long double x)) {
+ Complex<long double> x_c = cpp::bit_cast<Complex<long double>>(x);
+ return (x_c.real - x_c.imag * (_Complex long double)1.0i);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/complex/CImagTest.h b/libc/test/src/complex/CImagTest.h
index 6d2f9350026691..31236f7bf9a0d5 100644
--- a/libc/test/src/complex/CImagTest.h
+++ b/libc/test/src/complex/CImagTest.h
@@ -38,9 +38,10 @@ class CImagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
neg_min_denormal);
EXPECT_FP_EQ(func(CFPT(1241.112 + max_denormal * 1.0i)), max_denormal);
EXPECT_FP_EQ(func(CFPT(121.121 + zero * 1.0i)), zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + neg_zero * 1.0i)), neg_zero);
- EXPECT_FP_EQ(func(CFPT(zero + neg_zero * 1.0i)), neg_zero);
+ EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), -0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), -0.0);
}
void testRoundedNumbers(CImagFunc func) {
diff --git a/libc/test/src/complex/CMakeLists.txt b/libc/test/src/complex/CMakeLists.txt
index 8f49e6d79e1796..0c668d9e1e8b9c 100644
--- a/libc/test/src/complex/CMakeLists.txt
+++ b/libc/test/src/complex/CMakeLists.txt
@@ -1,5 +1,65 @@
add_custom_target(libc-complex-unittests)
+add_libc_test(
+ conj_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conj_test.cpp
+ DEPENDS
+ libc.src.complex.conj
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjf_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjf_test.cpp
+ DEPENDS
+ libc.src.complex.conjf
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjl_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjl_test.cpp
+ DEPENDS
+ libc.src.complex.conjl
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjf16_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjf16_test.cpp
+ DEPENDS
+ libc.src.complex.conjf16
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjf128_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjf128_test.cpp
+ DEPENDS
+ libc.src.complex.conjf128
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
add_libc_test(
creal_test
SUITE
diff --git a/libc/test/src/complex/CRealTest.h b/libc/test/src/complex/CRealTest.h
index a25555b506e225..9f1aed0fddfee1 100644
--- a/libc/test/src/complex/CRealTest.h
+++ b/libc/test/src/complex/CRealTest.h
@@ -37,8 +37,10 @@ class CRealTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(func(CFPT(neg_min_denormal + 781.134i)), neg_min_denormal);
EXPECT_FP_EQ(func(CFPT(max_denormal + 1241.112i)), max_denormal);
EXPECT_FP_EQ(func(CFPT(zero + 121.121i)), zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + neg_zero * 1.0i)), neg_zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
+ EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), -0.0);
}
void testRoundedNumbers(CRealFunc func) {
diff --git a/libc/test/src/complex/ConjTest.h b/libc/test/src/complex/ConjTest.h
new file mode 100644
index 00000000000000..2257f44909e6b9
--- /dev/null
+++ b/libc/test/src/complex/ConjTest.h
@@ -0,0 +1,123 @@
+//===-- Utility class to test different flavors of conj ---------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-------------...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nit.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/104/builds/12263 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/12241 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/188/builds/7878 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/196/builds/2149 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/183/builds/7317 Here is the relevant piece of the build log for the reference
|
Refer section 7.3.9.4 of ISO/IEC 9899:2023