<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Regression: NaN handling differs from LLVM 3.1-3.3"
   href="http://llvm.org/bugs/show_bug.cgi?id=18048">18048</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regression: NaN handling differs from LLVM 3.1-3.3
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kai@redstar.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=11601" name="attach_11601" title="IR file demonstrating the problem.">attachment 11601</a> <a href="attachment.cgi?id=11601&action=edit" title="IR file demonstrating the problem.">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>