[compiler-rt] [compiler-rt][ARM] Double-precision FP support functions (PR #179920)

Simon Tatham via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 07:55:51 PDT 2026


================
@@ -0,0 +1,78 @@
+//===-- dunder.c - Handle double-precision floating-point underflow -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This helper function is available for use by double-precision float
+// arithmetic implementations to handle underflowed output values, if they were
+// computed in the form of a normalized mantissa and an out-of-range exponent.
+//
+// On input: x should be a complete IEEE 754 floating-point value representing
+// the desired output scaled up by 2^1536 (the same value that would have been
+// passed to an underflow trap handler in IEEE 754:1985).
+//
+// This isn't enough information to re-round to the correct output denormal
+// without also knowing whether x itself has already been rounded, and which
+// way. 'errsign' gives this information, by indicating the sign of the value
+// (true result - x). That is, if errsign > 0 it means the true value was
+// larger (x was rounded down); if errsign < 0 then x was rounded up; if
+// errsign == 0 then x represents the _exact_ desired output value.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdint.h>
+
+#define SIGNBIT 0x8000000000000000
----------------
statham-arm wrote:

I'm not sure what you mean by the reference to Windows. On a 64-bit platform, I'd expect you meant the fact that `long` is only 32 bits instead of Linux's choice of 64. But this function is (currently) used on 32-bit Arm, so `long` is 32 bits whether we're on Windows or not.

In any case, I don't think this needs a suffix. A C integer literal is assigned a type large enough for it to fit into, so this will have a 64-bit integer type no matter which integer type that turns out to be on a given target.

https://github.com/llvm/llvm-project/pull/179920


More information about the llvm-commits mailing list