summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/InitPreprocessor.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2019-05-31 01:21:36 +0000
committerJohn McCall <rjmccall@apple.com>2019-05-31 01:21:36 +0000
commit059b823e709a90d3b5d2d24663830e59b3bdded9 (patch)
tree39392b05b6b230e4acec135a3ed95dbf1e6cb95c /clang/lib/Frontend/InitPreprocessor.cpp
parentb5a45bb77e05647f04bbd9780d70aabe9f251155 (diff)
downloadbcm5719-llvm-059b823e709a90d3b5d2d24663830e59b3bdded9.tar.gz
bcm5719-llvm-059b823e709a90d3b5d2d24663830e59b3bdded9.zip
Fix the predefined exponent limit macros for the 16-bit IEEE format.
The magnitude range of normalized _Float16 is 2^-14 (~6e-5) to (2-2^-10)*2^15 (65504). You might think, then, that the code is correct to defne FLT16_MIN_EXP and FLT16_MAX_EXP to be -14 and 15 respectively. However, for some reason the C specification actually specifies a bias for these macros: C11 5.2.4.2.2: - minimum negative integer such that FLT_RADIX raised to one less than that power is a normalized floating-point number, e_min: FLT_MIN_EXP DBL_MIN_EXP LDBL_MIN_EXP - maximum integer such that FLT_RADIX raised to one less than that power is a representable finite floating-point number, e_max: FLT_MAX_EXP DBL_MAX_EXP LDBL_MAX_EXP FLT16_MIN_EXP and FLT16_MAX_EXP should clearly be biased the same way, and other compilers do in fact do so, as do our OpenCL headers for `half`. Additionally, FLT16_MIN_10_EXP is just wrong. llvm-svn: 362183
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index cc479dd010f..1741ba5e520 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -122,10 +122,10 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
"4.94065645841246544176568792868221e-324",
"1.92592994438723585305597794258492732e-34");
int MantissaDigits = PickFP(Sem, 11, 24, 53, 64, 106, 113);
- int Min10Exp = PickFP(Sem, -13, -37, -307, -4931, -291, -4931);
+ int Min10Exp = PickFP(Sem, -4, -37, -307, -4931, -291, -4931);
int Max10Exp = PickFP(Sem, 4, 38, 308, 4932, 308, 4932);
- int MinExp = PickFP(Sem, -14, -125, -1021, -16381, -968, -16381);
- int MaxExp = PickFP(Sem, 15, 128, 1024, 16384, 1024, 16384);
+ int MinExp = PickFP(Sem, -13, -125, -1021, -16381, -968, -16381);
+ int MaxExp = PickFP(Sem, 16, 128, 1024, 16384, 1024, 16384);
Min = PickFP(Sem, "6.103515625e-5", "1.17549435e-38", "2.2250738585072014e-308",
"3.36210314311209350626e-4932",
"2.00416836000897277799610805135016e-292",
OpenPOWER on IntegriCloud