summaryrefslogtreecommitdiff
path: root/src/jit
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2018-10-25 08:17:49 -0700
committerGitHub <noreply@github.com>2018-10-25 08:17:49 -0700
commit1370fb92bc9c1ae9475e92f8638c827128c84527 (patch)
treec38e5fdd8c21ba48b3e3d4c64825843292b2519f /src/jit
parente210c1cef74a6c245f91b8215772895e57a4813e (diff)
downloadcoreclr-1370fb92bc9c1ae9475e92f8638c827128c84527.tar.gz
coreclr-1370fb92bc9c1ae9475e92f8638c827128c84527.tar.bz2
coreclr-1370fb92bc9c1ae9475e92f8638c827128c84527.zip
JIT: ensure float folding is done using float precision (#20578)
Cast float folded values back to float before assigning to the double the jit uses for storing FP literal constants. Fixes #20561. No diffs on Core; exposing the original bug requires building RyuJit with an older x86 C++ compiler that uses x87 floating point.
Diffstat (limited to 'src/jit')
-rw-r--r--src/jit/gentree.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp
index 37feba6fcb..5c785da3c7 100644
--- a/src/jit/gentree.cpp
+++ b/src/jit/gentree.cpp
@@ -14082,7 +14082,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
i1 = (d1 > d2);
goto FOLD_COND;
- // non-x86 arch: floating point arithmetic should be done in declared
+ // Floating point arithmetic should be done in declared
// precision while doing constant folding. For this reason though TYP_FLOAT
// constants are stored as double constants, while performing float arithmetic,
// double constants should be converted to float. Here is an example case
@@ -14099,7 +14099,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
{
f1 = forceCastToFloat(d1);
f2 = forceCastToFloat(d2);
- d1 = f1 + f2;
+ d1 = forceCastToFloat(f1 + f2);
}
else
{
@@ -14112,7 +14112,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
{
f1 = forceCastToFloat(d1);
f2 = forceCastToFloat(d2);
- d1 = f1 - f2;
+ d1 = forceCastToFloat(f1 - f2);
}
else
{
@@ -14125,7 +14125,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
{
f1 = forceCastToFloat(d1);
f2 = forceCastToFloat(d2);
- d1 = f1 * f2;
+ d1 = forceCastToFloat(f1 * f2);
}
else
{
@@ -14142,7 +14142,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
{
f1 = forceCastToFloat(d1);
f2 = forceCastToFloat(d2);
- d1 = f1 / f2;
+ d1 = forceCastToFloat(f1 / f2);
}
else
{