[LLVMbugs] [Bug 20870] New: no-signed-zero optimization flag isn't honored for an fneg operation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Sep 6 10:23:40 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20870

            Bug ID: 20870
           Summary: no-signed-zero optimization flag isn't honored for an
                    fneg operation
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ clang -v
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

$ cat fneg.c
float fneg(float x) {
    return 0.0f - x;
}

$ ./clang -O2 -fno-signed-zeros fneg.c -S -o -
...
    xorps    %xmm1, %xmm1
    subss    %xmm0, %xmm1
    movaps    %xmm1, %xmm0
    popq    %rbp
    retq

-----------------------------------------------------------------------

There shouldn't be any subtraction generated here; this should just be an xor
to flip the sign bit. 

I think this is a bug in the middle-end (opt, IR transforms) because the
back-end doesn't appear to have any logic to recognize the no-signed-zeros
optimization option.

So we should be transforming this:
  %sub = fsub float 0.0, %x

Into this:
  %sub = fsub float -0.0, %x

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140906/94d5ec1c/attachment.html>


More information about the llvm-bugs mailing list