[libc-commits] [libc] [libc][mathvec] Initial commit for LIBC vector math component (PR #173058)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed Jan 14 07:27:20 PST 2026
================
@@ -0,0 +1,133 @@
+//===-- Unittests for expf ------------------------------------------------===//
+//
+// 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 "hdr/math_macros.h"
+#include "src/__support/CPP/simd.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/math/expf.h"
+#include "src/mathvec/expf.h"
+#include "test/UnitTest/SIMDMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "hdr/stdint_proxy.h"
+
+using LlvmLibcVecExpfTest = LIBC_NAMESPACE::testing::FPTest<float>;
+
+// Wrappers
+
+// In order to test vector we can either duplicate a scalar input
+// or do something more elaborate. In any case that requires a wrapper
+// since the function call is written in this file.
+
+// Run reference on a vector with lanes duplicated from a scalar input.
+
+// with control lane
+static LIBC_NAMESPACE::cpp::simd<float> wrap_ref_vexpf(float x, float control) {
+ LIBC_NAMESPACE::cpp::simd<float> v(x);
+ v[0] = control;
+ constexpr size_t N = LIBC_NAMESPACE::cpp::internal::native_vector_size<float>;
+ for (size_t i = 0; i < N; i++) {
+ v[i] = LIBC_NAMESPACE::expf(v[i]);
----------------
SchrodingerZhu wrote:
elide braces
https://github.com/llvm/llvm-project/pull/173058
More information about the libc-commits
mailing list