aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-07-08 12:01:30 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2015-07-08 12:01:30 +0200
commitab1ddcd0d579d7e5760c6cfa84adbd55212c47e7 (patch)
tree207e3b1e59da7247d95d28d6ffdd6f4e93bdfc4c /test/regression
parent4148ee08387bf953bdbe69f7668597ec0bcccc29 (diff)
downloadcompcert-kvx-ab1ddcd0d579d7e5760c6cfa84adbd55212c47e7.tar.gz
compcert-kvx-ab1ddcd0d579d7e5760c6cfa84adbd55212c47e7.zip
More portable test for fres and fsqrte.
These instructions are approximate and produce different results on different processors. Just check the error bounds specified in the PPC ISA.
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/Results/builtins-powerpc4
-rw-r--r--test/regression/builtins-powerpc.c13
-rw-r--r--test/regression/sections.c6
3 files changed, 16 insertions, 7 deletions
diff --git a/test/regression/Results/builtins-powerpc b/test/regression/Results/builtins-powerpc
index ac4240a8..0fd07f69 100644
--- a/test/regression/Results/builtins-powerpc
+++ b/test/regression/Results/builtins-powerpc
@@ -8,8 +8,8 @@ fmsub(3.141590, 2.718000, 1.414000) = 7.124842
fabs(3.141590) = 3.141590
fabs(-3.141590) = 3.141590
fsqrt(3.141590) = 1.772453
-frsqrte(3.141590) = 0.564198
-fres(3.141590) = 0.318311
+frsqrte(3.141590) = OK
+fres(3.141590) = OK
fsel(3.141590, 2.718000, 1.414000) = 2.718000
fsel(-3.141590, 2.718000, 1.414000) = 1.414000
fcti(3.141590) = 3
diff --git a/test/regression/builtins-powerpc.c b/test/regression/builtins-powerpc.c
index 17d4d3c5..acffa435 100644
--- a/test/regression/builtins-powerpc.c
+++ b/test/regression/builtins-powerpc.c
@@ -1,6 +1,13 @@
/* Fun with builtins */
#include <stdio.h>
+#include <math.h>
+
+char * check_relative_error(double exact, double actual, double precision)
+{
+ double relative_error = (actual - exact) / exact;
+ return fabs(relative_error) <= precision ? "OK" : "ERROR";
+}
int main(int argc, char ** argv)
{
@@ -22,8 +29,10 @@ int main(int argc, char ** argv)
printf("fabs(%f) = %f\n", a, __builtin_fabs(a));
printf("fabs(%f) = %f\n", -a, __builtin_fabs(-a));
printf("fsqrt(%f) = %f\n", a, __builtin_fsqrt(a));
- printf("frsqrte(%f) = %f\n", a, __builtin_frsqrte(a));
- printf("fres(%f) = %f\n", a, __builtin_fres(a));
+ printf("frsqrte(%f) = %s\n",
+ a, check_relative_error(1.0 / sqrt(a), __builtin_frsqrte(a), 1./32.));
+ printf("fres(%f) = %s\n",
+ a, check_relative_error(1.0 / a, __builtin_fres(a), 1./256.));
printf("fsel(%f, %f, %f) = %f\n", a, b, c, __builtin_fsel(a, b, c));
printf("fsel(%f, %f, %f) = %f\n", -a, b, c, __builtin_fsel(-a, b, c));
printf("fcti(%f) = %d\n", a, __builtin_fcti(a));
diff --git a/test/regression/sections.c b/test/regression/sections.c
index 2e0e4e75..adf94e83 100644
--- a/test/regression/sections.c
+++ b/test/regression/sections.c
@@ -13,14 +13,14 @@ struct s {
long long ll;
};
-struct s x; /* normal absolute addressing */
+struct s x = {0, }; /* normal absolute addressing */
#pragma use_section SDATA y
-struct s y; /* small data area */
+struct s y = {0, }; /* small data area */
#pragma section MYDATA ".mydata" ".mydata" far-data RW
#pragma use_section MYDATA z
-struct s z; /* far data area, relative addressing */
+struct s z = {0, }; /* far data area, relative addressing */
#define TEST(msg,ty,x,v1,v2,v3) \
x = v1; \