<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Miscompilation in arm64 backend"
   href="https://bugs.llvm.org/show_bug.cgi?id=33100">33100</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompilation in arm64 backend
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>llc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>human@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18471" name="attach_18471" title="Returns 0 when compiled correctly">attachment 18471</a> <a href="attachment.cgi?id=18471&action=edit" title="Returns 0 when compiled correctly">[details]</a></span>
Returns 0 when compiled correctly

I came across a miscompilation bug on arm64.  I reduced it to a small test case
that is successful when compiled with -O0 but miscompiles with -O1.

Repro steps:

$ llc -relocation-model=pic -mcpu=cyclone -disable-fp-elim -O0 -o
reduced_good.s reduced_test_case.ll
$ clang -arch arm64 -x assembler -o reduced_good reduced_good.s

Execute on any arm64 device:

$ ./reduced_good 
$ echo $?
0

$ llc -relocation-model=pic -mcpu=cyclone -disable-fp-elim -O1 -o reduced_bad.s
reduced_test_case.ll
$ clang -arch arm64 -x assembler -o reduced_bad reduced_bad.s

Execute on any arm64 device:

$ ./reduced_good 
$ echo $?
1

After disassembling both, the bad one shows several 32-bit operations which are
somewhat unexpected in a function with only 64-bit operations.  The unoptimized
assembly also uses only 64-bit operations.  Maybe the > 32-bit left shift
triggers a mistake in the optimization to overaggressively truncate some
values.</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>