From: Julian Seward Date: Mon, 11 Sep 2006 11:05:26 +0000 (+0000) Subject: Add regtest for #132918 (amd64 fprem). X-Git-Tag: svn/VALGRIND_3_3_0~685 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=12affe3595400e8afbd5e250a625f9e5fed0d9ca;p=thirdparty%2Fvalgrind.git Add regtest for #132918 (amd64 fprem). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6046 --- diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am index 797a89b427..1950e1a690 100644 --- a/none/tests/amd64/Makefile.am +++ b/none/tests/amd64/Makefile.am @@ -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 index 0000000000..77eefd0136 --- /dev/null +++ b/none/tests/amd64/bug132918.c @@ -0,0 +1,55 @@ + +#include +#include + +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 index 0000000000..139597f9cb --- /dev/null +++ b/none/tests/amd64/bug132918.stderr.exp @@ -0,0 +1,2 @@ + + diff --git a/none/tests/amd64/bug132918.stdout.exp b/none/tests/amd64/bug132918.stdout.exp new file mode 100644 index 0000000000..9427c84c95 --- /dev/null +++ b/none/tests/amd64/bug132918.stdout.exp @@ -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 index 0000000000..7bfbf95dd4 --- /dev/null +++ b/none/tests/amd64/bug132918.vgtest @@ -0,0 +1 @@ +prog: bug132918