aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-28 12:50:20 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-04-28 12:50:20 +0200
commita5ae2da4c92214bc202f70cbcff6f871156ce633 (patch)
tree7013e6d778cc5c7140e97ce5060b5afdf6aa19dd
parent6d1223d053f1ff10792d5ed5d00d3830ff61e9d7 (diff)
downloadcompcert-kvx-a5ae2da4c92214bc202f70cbcff6f871156ce633.tar.gz
compcert-kvx-a5ae2da4c92214bc202f70cbcff6f871156ce633.zip
more insf detection
-rw-r--r--test/monniaux/math/exceptions.c42
-rw-r--r--test/monniaux/rules.mk4
2 files changed, 37 insertions, 9 deletions
diff --git a/test/monniaux/math/exceptions.c b/test/monniaux/math/exceptions.c
index 72107066..5d669510 100644
--- a/test/monniaux/math/exceptions.c
+++ b/test/monniaux/math/exceptions.c
@@ -18,11 +18,15 @@ int feclearexcept(int excepts) {
}
#endif
-double add(double x, double y) {
+double add_double(double x, double y) {
return x+y;
}
-double mul(double x, double y) {
+double mul_double(double x, double y) {
+ return x*y;
+}
+
+float mul_float(float x, float y) {
return x*y;
}
@@ -45,16 +49,16 @@ unsigned double2uint(double x) {
int main() {
printf("%x\n", fetestexcept(FE_ALL_EXCEPT));
- double v1 = add(3.0, 0.1);
+ double v1 = add_double(3.0, 0.1);
printf("%x\n", fetestexcept(FE_ALL_EXCEPT));
feclearexcept(FE_INEXACT);
printf("%x\n", fetestexcept(FE_ALL_EXCEPT));
- double v2 = mul(DBL_MAX, DBL_MAX);
+ double v2 = mul_double(DBL_MAX, DBL_MAX);
printf("%g %x\n", v2, fetestexcept(FE_ALL_EXCEPT));
feclearexcept(FE_ALL_EXCEPT);
- double v3 = mul(DBL_MIN, DBL_MIN);
+ double v3 = mul_double(DBL_MIN, DBL_MIN);
printf("%g %x\n", v3, fetestexcept(FE_ALL_EXCEPT));
feclearexcept(FE_ALL_EXCEPT);
@@ -67,18 +71,42 @@ int main() {
feclearexcept(FE_ALL_EXCEPT);
double v6 = ulong2double(0x11217763AFF77C7CUL);
- printf("%g %x\n", v6, fetestexcept(FE_ALL_EXCEPT)); // BUG 0 should have INEXACT
+ printf("%a %x\n", v6, fetestexcept(FE_ALL_EXCEPT)); // BUG 0 should have INEXACT; correct on x86
+ feclearexcept(FE_ALL_EXCEPT);
+
+ double v6b = ulong2double(0xFFFFFFFFFFFFFFFFUL);
+ printf("%a %x\n", v6b, fetestexcept(FE_ALL_EXCEPT)); // BUG 0 should have INEXACT; correct on x86
feclearexcept(FE_ALL_EXCEPT);
unsigned v7 = double2uint(-0.25); // softfloat says "0 and inexact" but here we have "0 and overflow" (due to negative input for unsigned?)
+ // unsure if (unsigned) (-0.25) should be 0 or an error
+ // BUG C99 annex F says that the error is invalid op not overflow
printf("%u %x\n", v7, fetestexcept(FE_ALL_EXCEPT));
feclearexcept(FE_ALL_EXCEPT);
- // +41F.307672C5496EF
+ // +41F.307672C5496EF in Berkeley Soft Float test
double d8 = 0x1.307672C5496EFp32;
unsigned v8 = double2uint(d8);
printf("%g %x %x\n", d8, v8, fetestexcept(FE_ALL_EXCEPT));
// BUG reports 307672C5 and inexact, but should report overflow
// bug comes from x86 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89175
feclearexcept(FE_ALL_EXCEPT);
+ // all f64_to_ui32_rx_minMag errors explained by
+ // 1) round to uin64 2) take 32 low order bits no precautions
+
+ double d8b = 0x1.307672C5496EFp70;
+ unsigned v8b = double2uint(d8b);
+ printf("d8b %g %x %x\n", d8b, v8b, fetestexcept(FE_ALL_EXCEPT));
+ feclearexcept(FE_ALL_EXCEPT);
+
+ // +380.FFFFFFFFFFFFF => +01.000000 ...ux expected +01.000000 ....x
+ // Bug in soft float?
+ double v9 = double2float(0x1.FFFFFFFFFFFFFp-127);
+ printf("%a %x\n", v9, fetestexcept(FE_ALL_EXCEPT));
+ feclearexcept(FE_ALL_EXCEPT);
+
+ // +00.7FFFFF +7F.000001 => +01.000000 ...ux expected +01.000000 ....x
+ float v10 = mul_float(0x0.7FFFFFp-126, 0x1.000001p+0);
+ printf("%a %x\n", v10, fetestexcept(FE_ALL_EXCEPT));
+ feclearexcept(FE_ALL_EXCEPT);
}
diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk
index 69950d7f..6254cab8 100644
--- a/test/monniaux/rules.mk
+++ b/test/monniaux/rules.mk
@@ -2,10 +2,10 @@ ALL_CCOMPFLAGS=-fno-unprototyped
CCOMP=ccomp
CCOMPFLAGS=-g -O3 -Wall $(ALL_CCOMPFLAGS) $(ALL_CFLAGS)
-CFLAGS=-g -std=c99 -O3 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS)
+CFLAGS=-g -std=c99 -O0 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS)
K1C_CC=k1-mbr-gcc
-K1C_CFLAGS =-g -std=c99 -O2 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS)
+K1C_CFLAGS =-g -std=c99 -O0 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS)
K1C_CCOMP = ../../../ccomp
K1C_CCOMPFLAGS=-O3 -Wall $(ALL_CCOMPFLAGS) $(ALL_CFLAGS) # -fpostpass-ilp