[LLVMbugs] [Bug 216] NEW: floating-point unary minus is incorrect

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Jan 30 09:39:10 PST 2004


           Summary: floating-point unary minus is incorrect
           Product: tools
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: sabre at nondot.org
        ReportedBy: mkahl at apple.com

LLVM does not have unary operators, so unary minus is emulated as "0 - x".  This is not correct for IEEE 
floating-point numbers.

In particular, the negation of "0.0" should be "-0.0", not "0.0", because positive and negative zeroes are 
distinct in IEEE.  I will attach a test program that illustrates this difference.

I don't know whether LLVM's treatment is also incorrect for NaN's and Inf's...

On the PowerPC, this could be easily fixed by emulating floating-point unary minus as "-0.0 - x" (rather 
than "+0.0 - x").  However, (a) I don't know whether this also works for NaN's and Inf's, and (b) I don't 
know whether this works in general on other processors.

You may need to rethink the decision to omit true unary operators from the LLVM IR.

You could argue that IEEE floating-point is not a strict requirement of the C/C++ standards, but in 
practice that is what people expect (and get, from gcc).

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list