<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 --- - PPC64: Possible endian issue in optimization"
   href="http://llvm.org/bugs/show_bug.cgi?id=16147">16147</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>PPC64: Possible endian issue in optimization
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: PowerPC
          </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=10584" name="attach_10584" title="IR file demonstrating the problem.">attachment 10584</a> <a href="attachment.cgi?id=10584&action=edit" title="IR file demonstrating the problem.">[details]</a></span>
IR file demonstrating the problem.

You get 2 different results for the attached file y.ll depending on
optimization level:

[u0012540@172-29-171-104 build-ldc]$ llvm-as y.ll; opt -O1 y.bc | llc
-filetype=obj >y.o ; gcc -m64 -o y y.o ; ./y ; echo $?
1
[u0012540@172-29-171-104 build-ldc]$ llvm-as y.ll; opt -O2 y.bc | llc
-filetype=obj >y.o ; gcc -m64 -o y y.o ; ./y ; echo $?
0

The result from level -O1 is the right one. The wrong output does not occur if
you only use llc. The IR code is derived from the following D code:

private union EndianSwapper
{
    bool value;
    ubyte[bool.sizeof] array;
}

int main()
{
    EndianSwapper es = void;
    es.array[0] = 1;
    immutable retval = es.value;
    return retval;
}

which is derived from the failure of the following identity:

assert(bigEndianToNative!bool(nativeToBigEndian(bool.max)) == bool.max);</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>