]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add regtest for #132918 (amd64 fprem).
authorJulian Seward <jseward@acm.org>
Mon, 11 Sep 2006 11:05:26 +0000 (11:05 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 11 Sep 2006 11:05:26 +0000 (11:05 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6046

none/tests/amd64/Makefile.am
none/tests/amd64/bug132918.c [new file with mode: 0644]
none/tests/amd64/bug132918.stderr.exp [new file with mode: 0644]
none/tests/amd64/bug132918.stdout.exp [new file with mode: 0644]
none/tests/amd64/bug132918.vgtest [new file with mode: 0644]

index 797a89b427a1ee8735dd7b1e923a8b7f798bb703..1950e1a690d27bf0e9545b82bcaf4317e71c24ec 100644 (file)
@@ -8,6 +8,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        bug127521-64.vgtest bug127521-64.stdout.exp bug127521-64.stderr.exp \
        bug132813-amd64.vgtest bug132813-amd64.stdout.exp \
        bug132813-amd64.stderr.exp \
+       bug132918.vgtest bug132918.stderr.exp bug132918.stdout.exp \
        clc.vgtest clc.stdout.exp clc.stderr.exp \
        faultstatus.disabled faultstatus.stderr.exp \
        fcmovnu.vgtest fcmovnu.stderr.exp fcmovnu.stdout.exp \
@@ -24,7 +25,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
 
 
 check_PROGRAMS = \
-       bug127521-64 bug132813-amd64 \
+       bug127521-64 bug132813-amd64 bug132918 \
        clc \
        faultstatus fcmovnu fxtract $(INSN_TESTS) looper jrcxz smc1 shrld \
        nibz_bennee_mmap
@@ -34,6 +35,7 @@ AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include
 AM_CXXFLAGS = $(AM_CFLAGS)
 
 # generic C ones
+bug132918_LDADD                = -lm
 insn_basic_SOURCES     = insn_basic.def
 insn_basic_LDADD       = -lm
 insn_mmx_SOURCES       = insn_mmx.def
diff --git a/none/tests/amd64/bug132918.c b/none/tests/amd64/bug132918.c
new file mode 100644 (file)
index 0000000..77eefd0
--- /dev/null
@@ -0,0 +1,55 @@
+
+#include <stdio.h>
+#include <math.h>
+
+typedef unsigned long long int ULong;
+
+typedef
+   struct { double d; int i; } Res;
+
+static void do_fprem ( Res* res, double x, double y )
+{
+  ULong c3210;
+  double f64;
+  double xx = x;
+  double yy = y;
+  __asm__ __volatile__(
+     "finit\n\t"
+     "fldl    %2\n\t"
+     "fldl    %3\n\t"
+     "fprem\n\t"
+     "fstpl   %1\n\t"
+     "movq    %%rax,%%r15\n\t"
+     "xorq    %%rax,%%rax\n\t"
+     "fnstsw  %%ax\n\t"
+     "movq    %%rax,%0\n\t"
+     "movq    %%r15,%%rax"
+     : /*out*/ "=r" (c3210)
+     : /*in*/  "m" (f64), "m" (xx), "m" (yy)
+     : /*trash*/ "r15", "rax", "%st", "%st(1)", "cc"
+   );
+  res->d = f64;
+  res->i = (int)(c3210 & 0x4700); /* mask for C3,2,1,0 */
+}
+
+static void show ( char* s, Res* res )
+{
+  printf("%s -> 0x%04x %f\n", s, (int)res->i, (double)res->d);
+}
+
+int main ( void )
+{
+  Res r;
+  int i;
+  double theta;
+  do_fprem(&r, 10.1, 200.2); show("xx1", &r);
+  do_fprem(&r, 20.3, 1.44);  show("xx2", &r);
+
+  for (i = 0; i < 20; i++) {
+    theta = (2.0 * 3.14159) / 10.0 * (double)i;
+    do_fprem(&r, 12.3*sin(theta), cos(theta)); show("xx", &r);
+  }
+
+  return 0;
+}
diff --git a/none/tests/amd64/bug132918.stderr.exp b/none/tests/amd64/bug132918.stderr.exp
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/none/tests/amd64/bug132918.stdout.exp b/none/tests/amd64/bug132918.stdout.exp
new file mode 100644 (file)
index 0000000..9427c84
--- /dev/null
@@ -0,0 +1,22 @@
+xx1 -> 0x4200 8.300000
+xx2 -> 0x0000 1.440000
+xx -> 0x0000 nan
+xx -> 0x0000 0.809017
+xx -> 0x0000 0.309018
+xx -> 0x0000 -0.309015
+xx -> 0x0000 -0.809016
+xx -> 0x4100 -0.000002
+xx -> 0x0000 -0.809019
+xx -> 0x0000 -0.309021
+xx -> 0x0000 0.309013
+xx -> 0x0000 0.809014
+xx -> 0x4300 0.000002
+xx -> 0x0000 0.809020
+xx -> 0x0000 0.309023
+xx -> 0x0000 -0.309010
+xx -> 0x0000 -0.809013
+xx -> 0x0100 -0.000067
+xx -> 0x0000 -0.809022
+xx -> 0x0000 -0.309026
+xx -> 0x0000 0.309008
+xx -> 0x0000 0.809011
diff --git a/none/tests/amd64/bug132918.vgtest b/none/tests/amd64/bug132918.vgtest
new file mode 100644 (file)
index 0000000..7bfbf95
--- /dev/null
@@ -0,0 +1 @@
+prog: bug132918