From ebd3759f6449a6425f0e123ea8bbac3737d06b62 Mon Sep 17 00:00:00 2001 From: Paul Osmialowski Date: Wed, 10 Apr 2019 12:38:36 +0100 Subject: [PATCH] [flang] AArch64: Set flushing mode for subnormals on glibc and bionic based systems Signed-off-by: Paul Osmialowski Original-commit: flang-compiler/f18@4881e3a91c34671a38ef410a771cd8e0e7a62e10 Reviewed-on: https://github.com/flang-compiler/f18/pull/397 --- flang/lib/evaluate/host.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/flang/lib/evaluate/host.cc b/flang/lib/evaluate/host.cc index 680a6c7d26cf..86a9cea02f91 100644 --- a/flang/lib/evaluate/host.cc +++ b/flang/lib/evaluate/host.cc @@ -42,6 +42,24 @@ void HostFloatingPointEnvironment::SetUpHostFloatingPointEnvironment( currentFenv_.__mxcsr &= ~0x8000; // result currentFenv_.__mxcsr &= ~0x0040; // operands } +#elif defined(__aarch64__) +#if defined(__GNU_LIBRARY__) + if (context.flushSubnormalsToZero()) { + currentFenv_.__fpcr |= (1U << 24); // control register + } else { + currentFenv_.__fpcr &= ~(1U << 24); // control register + } +#elif defined(__BIONIC__) + if (context.flushSubnormalsToZero()) { + currentFenv_.__control |= (1U << 24); // control register + } else { + currentFenv_.__control &= ~(1U << 24); // control register + } +#else + // TODO other C libraries on AArch64 + context.messages().Say( + "TODO: flushing mode for subnormals is not set for this host architecture due to incompatible C library it uses"_en_US); +#endif #else // TODO other architectures context.messages().Say(