]> sourceware.org Git - valgrind.git/commitdiff
regtest arm64: add a test for frinta and frintn
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 13 Apr 2024 16:19:25 +0000 (18:19 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 13 Apr 2024 16:19:25 +0000 (18:19 +0200)
Round ties above 0 (frinta) and to even (frintn). Both only scalar.
Vector not yet implemented.

.gitignore
none/tests/arm64/Makefile.am
none/tests/arm64/frinta_frintn.cpp [new file with mode: 0644]
none/tests/arm64/frinta_frintn.stderr.exp [new file with mode: 0644]
none/tests/arm64/frinta_frintn.vgtest [new file with mode: 0644]

index 3623378acd6cf4e025cd77269b3e0f0248beae40..1491b8943302f6398d804717aff2e62a9aa0ae42 100644 (file)
 /none/tests/arm64/fmadd_sub
 /none/tests/arm64/fp_and_simd
 /none/tests/arm64/fp_and_simd_v82
+/none/tests/arm64/frinta_frintn
 /none/tests/arm64/ldxp_stxp
 /none/tests/arm64/integer
 /none/tests/arm64/memory_test
index 8aadd42ebb5102524948ef561422f9b266ba7dee..52665a7f05865b8f18fc2da398c6f5b60c35e2f7 100644 (file)
@@ -8,6 +8,7 @@ EXTRA_DIST = \
         crc32.stdout.exp crc32.stderr.exp crc32.vgtest \
         cvtf_imm.stdout.exp cvtf_imm.stderr.exp cvtf_imm.vgtest \
        fp_and_simd.stdout.exp fp_and_simd.stderr.exp fp_and_simd.vgtest \
+       frinta_frintn.stderr.exp frinta_frintn.vgtest \
        integer.stdout.exp integer.stderr.exp integer.vgtest \
        memory_test.stdout.exp memory_test.stderr.exp memory_test.vgtest \
                memory_test.stdout.exp-clang \
@@ -44,6 +45,10 @@ if BUILD_ARMV82_TESTS
   check_PROGRAMS += fp_and_simd_v82
 endif
 
+if HAVE_CXX17
+  check_PROGRAMS += frinta_frintn
+endif
+
 if BUILD_ARMV82_DOTPROD_TESTS
   check_PROGRAMS += simd_dotprod
 endif
@@ -63,6 +68,8 @@ simd_v81_CFLAGS    = $(AM_CFLAGS) -march=armv8.1-a+crypto
 simd_dotprod_CFLAGS    = $(AM_CFLAGS) -march=armv8.2-a+dotprod
 fp_and_simd_CFLAGS = $(AM_CFLAGS) -march=armv8-a+crypto
 fp_and_simd_v82_CFLAGS = $(AM_CFLAGS) -march=armv8.2-a+fp16+crypto
+frinta_frintn_SOURCES  = frinta_frintn.cpp
+frinta_frintn_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17
 integer_CFLAGS     = $(AM_CFLAGS) -g -O0 -DTEST_BFM=0
 
 fp_and_simd_LDADD  = -lm
diff --git a/none/tests/arm64/frinta_frintn.cpp b/none/tests/arm64/frinta_frintn.cpp
new file mode 100644 (file)
index 0000000..8e13761
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * An extra testcase for bug484426
+ * The testcase supplied only tests single precision frinta
+ */
+
+#include <type_traits>
+#include <cassert>
+
+template<typename T>
+void test_frinta(T input, T expected)
+{
+    T result;
+    T* rp(&result);
+    T* ip(&input);
+    if constexpr (std::is_same_v<double, T> == true)
+    {
+     __asm__ __volatile__(
+         "ldr d0, [%1];\n"
+         "frinta d0, d0;\n"
+         "str d0, [%0];\n"
+         : "+rm" (rp)
+         : "r" (ip)
+         : "memory", "d0");
+       assert(result == expected);
+   }
+   else
+   {
+    __asm__ __volatile__(
+         "ldr s0, [%1];\n"
+         "frinta s0, s0;\n"
+         "str s0, [%0];\n"
+         : "+rm" (rp)
+         : "r" (ip)
+         : "memory", "s0");
+       assert(result == expected);
+   }
+}
+
+template<typename T>
+void test_frintn(T input, T expected)
+{
+    T result;
+    T* rp(&result);
+    T* ip(&input);
+    if constexpr (std::is_same_v<double, T> == true)
+    {
+     __asm__ __volatile__(
+         "ldr d0, [%1];\n"
+         "frintn d0, d0;\n"
+         "str d0, [%0];\n"
+         : "+rm" (rp)
+         : "r" (ip)
+         : "memory", "d0");
+       assert(result == expected);
+   }
+   else
+   {
+    __asm__ __volatile__(
+         "ldr s0, [%1];\n"
+         "frintn s0, s0;\n"
+         "str s0, [%0];\n"
+         : "+rm" (rp)
+         : "r" (ip)
+         : "memory", "s0");
+       assert(result == expected);
+   }
+}
+
+int main()
+{
+    // round "away from zero"
+    test_frinta(1.5, 2.0);
+    test_frinta(2.5, 3.0);
+    test_frinta(-1.5, -2.0);
+    test_frinta(-2.5, -3.0);
+    test_frinta(1.5F, 2.0F);
+    test_frinta(2.5F, 3.0F);
+    test_frinta(-1.5F, -2.0F);
+    test_frinta(-2.5F, -3.0F);
+
+    // round "to even"
+    test_frintn(1.5, 2.0);
+    test_frintn(2.5, 2.0);
+    test_frintn(-1.5, -2.0);
+    test_frintn(-2.5, -2.0);
+    test_frintn(1.5F, 2.0F);
+    test_frintn(2.5F, 2.0F);
+    test_frintn(-1.5F, -2.0F);
+    test_frintn(-2.5F, -2.0F);
+}
+
diff --git a/none/tests/arm64/frinta_frintn.stderr.exp b/none/tests/arm64/frinta_frintn.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/arm64/frinta_frintn.vgtest b/none/tests/arm64/frinta_frintn.vgtest
new file mode 100644 (file)
index 0000000..7470a2c
--- /dev/null
@@ -0,0 +1,3 @@
+prereq: test -x frinta_frintn
+prog: frinta_frintn
+vgopts: -q
This page took 0.043259 seconds and 5 git commands to generate.