<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 - Miscompile with the PPC backend after r329047"
   href="https://bugs.llvm.org/show_bug.cgi?id=37229">37229</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompile with the PPC backend after r329047
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

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

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chandlerc@gmail.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=20221" name="attach_20221" title="IR input">attachment 20221</a> <a href="attachment.cgi?id=20221&action=edit" title="IR input">[details]</a></span>
IR input

We've found that after r329047 the PPC backend appears to miscompile zlib
v1.2.11 code. Specifically, the gen_bitlen function here:
<a href="https://github.com/madler/zlib/blob/master/trees.c#L486">https://github.com/madler/zlib/blob/master/trees.c#L486</a>

The only functional reproducer we have sadly involves building zlib with a
clang including this revision, linking that zlib against clang itself built
targeting PPC, and then running one of the OpenMP Clang tests that uses PCH
files that are zlib compressed. Literally no other test we have duplicates this
failure. =/

However, turning -O1 off for this file causes the bug to go away, and reverting
this commit produces a single interesting diff in the assembly for this file
and it is within the identified function, so I'm fairly certain the issue is
there.

I don't really have a normal development environment for PPC so its hard for me
to really dig furhter into this, but I will attach the single-function IR file
(which I've cleaned up manually, but left as much intact as possible, notably
debug info so it should be possible to trace what code comes from what part of
the C code in that file), and the good and bad version of the assembly.

The bad version of the assembly was generated by 'llc' running over this IR
file with no extra flags. The good version had this commit reverted in the
'llc' and then run over this IR file with no extra flags.

The diff in the assembly exactly matches the diff we observe in the real build.</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>