Re: Optimization bug with floating-point?

From: Steve Kargl <sgk_at_troutmask.apl.washington.edu>
Date: Thu, 14 Mar 2019 09:46:03 -0700
On Wed, Mar 13, 2019 at 11:30:07PM -0700, Steve Kargl wrote:
> 
> Spent a couple hours wandering in contrib/llvm.  Have no idea
> how to fix clang to actually work on i386/387.  Any ideas 
> would be welcomed.
> 
> AFAICT, all libm float routines need to be modified to conditional
> include ieeefp.h and call fpsetprec(FP_PD).  This will work around
> issues is FP and libm.  FreeBSD needs to issue an erratum about 
> the numerical issues with clang.
> 

Probably beating a dead horse, but I'll continue as someone
might actually be able to me fix clang.

clang has the ability to determine the default precision that
the FPU on i386 is using.

#include <err.h>
#include <ieeefp.h>
#include <stdio.h>
#include <stdlib.h>

int
main(void)
{

   fp_prec_t p;

   p = fpgetprec();

   switch(p) {
   case FP_PS:
      printf("24 bit (single-precision)\n");
      break;
   case FP_PRS:
      printf("reserved\n");
      break;
   case FP_PD:
      printf("53 bit (double-precision)\n");
      break;
   case FP_PE:
      printf("64 bit (extended-precision)\n");
      break;
   default:
      errx(1,"unable to determine precision");
   };

   return 0;
}

%  cc -o z -O2 d.c && ./z
53 bit (double-precision)

It is likely that one (or more files) in contrib/llvm/Target/X86
to be fixed.  Unfortunately, there are 116 files, which are written
in languages I do not know.

Any pointers of which file(s) to poke?

-- 
Steve
Received on Thu Mar 14 2019 - 15:46:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:20 UTC