<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - clang++ cannot cast double to unsigned correctly."
   href="https://llvm.org/bugs/show_bug.cgi?id=24599">bug 24599</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>FIXED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - clang++ cannot cast double to unsigned correctly."
   href="https://llvm.org/bugs/show_bug.cgi?id=24599#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - clang++ cannot cast double to unsigned correctly."
   href="https://llvm.org/bugs/show_bug.cgi?id=24599">bug 24599</a>
              from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
        <pre><span class="quote">> Target: powerpc64le-unknown-linux-gnu</span >

Ah, this was a bug in the PPC64LE backend. Reduced testcase:

unsigned f(double d) { return d; }

int main(){
   volatile double d1 = 10.0L;
   return unsigned(d1);
}

Here's the assembly from 3.5 and 3.6:

    fctidz 0, 1
    stfd 0, -16(1)
    lwz 3, -12(1)
    blr

and here's the assembly from 3.7 onwards:

    xscvdpuxws 0, 1
    mfvsrwz 3, 0
    clrldi     3, 3, 32
    blr

Note that the 3.5 and 3.6 code is converting the double to a 64-bit integer,
then trying to truncate to 32 bits... but it looks like it's picking the wrong
32 bits.

Anyway, marking as fixed since it's working on trunk and in 3.7.</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>