Mark negative-zero-to-int conversion as Inexact,
authorDale Johannesen <dalej@apple.com>
Tue, 7 Oct 2008 00:40:01 +0000 (00:40 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 7 Oct 2008 00:40:01 +0000 (00:40 +0000)
since -0.0 can't be represented as an int.
This prevents llvm from reducing -0.0 to a
load-and-convert of int 0.  Fixes
ieee.exp/mzero[2356].c in gcc testsuite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57224 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APFloat.cpp

index b93f1d109a02df01ab0d29410fdccf237de9a1a2..df309d49c664b36c1270c3dcb81db4bf1f3a34cc 100644 (file)
@@ -1784,7 +1784,8 @@ APFloat::convertToSignExtendedInteger(integerPart *parts, unsigned int width,
 
   if(category == fcZero) {
     APInt::tcSet(parts, 0, dstPartsCount);
-    return opOK;
+    // Negative zero can't be represented as an int.
+    return sign ? opInexact : opOK;
   }
 
   src = significandParts();