<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 - powerpc: wrong floating point constant emitted in constant pool"
   href="https://bugs.llvm.org/show_bug.cgi?id=51096">51096</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>powerpc: wrong floating point constant emitted in constant pool
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>11.0
          </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>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bugdal@aerifal.cx
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25024" name="attach_25024" title="test case">attachment 25024</a> <a href="attachment.cgi?id=25024&action=edit" title="test case">[details]</a></span>
test case

This test case comes from musl libc's floor.c, adapted to be a standalone file.
It was found to be miscompiled, first for powerpcspe, by libc-test, but the
same turns out to happen on normal non-spe powerpc as well. The failing tests
included floor(-0x1.fffffffffffffp-1) and a number of other calls with
small-magnitude arguments.

In the code path for small exponent (integer part zero), the ternary gets
emitted as a branch and conditional load from a constant pool, but instead of
having -1.0 in the constant pool for the true branch, +1.0 is there. I tried
minifying the test case further, but most changes I tried produced bit
arithmetic instead of the constant pool loads, and masked the problem. Putting
(double)-1 instead of -1 in the ternary, so as not to rely on promotion of the
integer result to double, also masks the problem.

I'm not sure if the description of this bug is correct. It's possible that some
earlier transformation introduces the wrong value, instead of it happening when
emitting the rodata.

I checked other targets that use loads from a constant pool for floating point
values like this, including armhf, s390x, and mips, and they were not affected,
so the issue seems to be powerpc-backend-specific.</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>