[libc-commits] [compiler-rt] [libc] [llvm] [compiler-rt][builtins] add libc-backed arithmetic builtins (PR #207092)
via libc-commits
libc-commits at lists.llvm.org
Fri Jul 24 08:48:51 PDT 2026
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/207092
>From 666dabfb48fc855843768bf64eb158bbd7c5b6a3 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 28 May 2026 02:12:37 +0300
Subject: [PATCH 01/13] [compiler-rt][builtins] introduce libc math routines
---
.../compiler-rt-libc-builtins-tests.yml | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 .github/workflows/compiler-rt-libc-builtins-tests.yml
diff --git a/.github/workflows/compiler-rt-libc-builtins-tests.yml b/.github/workflows/compiler-rt-libc-builtins-tests.yml
new file mode 100644
index 0000000000000..3dab28c0387a7
--- /dev/null
+++ b/.github/workflows/compiler-rt-libc-builtins-tests.yml
@@ -0,0 +1,58 @@
+# Pre-commit CI for the compiler-rt + LLVM-libc builtins integration.
+name: compiler-rt + libc Builtins Tests
+permissions:
+ contents: read
+on:
+ pull_request:
+ branches: ["main"]
+ paths:
+ - "compiler-rt/lib/builtins/**"
+ - "compiler-rt/test/builtins/**"
+ - "libc/shared/builtins.h"
+ - "libc/shared/builtins/**"
+ - "libc/src/__support/builtins/**"
+ - "libc/src/__support/FPUtil/**"
+ - ".github/workflows/compiler-rt-libc-builtins-tests.yml"
+
+jobs:
+ build:
+ name: builtins (${{ matrix.os }})
+ if: github.repository_owner == 'llvm'
+ runs-on: ${{ matrix.os }}
+ container:
+ image: ${{ (startsWith(matrix.os, 'ubuntu-24.04-arm') && 'ghcr.io/llvm/arm64v8/libc-ubuntu-24.04') || 'ghcr.io/llvm/libc-ubuntu-24.04' }}
+ options: >-
+ --privileged
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-24.04, ubuntu-24.04-arm]
+
+ steps:
+ - uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ - name: Configure CMake
+ shell: bash
+ run: |
+ cmake \
+ -B build \
+ -S llvm \
+ -G Ninja \
+ -DCMAKE_C_COMPILER=clang-23 \
+ -DCMAKE_CXX_COMPILER=clang++-23 \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DLLVM_ENABLE_ASSERTIONS=ON \
+ -DLLVM_ENABLE_PROJECTS=clang \
+ -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
+ -DCOMPILER_RT_USE_LIBC_MATH=ON \
+ -DCOMPILER_RT_INCLUDE_TESTS=ON
+
+ - name: Test compiler-rt builtins
+ shell: bash
+ run: |
+ cmake \
+ --build build \
+ --parallel \
+ --target check-builtins
>From 4ff62bf936e2396114c8fcecea7ecacd61982f72 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Mon, 1 Jun 2026 00:50:36 +0300
Subject: [PATCH 02/13] allow all branches
---
.github/workflows/compiler-rt-libc-builtins-tests.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/compiler-rt-libc-builtins-tests.yml b/.github/workflows/compiler-rt-libc-builtins-tests.yml
index 3dab28c0387a7..ba9c9ecf38bdb 100644
--- a/.github/workflows/compiler-rt-libc-builtins-tests.yml
+++ b/.github/workflows/compiler-rt-libc-builtins-tests.yml
@@ -4,7 +4,6 @@ permissions:
contents: read
on:
pull_request:
- branches: ["main"]
paths:
- "compiler-rt/lib/builtins/**"
- "compiler-rt/test/builtins/**"
>From 2bae0a7582e9ae21b758e4251d4b902386d03650 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Mon, 1 Jun 2026 00:52:23 +0300
Subject: [PATCH 03/13] remove `--privileged`` option
---
.github/workflows/compiler-rt-libc-builtins-tests.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/compiler-rt-libc-builtins-tests.yml b/.github/workflows/compiler-rt-libc-builtins-tests.yml
index ba9c9ecf38bdb..66e511b45d95a 100644
--- a/.github/workflows/compiler-rt-libc-builtins-tests.yml
+++ b/.github/workflows/compiler-rt-libc-builtins-tests.yml
@@ -20,8 +20,6 @@ jobs:
runs-on: ${{ matrix.os }}
container:
image: ${{ (startsWith(matrix.os, 'ubuntu-24.04-arm') && 'ghcr.io/llvm/arm64v8/libc-ubuntu-24.04') || 'ghcr.io/llvm/libc-ubuntu-24.04' }}
- options: >-
- --privileged
strategy:
fail-fast: false
matrix:
>From 72f4c4773ccd3e1be973aeee124c89cd3bb4cc41 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Mon, 1 Jun 2026 00:53:52 +0300
Subject: [PATCH 04/13] remove shell option
---
.github/workflows/compiler-rt-libc-builtins-tests.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/compiler-rt-libc-builtins-tests.yml b/.github/workflows/compiler-rt-libc-builtins-tests.yml
index 66e511b45d95a..8605892a701fd 100644
--- a/.github/workflows/compiler-rt-libc-builtins-tests.yml
+++ b/.github/workflows/compiler-rt-libc-builtins-tests.yml
@@ -31,7 +31,6 @@ jobs:
persist-credentials: false
- name: Configure CMake
- shell: bash
run: |
cmake \
-B build \
@@ -47,7 +46,6 @@ jobs:
-DCOMPILER_RT_INCLUDE_TESTS=ON
- name: Test compiler-rt builtins
- shell: bash
run: |
cmake \
--build build \
>From f4341c938d688be8c64ac1df11d9c1eba35b2e72 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Fri, 26 Jun 2026 21:42:17 +0300
Subject: [PATCH 05/13] Split "[CI] Add precommit CIs to test compiler-rt +
LLVM libc integration"
---
.../compiler-rt-libc-builtins-tests.yml | 53 -------------------
1 file changed, 53 deletions(-)
delete mode 100644 .github/workflows/compiler-rt-libc-builtins-tests.yml
diff --git a/.github/workflows/compiler-rt-libc-builtins-tests.yml b/.github/workflows/compiler-rt-libc-builtins-tests.yml
deleted file mode 100644
index 8605892a701fd..0000000000000
--- a/.github/workflows/compiler-rt-libc-builtins-tests.yml
+++ /dev/null
@@ -1,53 +0,0 @@
-# Pre-commit CI for the compiler-rt + LLVM-libc builtins integration.
-name: compiler-rt + libc Builtins Tests
-permissions:
- contents: read
-on:
- pull_request:
- paths:
- - "compiler-rt/lib/builtins/**"
- - "compiler-rt/test/builtins/**"
- - "libc/shared/builtins.h"
- - "libc/shared/builtins/**"
- - "libc/src/__support/builtins/**"
- - "libc/src/__support/FPUtil/**"
- - ".github/workflows/compiler-rt-libc-builtins-tests.yml"
-
-jobs:
- build:
- name: builtins (${{ matrix.os }})
- if: github.repository_owner == 'llvm'
- runs-on: ${{ matrix.os }}
- container:
- image: ${{ (startsWith(matrix.os, 'ubuntu-24.04-arm') && 'ghcr.io/llvm/arm64v8/libc-ubuntu-24.04') || 'ghcr.io/llvm/libc-ubuntu-24.04' }}
- strategy:
- fail-fast: false
- matrix:
- os: [ubuntu-24.04, ubuntu-24.04-arm]
-
- steps:
- - uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- persist-credentials: false
-
- - name: Configure CMake
- run: |
- cmake \
- -B build \
- -S llvm \
- -G Ninja \
- -DCMAKE_C_COMPILER=clang-23 \
- -DCMAKE_CXX_COMPILER=clang++-23 \
- -DCMAKE_BUILD_TYPE=Release \
- -DLLVM_ENABLE_ASSERTIONS=ON \
- -DLLVM_ENABLE_PROJECTS=clang \
- -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
- -DCOMPILER_RT_USE_LIBC_MATH=ON \
- -DCOMPILER_RT_INCLUDE_TESTS=ON
-
- - name: Test compiler-rt builtins
- run: |
- cmake \
- --build build \
- --parallel \
- --target check-builtins
>From 929dfc1c9b00701ebde633c30e146dadc72bf8d2 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 2 Jul 2026 01:16:36 +0300
Subject: [PATCH 06/13] [compiler-rt][builtins] add libc-backed arithmetic
builtins
---
compiler-rt/lib/builtins/CMakeLists.txt | 7 +++++++
compiler-rt/lib/builtins/adddf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/divdf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/divtf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/muldf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/multf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/subdf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/subtf3.cpp | 22 ++++++++++++++++++++++
8 files changed, 161 insertions(+)
create mode 100644 compiler-rt/lib/builtins/adddf3.cpp
create mode 100644 compiler-rt/lib/builtins/divdf3.cpp
create mode 100644 compiler-rt/lib/builtins/divtf3.cpp
create mode 100644 compiler-rt/lib/builtins/muldf3.cpp
create mode 100644 compiler-rt/lib/builtins/multf3.cpp
create mode 100644 compiler-rt/lib/builtins/subdf3.cpp
create mode 100644 compiler-rt/lib/builtins/subtf3.cpp
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index e128fea6a3415..659e149b5a307 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -264,7 +264,14 @@ if(COMPILER_RT_USE_LIBC_MATH)
include_directories(SYSTEM ${_libc_include_dirs})
add_definitions(-DCOMPILER_RT_USE_LIBC_MATH)
+ use_libc_builtin(GENERIC_SOURCES adddf3)
use_libc_builtin(GENERIC_TF_SOURCES addtf3)
+ use_libc_builtin(GENERIC_SOURCES divdf3)
+ use_libc_builtin(GENERIC_TF_SOURCES divtf3)
+ use_libc_builtin(GENERIC_SOURCES muldf3)
+ use_libc_builtin(GENERIC_TF_SOURCES multf3)
+ use_libc_builtin(GENERIC_SOURCES subdf3)
+ use_libc_builtin(GENERIC_TF_SOURCES divtf3)
endif()
option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
diff --git a/compiler-rt/lib/builtins/adddf3.cpp b/compiler-rt/lib/builtins/adddf3.cpp
new file mode 100644
index 0000000000000..0bae3c92c3d3b
--- /dev/null
+++ b/compiler-rt/lib/builtins/adddf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/adddf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __adddf3 implemented on top of LLVM-libc's shared::adddf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/adddf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::adddf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/divdf3.cpp b/compiler-rt/lib/builtins/divdf3.cpp
new file mode 100644
index 0000000000000..ea01a3c719c51
--- /dev/null
+++ b/compiler-rt/lib/builtins/divdf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/divdf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __divdf3 implemented on top of LLVM-libc's shared::divdf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/divdf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __divdf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::divdf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/divtf3.cpp b/compiler-rt/lib/builtins/divtf3.cpp
new file mode 100644
index 0000000000000..7b16174ce16d9
--- /dev/null
+++ b/compiler-rt/lib/builtins/divtf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/divtf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __divtf3 implemented on top of LLVM-libc's shared::divtf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/divtf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __divtf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::divtf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/muldf3.cpp b/compiler-rt/lib/builtins/muldf3.cpp
new file mode 100644
index 0000000000000..d1d4c70fdb837
--- /dev/null
+++ b/compiler-rt/lib/builtins/muldf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/muldf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __muldf3 implemented on top of LLVM-libc's shared::muldf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/muldf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __muldf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::muldf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/multf3.cpp b/compiler-rt/lib/builtins/multf3.cpp
new file mode 100644
index 0000000000000..bafc7016bddfb
--- /dev/null
+++ b/compiler-rt/lib/builtins/multf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/multf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __multf3 implemented on top of LLVM-libc's shared::multf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/multf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __multf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::multf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/subdf3.cpp b/compiler-rt/lib/builtins/subdf3.cpp
new file mode 100644
index 0000000000000..c688d7dcab4c9
--- /dev/null
+++ b/compiler-rt/lib/builtins/subdf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/subdf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __subdf3 implemented on top of LLVM-libc's shared::subdf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/subdf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __subdf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::subdf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/subtf3.cpp b/compiler-rt/lib/builtins/subtf3.cpp
new file mode 100644
index 0000000000000..6868293f4043f
--- /dev/null
+++ b/compiler-rt/lib/builtins/subtf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/subtf3.cpp - Quad-precision addition (libc-backed) --*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __subtf3 implemented on top of LLVM-libc's shared::subtf3 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/subtf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __subtf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::subtf3(a, b);
+}
>From 07d22294a261de44da9ee2e2e263a71feae4a6c0 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Sat, 4 Jul 2026 20:03:09 +0300
Subject: [PATCH 07/13] [compiler-rt][builtins] add libc-backed arithmetic
builtins
---
compiler-rt/lib/builtins/CMakeLists.txt | 4 ++-
compiler-rt/lib/builtins/adddf3.cpp | 3 +-
compiler-rt/lib/builtins/divdf3.cpp | 3 +-
compiler-rt/lib/builtins/divtf3.cpp | 2 +-
compiler-rt/lib/builtins/muldf3.cpp | 2 +-
compiler-rt/lib/builtins/multf3.cpp | 2 +-
compiler-rt/lib/builtins/negdf2.cpp | 21 ++++++++++++
compiler-rt/lib/builtins/negsf2.cpp | 22 +++++++++++++
compiler-rt/lib/builtins/subdf3.cpp | 3 +-
compiler-rt/lib/builtins/subtf3.cpp | 2 +-
libc/shared/builtins.h | 2 ++
libc/shared/builtins/negdf2.h | 29 +++++++++++++++++
libc/shared/builtins/negsf2.h | 29 +++++++++++++++++
libc/src/__support/builtins/CMakeLists.txt | 16 ++++++++++
libc/src/__support/builtins/negdf2.h | 37 ++++++++++++++++++++++
libc/src/__support/builtins/negsf2.h | 37 ++++++++++++++++++++++
libc/test/shared/CMakeLists.txt | 2 ++
libc/test/shared/shared_builtins_test.cpp | 2 ++
18 files changed, 207 insertions(+), 11 deletions(-)
create mode 100644 compiler-rt/lib/builtins/negdf2.cpp
create mode 100644 compiler-rt/lib/builtins/negsf2.cpp
create mode 100644 libc/shared/builtins/negdf2.h
create mode 100644 libc/shared/builtins/negsf2.h
create mode 100644 libc/src/__support/builtins/negdf2.h
create mode 100644 libc/src/__support/builtins/negsf2.h
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 659e149b5a307..3a7751425d73f 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -270,8 +270,10 @@ if(COMPILER_RT_USE_LIBC_MATH)
use_libc_builtin(GENERIC_TF_SOURCES divtf3)
use_libc_builtin(GENERIC_SOURCES muldf3)
use_libc_builtin(GENERIC_TF_SOURCES multf3)
+ use_libc_builtin(GENERIC_SOURCES negdf2)
+ use_libc_builtin(GENERIC_SOURCES negsf2)
use_libc_builtin(GENERIC_SOURCES subdf3)
- use_libc_builtin(GENERIC_TF_SOURCES divtf3)
+ use_libc_builtin(GENERIC_TF_SOURCES subtf3)
endif()
option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
diff --git a/compiler-rt/lib/builtins/adddf3.cpp b/compiler-rt/lib/builtins/adddf3.cpp
index 0bae3c92c3d3b..03da4a1e33fb1 100644
--- a/compiler-rt/lib/builtins/adddf3.cpp
+++ b/compiler-rt/lib/builtins/adddf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/adddf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/adddf3.cpp - double-precision addition --------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
-#define QUAD_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
diff --git a/compiler-rt/lib/builtins/divdf3.cpp b/compiler-rt/lib/builtins/divdf3.cpp
index ea01a3c719c51..50ce7372b0647 100644
--- a/compiler-rt/lib/builtins/divdf3.cpp
+++ b/compiler-rt/lib/builtins/divdf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/divdf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/divdf3.cpp - double-precision division --------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
-#define QUAD_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
diff --git a/compiler-rt/lib/builtins/divtf3.cpp b/compiler-rt/lib/builtins/divtf3.cpp
index 7b16174ce16d9..bd099280aead6 100644
--- a/compiler-rt/lib/builtins/divtf3.cpp
+++ b/compiler-rt/lib/builtins/divtf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/divtf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/divtf3.cpp - quad-precision division ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/builtins/muldf3.cpp b/compiler-rt/lib/builtins/muldf3.cpp
index d1d4c70fdb837..d2effb1c7d665 100644
--- a/compiler-rt/lib/builtins/muldf3.cpp
+++ b/compiler-rt/lib/builtins/muldf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/muldf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/muldf3.cpp - double-precision multiplication --------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/builtins/multf3.cpp b/compiler-rt/lib/builtins/multf3.cpp
index bafc7016bddfb..e8324ca302c6e 100644
--- a/compiler-rt/lib/builtins/multf3.cpp
+++ b/compiler-rt/lib/builtins/multf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/multf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/multf3.cpp - quad-precision multiplication ----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/builtins/negdf2.cpp b/compiler-rt/lib/builtins/negdf2.cpp
new file mode 100644
index 0000000000000..cc9f190845cf3
--- /dev/null
+++ b/compiler-rt/lib/builtins/negdf2.cpp
@@ -0,0 +1,21 @@
+//===-- lib/negdf2.cpp - double-precision negation --------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __negdf2 implemented on top of LLVM-libc's shared::negdf2 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/negdf2.h"
+
+extern "C" COMPILER_RT_ABI fp_t __negdf2(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::negdf2(a, b);
+}
diff --git a/compiler-rt/lib/builtins/negsf2.cpp b/compiler-rt/lib/builtins/negsf2.cpp
new file mode 100644
index 0000000000000..2f23bf64b6b57
--- /dev/null
+++ b/compiler-rt/lib/builtins/negsf2.cpp
@@ -0,0 +1,22 @@
+//===-- lib/negsf2.cpp - single-precision negation --------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __negsf2 implemented on top of LLVM-libc's shared::negsf2 instruction.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/negsf2.h"
+
+extern "C" COMPILER_RT_ABI fp_t __negsf2(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::negsf2(a, b);
+}
diff --git a/compiler-rt/lib/builtins/subdf3.cpp b/compiler-rt/lib/builtins/subdf3.cpp
index c688d7dcab4c9..8ff5e0dc69976 100644
--- a/compiler-rt/lib/builtins/subdf3.cpp
+++ b/compiler-rt/lib/builtins/subdf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/subdf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/subdf3.cpp - double-precision subtraction -----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
-#define QUAD_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
diff --git a/compiler-rt/lib/builtins/subtf3.cpp b/compiler-rt/lib/builtins/subtf3.cpp
index 6868293f4043f..0880d12ddc50d 100644
--- a/compiler-rt/lib/builtins/subtf3.cpp
+++ b/compiler-rt/lib/builtins/subtf3.cpp
@@ -1,4 +1,4 @@
-//===-- lib/subtf3.cpp - Quad-precision addition (libc-backed) --*- C++ -*-===//
+//===-- lib/subtf3.cpp - quad-precision subtraction -------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/shared/builtins.h b/libc/shared/builtins.h
index ced054cb02582..b5b6dfa1d4d5b 100644
--- a/libc/shared/builtins.h
+++ b/libc/shared/builtins.h
@@ -26,6 +26,8 @@
#include "builtins/muldf3.h"
#include "builtins/mulsf3.h"
#include "builtins/multf3.h"
+#include "builtins/negdf2.h"
+#include "builtins/negsf2.h"
#include "builtins/subdf3.h"
#include "builtins/subsf3.h"
#include "builtins/subtf3.h"
diff --git a/libc/shared/builtins/negdf2.h b/libc/shared/builtins/negdf2.h
new file mode 100644
index 0000000000000..3322730f39dc6
--- /dev/null
+++ b/libc/shared/builtins/negdf2.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __negdf2 implementation as shared::negdf2 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_NEGDF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_NEGDF2_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/negdf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::negdf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_NEGDF2_H
diff --git a/libc/shared/builtins/negsf2.h b/libc/shared/builtins/negsf2.h
new file mode 100644
index 0000000000000..f8919935d8e84
--- /dev/null
+++ b/libc/shared/builtins/negsf2.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __negsf2 implementation as shared::negsf2 so
+/// that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_BUILTINS_NEGSF2_H
+#define LLVM_LIBC_SHARED_BUILTINS_NEGSF2_H
+
+#include "shared/libc_common.h"
+#include "src/__support/builtins/negsf2.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using builtins::negsf2;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_BUILTINS_NEGSF2_H
diff --git a/libc/src/__support/builtins/CMakeLists.txt b/libc/src/__support/builtins/CMakeLists.txt
index f5b5ffe3e07b4..8c2836bd3ce47 100644
--- a/libc/src/__support/builtins/CMakeLists.txt
+++ b/libc/src/__support/builtins/CMakeLists.txt
@@ -81,6 +81,22 @@ add_header_library(
DEPENDS
libc.src.__support.FPUtil.generic.add_sub
libc.src.__support.macros.config
+add_header_library(
+ negsf2
+ HDRS
+ negsf2.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_header_library(
+ negdf2
+ HDRS
+ negdf2.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.FPUtil.fp_bits
)
add_header_library(
diff --git a/libc/src/__support/builtins/negdf2.h b/libc/src/__support/builtins/negdf2.h
new file mode 100644
index 0000000000000..5e9752509a3d7
--- /dev/null
+++ b/libc/src/__support/builtins/negdf2.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __negdf2 implementation as builtins::negdf2
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_NEGDF2_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_NEGDF2_H
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Double-precision negation
+// Mirrors compiler-rt's __negdf2.
+LIBC_INLINE double negdf2(double x) {
+ using FPBits = fputil::FPBits<double>;
+
+ FPBits bits(x);
+ bits.set_sign(bits.sign().negate());
+ return bits.get_val();
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_NEGDF2_H
diff --git a/libc/src/__support/builtins/negsf2.h b/libc/src/__support/builtins/negsf2.h
new file mode 100644
index 0000000000000..81ab53ca7750c
--- /dev/null
+++ b/libc/src/__support/builtins/negsf2.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header exposes LLVM-libc's __negsf2 implementation as builtins::negsf2
+/// so that it can be reused by compiler-rt's builtins.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTINS_NEGSF2_H
+#define LLVM_LIBC_SRC___SUPPORT_BUILTINS_NEGSF2_H
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace builtins {
+
+// Single-precision negation
+// Mirrors compiler-rt's __negsf2.
+LIBC_INLINE float negsf2(float x) {
+ using FPBits = fputil::FPBits<float>;
+
+ FPBits bits(x);
+ bits.set_sign(bits.sign().negate());
+ return bits.get_val();
+}
+
+} // namespace builtins
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_BUILTINS_NEGSF2_H
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 6efe8365b1557..0fabf261c36e7 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -836,6 +836,8 @@ add_fp_unittest(
libc.src.__support.builtins.muldf3
libc.src.__support.builtins.mulsf3
libc.src.__support.builtins.multf3
+ libc.src.__support.builtins.negdf3
+ libc.src.__support.builtins.negsf3
libc.src.__support.builtins.subdf3
libc.src.__support.builtins.subsf3
libc.src.__support.builtins.subtf3
diff --git a/libc/test/shared/shared_builtins_test.cpp b/libc/test/shared/shared_builtins_test.cpp
index dac84345eade1..978f8c57e79d9 100644
--- a/libc/test/shared/shared_builtins_test.cpp
+++ b/libc/test/shared/shared_builtins_test.cpp
@@ -15,12 +15,14 @@ TEST(LlvmLibcSharedBuiltinsTest, AllFloat) {
EXPECT_FP_EQ(3.0f, LIBC_NAMESPACE::shared::divsf3(6.0f, 2.0f));
EXPECT_FP_EQ(6.0f, LIBC_NAMESPACE::shared::mulsf3(2.0f, 3.0f));
EXPECT_FP_EQ(2.0f, LIBC_NAMESPACE::shared::subsf3(5.0f, 3.0f));
+ EXPECT_FP_EQ(-5.0, LIBC_NAMESPACE::shared::negsf2(5.0));
}
TEST(LlvmLibcSharedBuiltinsTest, AllDouble) {
EXPECT_FP_EQ(3.0, LIBC_NAMESPACE::shared::adddf3(1.0, 2.0));
EXPECT_FP_EQ(3.0, LIBC_NAMESPACE::shared::divdf3(6.0, 2.0));
EXPECT_FP_EQ(6.0, LIBC_NAMESPACE::shared::muldf3(2.0, 3.0));
+ EXPECT_FP_EQ(5.0, LIBC_NAMESPACE::shared::negdf2(-5.0));
EXPECT_FP_EQ(2.0, LIBC_NAMESPACE::shared::subdf3(5.0, 3.0));
}
>From d024e82a4893d2f2e85b2df80ef0ef1b000527f8 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Sun, 5 Jul 2026 00:04:42 +0300
Subject: [PATCH 08/13] fix format
---
libc/src/__support/builtins/CMakeLists.txt | 2 ++
libc/src/__support/builtins/negdf2.h | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/libc/src/__support/builtins/CMakeLists.txt b/libc/src/__support/builtins/CMakeLists.txt
index 8c2836bd3ce47..d913971fa3b55 100644
--- a/libc/src/__support/builtins/CMakeLists.txt
+++ b/libc/src/__support/builtins/CMakeLists.txt
@@ -81,6 +81,8 @@ add_header_library(
DEPENDS
libc.src.__support.FPUtil.generic.add_sub
libc.src.__support.macros.config
+)
+
add_header_library(
negsf2
HDRS
diff --git a/libc/src/__support/builtins/negdf2.h b/libc/src/__support/builtins/negdf2.h
index 5e9752509a3d7..9d290fc7750e3 100644
--- a/libc/src/__support/builtins/negdf2.h
+++ b/libc/src/__support/builtins/negdf2.h
@@ -21,14 +21,14 @@
namespace LIBC_NAMESPACE_DECL {
namespace builtins {
-// Double-precision negation
+// Double-precision negation
// Mirrors compiler-rt's __negdf2.
LIBC_INLINE double negdf2(double x) {
- using FPBits = fputil::FPBits<double>;
+ using FPBits = fputil::FPBits<double>;
- FPBits bits(x);
- bits.set_sign(bits.sign().negate());
- return bits.get_val();
+ FPBits bits(x);
+ bits.set_sign(bits.sign().negate());
+ return bits.get_val();
}
} // namespace builtins
>From 3ff80f477965cc775e2428460286dd8405816ab5 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Wed, 8 Jul 2026 03:33:56 +0300
Subject: [PATCH 09/13] add single-precision arithmtics
---
compiler-rt/lib/builtins/CMakeLists.txt | 4 ++++
compiler-rt/lib/builtins/adddf3.cpp | 1 +
compiler-rt/lib/builtins/addsf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/divdf3.cpp | 1 +
compiler-rt/lib/builtins/divsf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/muldf3.cpp | 2 +-
compiler-rt/lib/builtins/mulsf3.cpp | 22 ++++++++++++++++++++++
compiler-rt/lib/builtins/subdf3.cpp | 1 +
compiler-rt/lib/builtins/subsf3.cpp | 22 ++++++++++++++++++++++
libc/test/shared/shared_builtins_test.cpp | 2 +-
10 files changed, 97 insertions(+), 2 deletions(-)
create mode 100644 compiler-rt/lib/builtins/addsf3.cpp
create mode 100644 compiler-rt/lib/builtins/divsf3.cpp
create mode 100644 compiler-rt/lib/builtins/mulsf3.cpp
create mode 100644 compiler-rt/lib/builtins/subsf3.cpp
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 3a7751425d73f..1685646483cbb 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -265,14 +265,18 @@ if(COMPILER_RT_USE_LIBC_MATH)
add_definitions(-DCOMPILER_RT_USE_LIBC_MATH)
use_libc_builtin(GENERIC_SOURCES adddf3)
+ use_libc_builtin(GENERIC_SOURCES addsf3)
use_libc_builtin(GENERIC_TF_SOURCES addtf3)
use_libc_builtin(GENERIC_SOURCES divdf3)
+ use_libc_builtin(GENERIC_SOURCES divsf3)
use_libc_builtin(GENERIC_TF_SOURCES divtf3)
use_libc_builtin(GENERIC_SOURCES muldf3)
+ use_libc_builtin(GENERIC_SOURCES mulsf3)
use_libc_builtin(GENERIC_TF_SOURCES multf3)
use_libc_builtin(GENERIC_SOURCES negdf2)
use_libc_builtin(GENERIC_SOURCES negsf2)
use_libc_builtin(GENERIC_SOURCES subdf3)
+ use_libc_builtin(GENERIC_SOURCES subsf3)
use_libc_builtin(GENERIC_TF_SOURCES subtf3)
endif()
diff --git a/compiler-rt/lib/builtins/adddf3.cpp b/compiler-rt/lib/builtins/adddf3.cpp
index 03da4a1e33fb1..89918c9c54607 100644
--- a/compiler-rt/lib/builtins/adddf3.cpp
+++ b/compiler-rt/lib/builtins/adddf3.cpp
@@ -12,6 +12,7 @@
#include "fp_lib.h"
+#define DOUBLE_PRECISION
#include "fp_libc_config.h"
#include "int_lib.h"
#include "shared/builtins/adddf3.h"
diff --git a/compiler-rt/lib/builtins/addsf3.cpp b/compiler-rt/lib/builtins/addsf3.cpp
new file mode 100644
index 0000000000000..bb8704334e6f0
--- /dev/null
+++ b/compiler-rt/lib/builtins/addsf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/addsf3.cpp - libc-backed __addsf3 -------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __addsf3 implemented on top of LLVM-libc's shared::addsf3.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/addsf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __addsf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::addsf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/divdf3.cpp b/compiler-rt/lib/builtins/divdf3.cpp
index 50ce7372b0647..c542ac490da6b 100644
--- a/compiler-rt/lib/builtins/divdf3.cpp
+++ b/compiler-rt/lib/builtins/divdf3.cpp
@@ -12,6 +12,7 @@
#include "fp_lib.h"
+#define DOUBLE_PRECISION
#include "fp_libc_config.h"
#include "int_lib.h"
#include "shared/builtins/divdf3.h"
diff --git a/compiler-rt/lib/builtins/divsf3.cpp b/compiler-rt/lib/builtins/divsf3.cpp
new file mode 100644
index 0000000000000..106752c17b024
--- /dev/null
+++ b/compiler-rt/lib/builtins/divsf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/divsf3.cpp - libc-backed __divsf3 -------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __divsf3 implemented on top of LLVM-libc's shared::divsf3.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/divsf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __divsf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::divsf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/muldf3.cpp b/compiler-rt/lib/builtins/muldf3.cpp
index d2effb1c7d665..ec7c1ebe9e3e3 100644
--- a/compiler-rt/lib/builtins/muldf3.cpp
+++ b/compiler-rt/lib/builtins/muldf3.cpp
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
-#define QUAD_PRECISION
+#define DOUBLE_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
diff --git a/compiler-rt/lib/builtins/mulsf3.cpp b/compiler-rt/lib/builtins/mulsf3.cpp
new file mode 100644
index 0000000000000..d88c8b72078e2
--- /dev/null
+++ b/compiler-rt/lib/builtins/mulsf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/mulsf3.cpp - libc-backed __mulsf3 -------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __mulsf3 implemented on top of LLVM-libc's shared::mulsf3.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/mulsf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __mulsf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::mulsf3(a, b);
+}
diff --git a/compiler-rt/lib/builtins/subdf3.cpp b/compiler-rt/lib/builtins/subdf3.cpp
index 8ff5e0dc69976..e910a9d10e6e2 100644
--- a/compiler-rt/lib/builtins/subdf3.cpp
+++ b/compiler-rt/lib/builtins/subdf3.cpp
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+#define DOUBLE_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
diff --git a/compiler-rt/lib/builtins/subsf3.cpp b/compiler-rt/lib/builtins/subsf3.cpp
new file mode 100644
index 0000000000000..d1cdebc78ff09
--- /dev/null
+++ b/compiler-rt/lib/builtins/subsf3.cpp
@@ -0,0 +1,22 @@
+//===-- lib/subsf3.cpp - libc-backed __subsf3 -------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// __subsf3 implemented on top of LLVM-libc's shared::subsf3.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "fp_lib.h"
+
+#include "fp_libc_config.h"
+#include "int_lib.h"
+#include "shared/builtins/subsf3.h"
+
+extern "C" COMPILER_RT_ABI fp_t __subsf3(fp_t a, fp_t b) {
+ return LIBC_NAMESPACE::shared::subsf3(a, b);
+}
diff --git a/libc/test/shared/shared_builtins_test.cpp b/libc/test/shared/shared_builtins_test.cpp
index 978f8c57e79d9..97f1d82b3dc3c 100644
--- a/libc/test/shared/shared_builtins_test.cpp
+++ b/libc/test/shared/shared_builtins_test.cpp
@@ -14,8 +14,8 @@ TEST(LlvmLibcSharedBuiltinsTest, AllFloat) {
EXPECT_FP_EQ(3.0f, LIBC_NAMESPACE::shared::addsf3(1.0f, 2.0f));
EXPECT_FP_EQ(3.0f, LIBC_NAMESPACE::shared::divsf3(6.0f, 2.0f));
EXPECT_FP_EQ(6.0f, LIBC_NAMESPACE::shared::mulsf3(2.0f, 3.0f));
- EXPECT_FP_EQ(2.0f, LIBC_NAMESPACE::shared::subsf3(5.0f, 3.0f));
EXPECT_FP_EQ(-5.0, LIBC_NAMESPACE::shared::negsf2(5.0));
+ EXPECT_FP_EQ(2.0f, LIBC_NAMESPACE::shared::subsf3(5.0f, 3.0f));
}
TEST(LlvmLibcSharedBuiltinsTest, AllDouble) {
>From 9818e3e4a40b6642f5f6a212f44ff8414d400969 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 9 Jul 2026 06:41:47 +0300
Subject: [PATCH 10/13] follow new header standard
---
compiler-rt/lib/builtins/adddf3.cpp | 12 +++++++-----
compiler-rt/lib/builtins/addsf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/addtf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/muldf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/mulsf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/multf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/negdf2.cpp | 9 +++++----
compiler-rt/lib/builtins/negsf2.cpp | 9 +++++----
compiler-rt/lib/builtins/subdf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/subsf3.cpp | 10 ++++++----
compiler-rt/lib/builtins/subtf3.cpp | 10 ++++++----
11 files changed, 65 insertions(+), 45 deletions(-)
diff --git a/compiler-rt/lib/builtins/adddf3.cpp b/compiler-rt/lib/builtins/adddf3.cpp
index 89918c9c54607..63d070bab1fc1 100644
--- a/compiler-rt/lib/builtins/adddf3.cpp
+++ b/compiler-rt/lib/builtins/adddf3.cpp
@@ -1,18 +1,20 @@
-//===-- lib/adddf3.cpp - double-precision addition --------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __adddf3 implemented on top of LLVM-libc's shared::adddf3 instruction.
-//
+///
+/// \file
+/// This file implements compiler-rt's __adddf3, double-precision addition, on
+/// top of LLVM-libc's shared::adddf3.
+///
//===----------------------------------------------------------------------===//
+#define DOUBLE_PRECISION
#include "fp_lib.h"
-#define DOUBLE_PRECISION
#include "fp_libc_config.h"
#include "int_lib.h"
#include "shared/builtins/adddf3.h"
diff --git a/compiler-rt/lib/builtins/addsf3.cpp b/compiler-rt/lib/builtins/addsf3.cpp
index bb8704334e6f0..dd54a89e25273 100644
--- a/compiler-rt/lib/builtins/addsf3.cpp
+++ b/compiler-rt/lib/builtins/addsf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/addsf3.cpp - libc-backed __addsf3 -------------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __addsf3 implemented on top of LLVM-libc's shared::addsf3.
-//
+///
+/// \file
+/// This file implements compiler-rt's __addsf3, single-precision addition, on
+/// top of LLVM-libc's shared::addsf3.
+///
//===----------------------------------------------------------------------===//
#define SINGLE_PRECISION
diff --git a/compiler-rt/lib/builtins/addtf3.cpp b/compiler-rt/lib/builtins/addtf3.cpp
index ae4dbd5772cfb..cf4eaee0f64ba 100644
--- a/compiler-rt/lib/builtins/addtf3.cpp
+++ b/compiler-rt/lib/builtins/addtf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/addtf3.cpp - Quad-precision addition (libc-backed) --*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __addtf3 implemented on top of LLVM-libc's shared::addtf3 instruction.
-//
+///
+/// \file
+/// This file implements compiler-rt's __addtf3, quad-precision addition, on top
+/// of LLVM-libc's shared::addtf3.
+///
//===----------------------------------------------------------------------===//
#define QUAD_PRECISION
diff --git a/compiler-rt/lib/builtins/muldf3.cpp b/compiler-rt/lib/builtins/muldf3.cpp
index ec7c1ebe9e3e3..4e654aeb782df 100644
--- a/compiler-rt/lib/builtins/muldf3.cpp
+++ b/compiler-rt/lib/builtins/muldf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/muldf3.cpp - double-precision multiplication --------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __muldf3 implemented on top of LLVM-libc's shared::muldf3 instruction.
-//
+///
+/// \file
+/// This file implements compiler-rt's __muldf3, double-precision
+/// multiplication, on top of LLVM-libc's shared::muldf3.
+///
//===----------------------------------------------------------------------===//
#define DOUBLE_PRECISION
diff --git a/compiler-rt/lib/builtins/mulsf3.cpp b/compiler-rt/lib/builtins/mulsf3.cpp
index d88c8b72078e2..dbc4a483bc44c 100644
--- a/compiler-rt/lib/builtins/mulsf3.cpp
+++ b/compiler-rt/lib/builtins/mulsf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/mulsf3.cpp - libc-backed __mulsf3 -------------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __mulsf3 implemented on top of LLVM-libc's shared::mulsf3.
-//
+///
+/// \file
+/// This file implements compiler-rt's __mulsf3, single-precision
+/// multiplication, on top of LLVM-libc's shared::mulsf3.
+///
//===----------------------------------------------------------------------===//
#define SINGLE_PRECISION
diff --git a/compiler-rt/lib/builtins/multf3.cpp b/compiler-rt/lib/builtins/multf3.cpp
index e8324ca302c6e..ab123f1a5c48a 100644
--- a/compiler-rt/lib/builtins/multf3.cpp
+++ b/compiler-rt/lib/builtins/multf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/multf3.cpp - quad-precision multiplication ----------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __multf3 implemented on top of LLVM-libc's shared::multf3 instruction.
-//
+///
+/// \file
+/// This file implements compiler-rt's __multf3, quad-precision multiplication,
+/// on top of LLVM-libc's shared::multf3.
+///
//===----------------------------------------------------------------------===//
#define QUAD_PRECISION
diff --git a/compiler-rt/lib/builtins/negdf2.cpp b/compiler-rt/lib/builtins/negdf2.cpp
index cc9f190845cf3..44e716dfe8256 100644
--- a/compiler-rt/lib/builtins/negdf2.cpp
+++ b/compiler-rt/lib/builtins/negdf2.cpp
@@ -1,13 +1,14 @@
-//===-- lib/negdf2.cpp - double-precision negation --------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __negdf2 implemented on top of LLVM-libc's shared::negdf2 instruction.
-//
+/// \file
+/// This file implements compiler-rt's __negdf2, double-precision negation,
+/// on top of LLVM-libc's shared::negdf2.
+///
//===----------------------------------------------------------------------===//
#include "fp_lib.h"
diff --git a/compiler-rt/lib/builtins/negsf2.cpp b/compiler-rt/lib/builtins/negsf2.cpp
index 2f23bf64b6b57..4197e3174eae1 100644
--- a/compiler-rt/lib/builtins/negsf2.cpp
+++ b/compiler-rt/lib/builtins/negsf2.cpp
@@ -1,13 +1,14 @@
-//===-- lib/negsf2.cpp - single-precision negation --------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __negsf2 implemented on top of LLVM-libc's shared::negsf2 instruction.
-//
+/// \file
+/// This file implements compiler-rt's __negsf2, single-precision negation,
+/// on top of LLVM-libc's shared::negsf2.
+///
//===----------------------------------------------------------------------===//
#define QUAD_PRECISION
diff --git a/compiler-rt/lib/builtins/subdf3.cpp b/compiler-rt/lib/builtins/subdf3.cpp
index e910a9d10e6e2..1510843179a92 100644
--- a/compiler-rt/lib/builtins/subdf3.cpp
+++ b/compiler-rt/lib/builtins/subdf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/subdf3.cpp - double-precision subtraction -----------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __subdf3 implemented on top of LLVM-libc's shared::subdf3 instruction.
-//
+///
+/// \file
+/// This file implements compiler-rt's __subdf3, double-precision subtraction,
+/// on top of LLVM-libc's shared::subdf3.
+///
//===----------------------------------------------------------------------===//
#define DOUBLE_PRECISION
diff --git a/compiler-rt/lib/builtins/subsf3.cpp b/compiler-rt/lib/builtins/subsf3.cpp
index d1cdebc78ff09..0c334a448402c 100644
--- a/compiler-rt/lib/builtins/subsf3.cpp
+++ b/compiler-rt/lib/builtins/subsf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/subsf3.cpp - libc-backed __subsf3 -------------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __subsf3 implemented on top of LLVM-libc's shared::subsf3.
-//
+///
+/// \file
+/// This file implements compiler-rt's __subsf3, single-precision subtraction,
+/// on top of LLVM-libc's shared::subsf3.
+///
//===----------------------------------------------------------------------===//
#define SINGLE_PRECISION
diff --git a/compiler-rt/lib/builtins/subtf3.cpp b/compiler-rt/lib/builtins/subtf3.cpp
index 0880d12ddc50d..a59bd683fb3b7 100644
--- a/compiler-rt/lib/builtins/subtf3.cpp
+++ b/compiler-rt/lib/builtins/subtf3.cpp
@@ -1,13 +1,15 @@
-//===-- lib/subtf3.cpp - quad-precision subtraction -------------*- 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
//
//===----------------------------------------------------------------------===//
-//
-// __subtf3 implemented on top of LLVM-libc's shared::subtf3 instruction.
-//
+///
+/// \file
+/// This file implements compiler-rt's __subtf3, quad-precision subtraction, on
+/// top of LLVM-libc's shared::subtf3.
+///
//===----------------------------------------------------------------------===//
#define QUAD_PRECISION
>From c183b29c441c1b11dee72652b0b7d91be9386ba9 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 9 Jul 2026 06:51:47 +0300
Subject: [PATCH 11/13] chore
---
libc/test/shared/shared_builtins_test.cpp | 44 ++++++++++++-----------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/libc/test/shared/shared_builtins_test.cpp b/libc/test/shared/shared_builtins_test.cpp
index 97f1d82b3dc3c..12d6338258278 100644
--- a/libc/test/shared/shared_builtins_test.cpp
+++ b/libc/test/shared/shared_builtins_test.cpp
@@ -10,33 +10,35 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-TEST(LlvmLibcSharedBuiltinsTest, AllFloat) {
- EXPECT_FP_EQ(3.0f, LIBC_NAMESPACE::shared::addsf3(1.0f, 2.0f));
- EXPECT_FP_EQ(3.0f, LIBC_NAMESPACE::shared::divsf3(6.0f, 2.0f));
- EXPECT_FP_EQ(6.0f, LIBC_NAMESPACE::shared::mulsf3(2.0f, 3.0f));
- EXPECT_FP_EQ(-5.0, LIBC_NAMESPACE::shared::negsf2(5.0));
- EXPECT_FP_EQ(2.0f, LIBC_NAMESPACE::shared::subsf3(5.0f, 3.0f));
+TEST(LlvmLibcSharedBuiltinsTest, SinglePrecisionArithmtic) {
+ using shared = LIBC_NAMESPACE::shared;
+
+ EXPECT_FP_EQ(3.0f, shared::addsf3(1.0f, 2.0f));
+ EXPECT_FP_EQ(3.0f, shared::divsf3(6.0f, 2.0f));
+ EXPECT_FP_EQ(6.0f, shared::mulsf3(2.0f, 3.0f));
+ EXPECT_FP_EQ(-5.0, shared::negsf2(5.0));
+ EXPECT_FP_EQ(2.0f, shared::subsf3(5.0f, 3.0f));
}
-TEST(LlvmLibcSharedBuiltinsTest, AllDouble) {
- EXPECT_FP_EQ(3.0, LIBC_NAMESPACE::shared::adddf3(1.0, 2.0));
- EXPECT_FP_EQ(3.0, LIBC_NAMESPACE::shared::divdf3(6.0, 2.0));
- EXPECT_FP_EQ(6.0, LIBC_NAMESPACE::shared::muldf3(2.0, 3.0));
- EXPECT_FP_EQ(5.0, LIBC_NAMESPACE::shared::negdf2(-5.0));
- EXPECT_FP_EQ(2.0, LIBC_NAMESPACE::shared::subdf3(5.0, 3.0));
+TEST(LlvmLibcSharedBuiltinsTest, DoublePrecisionArithmtic) {
+ using shared = LIBC_NAMESPACE::shared;
+
+ EXPECT_FP_EQ(3.0, shared::adddf3(1.0, 2.0));
+ EXPECT_FP_EQ(3.0, shared::divdf3(6.0, 2.0));
+ EXPECT_FP_EQ(6.0, shared::muldf3(2.0, 3.0));
+ EXPECT_FP_EQ(5.0, shared::negdf2(-5.0));
+ EXPECT_FP_EQ(2.0, shared::subdf3(5.0, 3.0));
}
#ifdef LIBC_TYPES_HAS_FLOAT128
-TEST(LlvmLibcSharedBuiltinsTest, AllFloat128) {
- EXPECT_FP_EQ(float128(3.0),
- LIBC_NAMESPACE::shared::addtf3(float128(1.0), float128(2.0)));
- EXPECT_FP_EQ(float128(3.0),
- LIBC_NAMESPACE::shared::divtf3(float128(6.0), float128(2.0)));
- EXPECT_FP_EQ(float128(6.0),
- LIBC_NAMESPACE::shared::multf3(float128(2.0), float128(3.0)));
- EXPECT_FP_EQ(float128(2.0),
- LIBC_NAMESPACE::shared::subtf3(float128(5.0), float128(3.0)));
+TEST(LlvmLibcSharedBuiltinsTest, QuadPrecisionArithmtic) {
+ using shared = LIBC_NAMESPACE::shared;
+
+ EXPECT_FP_EQ(float128(3.0), shared::addtf3(float128(1.0), float128(2.0)));
+ EXPECT_FP_EQ(float128(3.0), shared::divtf3(float128(6.0), float128(2.0)));
+ EXPECT_FP_EQ(float128(6.0), shared::multf3(float128(2.0), float128(3.0)));
+ EXPECT_FP_EQ(float128(2.0), shared::subtf3(float128(5.0), float128(3.0)));
}
#endif // LIBC_TYPES_HAS_FLOAT128
>From 21524dbc6707941cc9149196d87630c41c971778 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 9 Jul 2026 09:24:04 +0300
Subject: [PATCH 12/13] wrong flags
---
compiler-rt/lib/builtins/negdf2.cpp | 1 +
compiler-rt/lib/builtins/negsf2.cpp | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/builtins/negdf2.cpp b/compiler-rt/lib/builtins/negdf2.cpp
index 44e716dfe8256..6b8dbc96edcbf 100644
--- a/compiler-rt/lib/builtins/negdf2.cpp
+++ b/compiler-rt/lib/builtins/negdf2.cpp
@@ -11,6 +11,7 @@
///
//===----------------------------------------------------------------------===//
+#define DOUBLE_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
diff --git a/compiler-rt/lib/builtins/negsf2.cpp b/compiler-rt/lib/builtins/negsf2.cpp
index 4197e3174eae1..2f554d13ad1a7 100644
--- a/compiler-rt/lib/builtins/negsf2.cpp
+++ b/compiler-rt/lib/builtins/negsf2.cpp
@@ -11,7 +11,7 @@
///
//===----------------------------------------------------------------------===//
-#define QUAD_PRECISION
+#define SINGLE_PRECISION
#include "fp_lib.h"
#include "fp_libc_config.h"
>From 277618bf4db01d4a6b79f598dd6a20058da26362 Mon Sep 17 00:00:00 2001
From: hulxv <hulxxv at gmail.com>
Date: Thu, 9 Jul 2026 09:24:19 +0300
Subject: [PATCH 13/13] cleanup the test
---
libc/test/shared/shared_builtins_test.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/libc/test/shared/shared_builtins_test.cpp b/libc/test/shared/shared_builtins_test.cpp
index 12d6338258278..bece0d68d737f 100644
--- a/libc/test/shared/shared_builtins_test.cpp
+++ b/libc/test/shared/shared_builtins_test.cpp
@@ -10,9 +10,9 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
-TEST(LlvmLibcSharedBuiltinsTest, SinglePrecisionArithmtic) {
- using shared = LIBC_NAMESPACE::shared;
+using shared = LIBC_NAMESPACE::shared;
+TEST(LlvmLibcSharedBuiltinsTest, SinglePrecisionArithmtic) {
EXPECT_FP_EQ(3.0f, shared::addsf3(1.0f, 2.0f));
EXPECT_FP_EQ(3.0f, shared::divsf3(6.0f, 2.0f));
EXPECT_FP_EQ(6.0f, shared::mulsf3(2.0f, 3.0f));
@@ -21,8 +21,6 @@ TEST(LlvmLibcSharedBuiltinsTest, SinglePrecisionArithmtic) {
}
TEST(LlvmLibcSharedBuiltinsTest, DoublePrecisionArithmtic) {
- using shared = LIBC_NAMESPACE::shared;
-
EXPECT_FP_EQ(3.0, shared::adddf3(1.0, 2.0));
EXPECT_FP_EQ(3.0, shared::divdf3(6.0, 2.0));
EXPECT_FP_EQ(6.0, shared::muldf3(2.0, 3.0));
@@ -33,8 +31,6 @@ TEST(LlvmLibcSharedBuiltinsTest, DoublePrecisionArithmtic) {
#ifdef LIBC_TYPES_HAS_FLOAT128
TEST(LlvmLibcSharedBuiltinsTest, QuadPrecisionArithmtic) {
- using shared = LIBC_NAMESPACE::shared;
-
EXPECT_FP_EQ(float128(3.0), shared::addtf3(float128(1.0), float128(2.0)));
EXPECT_FP_EQ(float128(3.0), shared::divtf3(float128(6.0), float128(2.0)));
EXPECT_FP_EQ(float128(6.0), shared::multf3(float128(2.0), float128(3.0)));
More information about the libc-commits
mailing list