NaN fixes for clang backend (#9652)

This commit is contained in:
Arne Döring 2018-11-08 20:17:37 +01:00 • committed by GitHub
commit 6a57ec6d2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 9 deletions

View file

@ -267,12 +267,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
of mSubF64: result = newFloatNodeT(getFloat(a) - getFloat(b), n, g) of mSubF64: result = newFloatNodeT(getFloat(a) - getFloat(b), n, g)
of mMulF64: result = newFloatNodeT(getFloat(a) * getFloat(b), n, g) of mMulF64: result = newFloatNodeT(getFloat(a) * getFloat(b), n, g)
of mDivF64: of mDivF64:
if getFloat(b) == 0.0: result = newFloatNodeT(getFloat(a) / getFloat(b), n, g)
if getFloat(a) == 0.0: result = newFloatNodeT(NaN, n, g)
elif getFloat(b).classify == fcNegZero: result = newFloatNodeT(-Inf, n, g)
else: result = newFloatNodeT(Inf, n, g)
else:
result = newFloatNodeT(getFloat(a) / getFloat(b), n, g)
of mMaxF64: of mMaxF64:
if getFloat(a) > getFloat(b): result = newFloatNodeT(getFloat(a), n, g) if getFloat(a) > getFloat(b): result = newFloatNodeT(getFloat(a), n, g)
else: result = newFloatNodeT(getFloat(b), n, g) else: result = newFloatNodeT(getFloat(b), n, g)

View file

@ -2041,11 +2041,11 @@ proc getRefcount*[T](x: seq[T]): int {.importc: "getRefcount", noSideEffect,
const const
Inf* {.magic: "Inf".} = 1.0 / 0.0 Inf* = 0x7FF0000000000000'f64
## contains the IEEE floating point value of positive infinity. ## contains the IEEE floating point value of positive infinity.
NegInf* {.magic: "NegInf".} = -Inf NegInf* = 0xFFF0000000000000'f64
## contains the IEEE floating point value of negative infinity. ## contains the IEEE floating point value of negative infinity.
NaN* {.magic: "NaN".} = 0.0 / 0.0 NaN* = 0x7FF7FFFFFFFFFFFF'f64
## contains an IEEE floating point value of *Not A Number*. Note ## contains an IEEE floating point value of *Not A Number*. Note
## that you cannot compare a floating point value to this value ## that you cannot compare a floating point value to this value
## and expect a reasonable result - use the `classify` procedure ## and expect a reasonable result - use the `classify` procedure