Child of #30978
The fmaf function is implemented in compiler_rt.
Remove fmaf.c.
There is a TODO inside of the method, though for some reason the tests pass either way. I implemented it, though I want to see if the tests pass here as well.
usebeforefree/zig:libzigc-fmaf into master
Child of #30978
The fmaf function is implemented in compiler_rt.
Remove fmaf.c.
There is a TODO inside of the method, though for some reason the tests pass either way. I implemented it, though I want to see if the tests pass here as well.
zig build test-libc -Dlibc-test-path=/path/to/libc-test -fqemu -fwasmtime -Dtest-filter=fmaf
fails on every tested architecture.
Thanks, I ran the test command without -fqemu -fwasmtime and it worked, which was suspicious to me. I'll check it out tomorrow. The function itself is not complex, though I cannot seem to figure out how to trigger/check for a FE_UNDERFLOW bit. I saw that similar problems are handled with doNotOptimize triggering some bit, but didn't find any example for underflow. Tried this: std.mem.doNotOptimizeAway(0x1p-126 * 0x1p-126) though it either didn't work, or I have some other unknown problem. Anyways if it did work I am not sure how to confirm it works (the underflow bit). So I am kinda stuck atm.
The original func for context:
floatfmaf(floatx,floaty,floatz){#pragmaSTDCFENV_ACCESSONdoublexy,result;union{doublef;uint64_ti;}u;inte;xy=(double)x*y;result=xy+z;u.f=result;e=u.i>>52&0x7ff;/*Commoncase:Thedoubleprecisionresultisfine.*/if((u.i&0x1fffffff)!=0x10000000||/*notahalfwaycase*/e==0x7ff||/*NaN*/(result-xy==z&&result-z==xy)||/*exact*/fegetround()!=FE_TONEAREST)/*notround-to-nearest*/{/*underflowmaynotberaisedcorrectly,example:fmaf(0x1p-120f,0x1p-120f,0x1p-149f)*/#ifdefined(FE_INEXACT)&&defined(FE_UNDERFLOW)if(e<0x3ff-126&&e>=0x3ff-149&&fetestexcept(FE_INEXACT)){feclearexcept(FE_INEXACT);/*TODO:gccandclangbugworkaround*/volatilefloatvz=z;result=xy+vz;if(fetestexcept(FE_INEXACT))feraiseexcept(FE_UNDERFLOW);elseferaiseexcept(FE_INEXACT);}#endifz=result;returnz;}
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?