[llvm-bugs] [Bug 24599] clang++ cannot cast double to unsigned correctly.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 28 19:10:23 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24599

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Richard Smith <richard-llvm at metafoo.co.uk> ---
> Target: powerpc64le-unknown-linux-gnu

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150829/dc9221e9/attachment.html>


More information about the llvm-bugs mailing list