<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 - [X86] uint64->f32 on 32-bit Windows without SSE can have double rounding"
   href="https://bugs.llvm.org/show_bug.cgi?id=44549">44549</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86] uint64->f32 on 32-bit Windows without SSE can have double rounding
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>craig.topper@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>On 32-bit targets without SSE we use the X87 unit to do uint64_t -> f32/f64/f80
conversions by converting a 64-bit integer into 80-bit extended precision using
FILD. This is a signed conversion so then we add a fixup that is either 0 or
2^64 based on whether the original number was negative. Then we round the
result if the destination type is f32 or f64.

This should work correctly assuming the the PC field in X87's FPCW is set to
80-bit. The FILD is not subject to the PC field, but the fixup FADD is.

On Windows, the PC field defaults to 64-bit. So the fixup FADD will round to
the double precision. This means if we're doing a conversion from uint64_t to
fp32, we'll round after the fixup FADD and round again when we do the fst to
round to f32.

Conversions to f64 should fine since we'll just round after the FADD and the
final rounding operation won't do anything.</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>