This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran,patch] Support for IEEE underflow control on x86/x86_64


On Thu, Jul 3, 2014 at 11:25 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

>> The attached patch provides support for underflow control in the IEEE_ARITHMETIC module, for x86/x86_64 targets (our main user base).
>> Bootstrapped and regtested on x86_64-apple-darwin13. Comes with a testcase.

> Index: gcc/testsuite/gfortran.dg/ieee/underflow_1.f90

I'd suggest to name this fie ieee_underflow_1.f90 for consistency.

BTW: underflow control also works on alpha, using following code:

--cut here--
int
support_fpu_underflow_control (int kind)
{
  return (kind == 4 || kind == 8) ? 1 : 0;
}


int
get_fpu_underflow_mode (void)
{
  fenv_t state = __ieee_get_fp_control ();

  /* Return 0 for abrupt underflow (flush to zero), 1 for gradual underflow.  */
  return (state & FE_MAP_UMZ) ? 0 : 1;
}


void
set_fpu_underflow_mode (int gradual __attribute__((unused)))
{
  fenv_t state = __ieee_get_fp_control ();

  if (gradual)
    state &= ~FE_MAP_UMZ;
  else
    state |= FE_MAP_UMZ;

  __ieee_set_fp_control (state);
}
--cut here--

This non-portable code was stuffed into fpu-glibc.h so should be
#ifdef'd with some __ALPHA__ and/or FE_MAP_UMZ check.

Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]