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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to