[LLVMbugs] [Bug 18048] New: Regression: NaN handling differs from LLVM 3.1-3.3

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Nov 24 13:15:33 PST 2013


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

            Bug ID: 18048
           Summary: Regression: NaN handling differs from LLVM 3.1-3.3
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: kai at redstar.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11601
  --> http://llvm.org/bugs/attachment.cgi?id=11601&action=edit
IR file demonstrating the problem.

The attached IR code is reduced from a D program. It can be compiled and run on
Linux/x86_64.

Compiled with llc -filetype=obj bug.ll ; gcc -o bug bug.o ; ./bug it produces
the output:

0000ffff - 0000ffff

but compiled with opt -O3 <bug.ll | llc -filetype=obj >bug.o ; gcc -o bug bug.o
; ./bug it produces the output:

0000ffff - 00007fff

The root cause seems to be that -real.nan is negativ but 2* -real.nan is
positiv (with -O3). That is really surprising.

The original D program is:
import core.stdc.stdio : printf;

ushort sign(real x)
{
    ushort* pxe = cast(ushort *)&x;
    return pxe[4];
}


void main()
{
    real x = -real.nan;
    real y = 2*x;
    printf("%08x - %08x\n", sign(x), sign(y));
}

This happens only with LLVM3.4+, not with LLVM 3.1/3.2/3.3.

-- 
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/20131124/42fd7150/attachment.html>


More information about the llvm-bugs mailing list