]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 485148 - vfmadd213ss instruction is instrumented incorrectly (the remaining part...
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 14 Apr 2024 15:59:30 +0000 (17:59 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 14 Apr 2024 19:21:35 +0000 (21:21 +0200)
Initial version contributed by Bruno Lathuilière <bruno.lathuiliere@edf.fr>
Initial test contributed by Petr <kobalicek.petr@gmail.com>

.gitignore
NEWS
VEX/priv/guest_amd64_toIR.c
none/tests/amd64/Makefile.am
none/tests/amd64/bug485148.cpp [new file with mode: 0644]
none/tests/amd64/bug485148.stderr.exp [new file with mode: 0644]
none/tests/amd64/bug485148.stdout.exp [new file with mode: 0644]
none/tests/amd64/bug485148.vgtest [new file with mode: 0644]

index 1491b8943302f6398d804717aff2e62a9aa0ae42..b242eb6e2922cc97d135c9775dc7fbd247560f39 100644 (file)
 /none/tests/amd64/bug132918
 /none/tests/amd64/bug137714-amd64
 /none/tests/amd64/bug156404-amd64
+/none/tests/amd64/bug485148
 /none/tests/amd64/cet_nops
 /none/tests/amd64/clc
 /none/tests/amd64/cmpxchg
diff --git a/NEWS b/NEWS
index 705e17be238125f405d43856229209b57694d5f5..8f5ac0c9c80d181cb0f47534c1da4001e0a58687 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -89,6 +89,8 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 484480  False positives when using sem_trywait
 484935  [patch] Valgrind reports false "Conditional jump or move depends on
         uninitialised value" errors for aarch64 signal handlers
+485148  vfmadd213ss instruction is instrumented incorrectly (the remaining
+        part of the register is cleared instead of kept unmodified)
 n-i-bz  Add redirect for memccpy
 
 To see details of a given bug, visit
index d7c25042d2488c98cd473170b7d915abd8b0871f..f0b1c55162677546a73f5a967f090b561dcac4f6 100644 (file)
@@ -27989,8 +27989,8 @@ static Long dis_FMA ( const VexAbiInfo* vbi, Prefix pfx, Long delta, UChar opc )
    }
 
    switch (vty) {
-      case Ity_F32:  putYMMRegLane32(rG, 1, mkU32(0)); /*fallthru*/
-      case Ity_F64:  putYMMRegLane64(rG, 1, mkU64(0)); /*fallthru*/
+      case Ity_F32:
+      case Ity_F64:
       case Ity_V128: putYMMRegLane128(rG, 1, mkV128(0)); /*fallthru*/
       case Ity_V256: break;
       default: vassert(0);
index 2e688e3ca73ac2a55bbdd7dd8d47f14bfa8616c9..dc0498018209ac479a40072557196a225bcdb8b5 100644 (file)
@@ -43,6 +43,7 @@ EXTRA_DIST = \
        bug132918.stdout.exp-older-glibc \
        bug156404-amd64.vgtest bug156404-amd64.stdout.exp \
        bug156404-amd64.stderr.exp \
+       bug485148.vgtest bug485148.stdout.exp bug485148.stderr.exp \
        cet_nops.vgtest cet_nops.stdout.exp cet_nops.stderr.exp \
        clc.vgtest clc.stdout.exp clc.stderr.exp \
        crc32.vgtest crc32.stdout.exp crc32.stderr.exp \
@@ -160,7 +161,7 @@ if BUILD_BMI_TESTS
  check_PROGRAMS += bmi
 endif
 if BUILD_FMA_TESTS
- check_PROGRAMS += fma
+ check_PROGRAMS += fma bug485148
 endif
 if BUILD_MPX_TESTS
  check_PROGRAMS += mpx
@@ -201,6 +202,8 @@ allexec_CFLAGS              = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
 # generic C ones
 amd64locked_CFLAGS     = $(AM_CFLAGS) -O
 bug132918_LDADD                = -lm
+bug485148_CXXFLAGS      = ${AM_CXXFLAGS} -mfma
+bug485148_SOURCES       = bug485148.cpp
 cmpxchg_CFLAGS         = $(AM_CFLAGS) @FLAG_NO_PIE@
 fb_test_amd64_CFLAGS   = $(AM_CFLAGS) -O -fno-strict-aliasing
 fb_test_amd64_LDADD    = -lm
diff --git a/none/tests/amd64/bug485148.cpp b/none/tests/amd64/bug485148.cpp
new file mode 100644 (file)
index 0000000..bed8de8
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <x86intrin.h>
+
+static __attribute__((noinline)) void
+test_fma_ss(float dst[4], const float a[4], const float b[4], const float c[4])
+{
+   __m128 av = _mm_loadu_ps(a);
+   __m128 bv = _mm_loadu_ps(b);
+   __m128 cv = _mm_loadu_ps(c);
+
+   __m128 dv = _mm_fmadd_ss(av, bv, cv);
+   _mm_storeu_ps(dst, dv);
+}
+
+static __attribute__((noinline)) void
+test_fma_sd(double dst[2], const double a[2], const double b[2], const double c[2])
+{
+   __m128d av = _mm_loadu_pd(a);
+   __m128d bv = _mm_loadu_pd(b);
+   __m128d cv = _mm_loadu_pd(c);
+
+   __m128d dv = _mm_fmadd_sd(av, bv, cv);
+   _mm_storeu_pd(dst, dv);
+}
+
+int main()
+{
+   float a[4] = {1, 2, 3, 4};
+   float b[4] = {3, 11, 35, 1};
+   float c[4] = {-1, -2, -19, 0};
+
+   float dst_f[4];
+   test_fma_ss(dst_f, a, b, c);
+
+   printf("[%f %f %f %f]\n", dst_f[0], dst_f[1], dst_f[2], dst_f[3]);
+
+   double d[2] = {5, 6};
+   double e[2] = {2, 18};
+   double f[2] = {3, 15};
+
+   double dst_d[2];
+   test_fma_sd(dst_d, d, e, f);
+
+   printf("[%f %f]\n", dst_d[0], dst_d[1]);
+}
diff --git a/none/tests/amd64/bug485148.stderr.exp b/none/tests/amd64/bug485148.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/amd64/bug485148.stdout.exp b/none/tests/amd64/bug485148.stdout.exp
new file mode 100644 (file)
index 0000000..23d8310
--- /dev/null
@@ -0,0 +1,2 @@
+[2.000000 2.000000 3.000000 4.000000]
+[13.000000 6.000000]
diff --git a/none/tests/amd64/bug485148.vgtest b/none/tests/amd64/bug485148.vgtest
new file mode 100644 (file)
index 0000000..dbbedc6
--- /dev/null
@@ -0,0 +1,3 @@
+prog: bug485148
+prereq: test -x bug485148 && ../../../tests/x86_amd64_features amd64-avx
+vgopts: -q