Blame src/math/fmaf.c

nsz 588927
#include <stdint.h>
nsz 588927
#include <stdio.h>
Szabolcs Nagy cfa23c
#include "mtest.h"
nsz 588927
nsz 588927
static struct fff_f t[] = {
nsz 588927
#include "sanity/fmaf.h"
Szabolcs Nagy f3f0ff
#include "special/fmaf.h"
nsz 588927
};
nsz 588927
nsz 588927
int main(void)
nsz 588927
{
nsz 588927
	#pragma STDC FENV_ACCESS ON
nsz 588927
	float y;
nsz 588927
	float d;
nsz 588927
	int e, i, err = 0;
nsz 588927
	struct fff_f *p;
nsz 588927
nsz 588927
	for (i = 0; i < sizeof t/sizeof *t; i++) {
nsz 588927
		p = t + i;
nsz 588927
nsz 588927
		if (p->r < 0)
nsz 588927
			continue;
nsz 588927
		fesetround(p->r);
nsz 588927
		feclearexcept(FE_ALL_EXCEPT);
nsz 588927
		y = fmaf(p->x, p->x2, p->x3);
nsz 588927
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
nsz 588927
Szabolcs Nagy cda5e0
		/* do not check inexact by default */
Szabolcs Nagy cda5e0
#if defined CHECK_INEXACT || defined CHECK_INEXACT_OMISSION
Szabolcs Nagy cda5e0
		if (!checkexceptall(e, p->e, p->r)) {
Szabolcs Nagy cda5e0
#else
Szabolcs Nagy cda5e0
		if (!checkexceptall(e|INEXACT, p->e|INEXACT, p->r)) {
Szabolcs Nagy cda5e0
#endif
nsz 588927
			printf("%s:%d: bad fp exception: %s fmaf(%a,%a,%a)=%a, want %s",
nsz 588927
				p->file, p->line, rstr(p->r), p->x, p->x2, p->x3, p->y, estr(p->e));
nsz 588927
			printf(" got %s\n", estr(e));
nsz 588927
			err++;
nsz 588927
		}
nsz 588927
		d = ulperrf(y, p->y, p->dy);
Szabolcs Nagy 5729b0
		if (!checkcr(y, p->y, p->r)) {
nsz 588927
			printf("%s:%d: %s fmaf(%a,%a,%a) want %a got %a ulperr %.3f = %a + %a\n",
nsz 588927
				p->file, p->line, rstr(p->r), p->x, p->x2, p->x3, p->y, y, d, d-p->dy, p->dy);
nsz 588927
			err++;
nsz 588927
		}
nsz 588927
	}
nsz 588927
	return !!err;
nsz 588927
}