Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 11 additions & 40 deletions src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12042,49 +12042,20 @@ GenTreePtr Compiler::gtFoldExprConst(GenTreePtr tree)
// constants in a target-specific function.
CLANG_FORMAT_COMMENT_ANCHOR;

#ifdef _TARGET_XARCH_
// Don't fold conversions of +inf/-inf to integral value as the value returned by JIT helper
// doesn't match with the C compiler's cast result.
// Don't fold conversions of +inf/-inf to integral value on all platforms
// as the value returned by JIT helper doesn't match with the C compiler's cast result.
// We want the behavior to be same with or without folding.
return tree;
#else //!_TARGET_XARCH_

switch (tree->CastToType())
{
case TYP_BYTE:
i1 = ssize_t(INT8(d1));
goto CNS_INT;
case TYP_UBYTE:
i1 = ssize_t(UINT8(d1));
goto CNS_INT;
case TYP_SHORT:
i1 = ssize_t(INT16(d1));
goto CNS_INT;
case TYP_CHAR:
i1 = ssize_t(UINT16(d1));
goto CNS_INT;
case TYP_INT:
i1 = ssize_t(INT32(d1));
goto CNS_INT;
case TYP_UINT:
i1 = ssize_t(UINT32(d1));
goto CNS_INT;
case TYP_LONG:
lval1 = INT64(d1);
goto CNS_LONG;
case TYP_ULONG:
lval1 = UINT64(d1);
goto CNS_LONG;
case TYP_FLOAT:
case TYP_DOUBLE:
if (op1->gtType == TYP_FLOAT)
d1 = forceCastToFloat(d1); // it's only !_finite() after this conversion
goto CNS_DOUBLE;
default:
unreached();
}
#endif //!_TARGET_XARCH_
}

if (d1 <= -1.0 && varTypeIsUnsigned(tree->CastToType()))
{
// Don't fold conversions of these cases becasue the result is unspecified per ECMA spec
// and the native math doing the fold doesn't match the run-time computation on all platforms.
// We want the behavior to be same with or without folding.
return tree;
}

switch (tree->CastToType())
{
case TYP_BYTE:
Expand Down
2 changes: 1 addition & 1 deletion src/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ HCIMPL1_V(UINT64, JIT_Dbl2ULng, double val)
else {
// subtract 0x8000000000000000, do the convert then add it back again
ret = FastDbl2Lng(val - two63) + I64(0x8000000000000000);
}
}
return ret;
}
HCIMPLEND
Expand Down